From d63a16e2d0d9969ea6110c5672966c3f74e53ee5 Mon Sep 17 00:00:00 2001 From: MultiMote Date: Fri, 27 Sep 2024 22:58:51 +0300 Subject: [PATCH] Move to material-icons (#30) --- gen-mdi-list.mjs | 50 + index.html | 2 + package.json | 6 +- src/App.svelte | 17 +- src/font.scss | 10 + src/lib/BarcodeParamsControls.svelte | 10 +- src/lib/BrowserWarning.svelte | 5 +- src/lib/CsvControl.svelte | 5 +- src/lib/FaIcon.svelte | 25 - src/lib/GenericObjectParamsControls.svelte | 6 +- src/lib/IconPicker.svelte | 23 +- src/lib/ImageEditor.svelte | 38 +- src/lib/LabelPresetsBrowser.svelte | 11 +- src/lib/LabelPropsEditor.svelte | 6 +- src/lib/MdIcon.svelte | 9 + src/lib/ObjectPicker.svelte | 20 +- src/lib/ParamLockButton.svelte | 14 +- src/lib/PrintPreview.svelte | 8 +- src/lib/PrinterConnector.svelte | 8 +- src/lib/QRCodeParamsControls.svelte | 4 +- src/lib/TextParamsControls.svelte | 71 +- src/lib/VariableInsertControl.svelte | 10 +- src/lib/ZplImportButton.svelte | 8 +- src/locale/index.ts | 1 + src/locale/ru.ts | 1 + src/mdi_icons.ts | 2130 ++++++++++++++++++++ src/style.scss | 26 +- src/utils/image_editor_utils.ts | 30 +- vite.config.ts | 3 - yarn.lock | 24 +- 30 files changed, 2374 insertions(+), 207 deletions(-) create mode 100644 gen-mdi-list.mjs delete mode 100644 src/lib/FaIcon.svelte create mode 100644 src/lib/MdIcon.svelte create mode 100644 src/mdi_icons.ts diff --git a/gen-mdi-list.mjs b/gen-mdi-list.mjs new file mode 100644 index 0000000..1b2edce --- /dev/null +++ b/gen-mdi-list.mjs @@ -0,0 +1,50 @@ +import fs from "fs"; +import readline from "readline"; +const codepoints = {}; +const availableIcons = []; + +let fileStream = fs.createReadStream("node_modules/material-icons/css/_codepoints.scss"); + +let rl = readline.createInterface({ + input: fileStream, + crlfDelay: Infinity, +}); + +for await (const line of rl) { + const r = /^\s*"(\w+)": (\w+)/.exec(line); + if (r != null) { + codepoints[r[1]] = r[2]; + } +} +fileStream.close(); + +fileStream = fs.createReadStream("node_modules/material-icons/index.d.ts"); + +rl = readline.createInterface({ + input: fileStream, + crlfDelay: Infinity, +}); + +for await (const line of rl) { + const r = /^\s*"(\w+)"/.exec(line); + if (r != null) { + availableIcons.push(r[1]); + } +} +fileStream.close(); + +console.log(`import { type MaterialIcon } from "material-icons/index.d";`); +console.log(""); +console.log("type IconListItem = Record;"); +console.log(""); +console.log("export const iconCodepoints: IconListItem = {"); + +for (const icon of availableIcons) { + if (icon in codepoints) { + console.log(` "${icon}": 0x${codepoints[icon]},`); + } +} + +console.log("};"); +console.log(""); +console.log('export { type MaterialIcon } from "material-icons/index.d";'); diff --git a/index.html b/index.html index 4d16669..cfef048 100644 --- a/index.html +++ b/index.html @@ -18,6 +18,8 @@ href="node_modules/@fontsource-variable/noto-sans/files/noto-sans-latin-wght-normal.woff2"/> + %VITE_PAGE_TITLE% diff --git a/package.json b/package.json index 49ef48f..4225d66 100644 --- a/package.json +++ b/package.json @@ -10,18 +10,18 @@ "build": "vite build", "build-rel": "vite build --base=./", "preview": "vite preview", - "sv-check": "svelte-check --tsconfig ./tsconfig.json" + "sv-check": "svelte-check --tsconfig ./tsconfig.json", + "gen-mdi-list": "node gen-mdi-list.mjs > src/mdi_icons.ts" }, "dependencies": { "@fontsource-variable/noto-sans": "^5.0.5", - "@fortawesome/fontawesome-svg-core": "^6.5.2", - "@fortawesome/free-solid-svg-icons": "^6.5.2", "@mmote/niimbluelib": "0.0.1-alpha.0", "@popperjs/core": "^2.11.8", "bootstrap": "5.3.3", "d3-dsv": "^3.0.1", "dayjs": "^1.11.13", "fabric": "5.4.0-browser", + "material-icons": "^1.13.12", "qrcode-svg": "^1.1.0" }, "devDependencies": { diff --git a/src/App.svelte b/src/App.svelte index 405b40f..6fcc2d7 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,20 +1,5 @@ -{#if loading} -
Loading resources...
-{:else} - -{/if} + diff --git a/src/font.scss b/src/font.scss index 702d685..d213684 100644 --- a/src/font.scss +++ b/src/font.scss @@ -18,3 +18,13 @@ src: url(@fontsource-variable/noto-sans/files/noto-sans-cyrillic-wght-normal.woff2) format("woff2-variations"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } + + +/* material-icons */ +@font-face { + font-family: "Material Icons"; + font-style: normal; + font-display: swap; + font-weight: 400; + src: url(material-icons/iconfont/material-icons.woff2) format("woff2"); +} diff --git a/src/lib/BarcodeParamsControls.svelte b/src/lib/BarcodeParamsControls.svelte index 8464b70..996c110 100644 --- a/src/lib/BarcodeParamsControls.svelte +++ b/src/lib/BarcodeParamsControls.svelte @@ -1,7 +1,7 @@ @@ -9,7 +9,8 @@ {#if !bluetooth && !serial}