Material Design Icons replace the hand-drawn UI icons (only the used ones vendored, Renovate-tracked); route panel: saved-point picker, buttons on two rows with icons
This commit is contained in:
1 parent
a6d63e242b
commit
4c704045c5
10 files changed
+251
-206
No files matched your search
+19
-1
@@ -5,7 +5,7 @@
|
||||
// its PR carries the new files too. Manually: `npm ci && node bin/vendor-sync.mjs`.
|
||||
// Assets not on npm: fonts and the Liberty style/sprite go through
|
||||
// bin/assets-sync.mjs, the NPS plugins are updated by hand.
|
||||
import { copyFileSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
||||
import { copyFileSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
||||
|
||||
const root = new URL("..", import.meta.url).pathname;
|
||||
const nm = (p) => `${root}node_modules/${p}`;
|
||||
@@ -30,3 +30,21 @@ copy("suncalc/LICENSE", "suncalc/LICENSE");
|
||||
|
||||
// Only the flags already vendored (the European subset), not all ~270.
|
||||
for (const f of readdirSync(vendor("flag-icons/1x1"))) copy(`flag-icons/flags/1x1/${f}`, `flag-icons/1x1/${f}`);
|
||||
|
||||
// Material Design Icons: only the mdi* names public/js/ actually uses (the
|
||||
// whole set is ~3 MB), as one small ES module. Using another icon is just
|
||||
// naming it in the code and running this again.
|
||||
const mdi = await import(nm("@mdi/js/mdi.js"));
|
||||
const used = new Set();
|
||||
for (const f of readdirSync(`${root}public/js`)) {
|
||||
if (f.endsWith(".js")) for (const [name] of readFileSync(`${root}public/js/${f}`, "utf8").matchAll(/\bmdi[A-Z]\w*/g)) used.add(name);
|
||||
}
|
||||
const missing = [...used].filter((name) => !mdi[name]);
|
||||
if (missing.length) throw new Error(`not in @mdi/js: ${missing.join(", ")}`);
|
||||
mkdirSync(vendor("mdi"), { recursive: true });
|
||||
writeFileSync(
|
||||
vendor("mdi/mdi.mjs"),
|
||||
`// Generated by bin/vendor-sync.mjs from @mdi/js ${JSON.parse(readFileSync(nm("@mdi/js/package.json"), "utf8")).version}, Apache-2.0 (LICENSE).\n` +
|
||||
[...used].sort().map((name) => `export const ${name} = "${mdi[name]}";\n`).join(""),
|
||||
);
|
||||
copy("@mdi/js/LICENSE", "mdi/LICENSE");
|
||||
Reference in new issue
Block a user