Skip to content

Commit

Permalink
Font Awesome のアイコンを表示するサンプルを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
0918nobita committed Mar 4, 2024
1 parent 9289944 commit 0c1b04d
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"format:check": "prettier --check ."
},
"devDependencies": {
"@fortawesome/free-solid-svg-icons": "6.5.1",
"@types/node": "20.11.24",
"@vanilla-extract/vite-plugin": "4.0.4",
"eslint": "8.57.0",
Expand Down
19 changes: 19 additions & 0 deletions src/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export function volumeHigh(): SVGSVGElement {
const svgEl = document.createElementNS('http://www.w3.org/2000/svg', 'svg');

svgEl.setAttribute(
'viewBox',
`0 0 ${__VOLUME_HIGH_ICON_WIDTH__} ${__VOLUME_HIGH_ICON_HEIGHT__}`,
);

const pathEl = document.createElementNS(
'http://www.w3.org/2000/svg',
'path',
);

pathEl.setAttribute('d', __VOLUME_HIGH_ICON__);

svgEl.append(pathEl);

return svgEl;
}
3 changes: 3 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare const __VOLUME_HIGH_ICON__: string;
declare const __VOLUME_HIGH_ICON_WIDTH__: string;
declare const __VOLUME_HIGH_ICON_HEIGHT__: string;
6 changes: 6 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { faVolumeHigh } from '@fortawesome/free-solid-svg-icons';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import { defineConfig } from 'vite';

Expand All @@ -19,6 +20,11 @@ export default defineConfig({
external: ['obsidian'],
},
},
define: {
__VOLUME_HIGH_ICON__: JSON.stringify(faVolumeHigh.icon[4]),
__VOLUME_HIGH_ICON_WIDTH__: JSON.stringify(faVolumeHigh.icon[0]),
__VOLUME_HIGH_ICON_HEIGHT__: JSON.stringify(faVolumeHigh.icon[1]),
},
plugins: [
vanillaExtractPlugin({
identifiers: ({ hash }) => `zhongwenBlock_${hash}`,
Expand Down

0 comments on commit 0c1b04d

Please sign in to comment.