import { mkdir, writeFile } from "node:fs/promises";
import { icons, iconNames, iconSvg } from "../icons/icons.js";
const root = new URL("../icons/", import.meta.url);
await mkdir(new URL("svg/", root), { recursive: true });
for (const name of iconNames)
await writeFile(
new URL(`svg/${name}.svg`, root),
iconSvg(name, { label: icons[name].label }) + "\n",
);
await writeFile(
new URL("sprite.svg", root),
`\n`,
);
await writeFile(
new URL("manifest.json", root),
JSON.stringify(
{
name: "Anidev Dock Icons",
version: "1.0.0",
grid: 24,
stroke: 1.5,
count: iconNames.length,
icons: iconNames.map((name) => ({
name,
label: icons[name].label,
category: icons[name].category,
file: `svg/${name}.svg`,
})),
},
null,
2,
) + "\n",
);
const categories = [...new Set(iconNames.map((name) => icons[name].category))];
const groupNames = {
navigation: "Навигация",
account: "Аккаунт",
security: "Безопасность",
actions: "Действия",
files: "Файлы",
system: "Система",
status: "Состояния",
direction: "Направления",
};
for (const theme of ["dark", "light"]) {
const [bg, ink, muted, line, accent] =
theme === "dark"
? ["#111f26", "#e3f2f3", "#a5bec5", "#3b535c", "#77cbbb"]
: ["#edf3f3", "#173239", "#4c666d", "#c6d7da", "#12616a"];
const rows = categories
.map((category, row) => {
const y = 178 + row * 118;
return `${groupNames[category]}${iconNames
.filter((name) => icons[name].category === category)
.map((name, col) => {
const x = 56 + col * 106;
return `${name}`;
})
.join("")}`;
})
.join("");
await writeFile(
new URL(`preview-${theme}.svg`, root),
`\n`,
);
}
console.log(
`Built ${iconNames.length} icons, sprite, manifest and two contact sheets.`,
);