-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathicons.ts
56 lines (50 loc) · 1.43 KB
/
icons.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { closest } from "ctpvert";
import { type ColorName, flavorEntries, flavors } from "@catppuccin/palette";
const { icons_by_filename, icons_by_file_extension } = JSON.parse(
await Deno.readTextFile("./icons.json"),
) as Record<
string,
Record<
string,
{
name: string;
icon: string;
cterm_color: string;
color: string;
}
>
>;
const hex_to_color_overrides = {
"#dddddd": "text",
};
for (const [identifier, { colors, colorEntries }] of flavorEntries) {
let output = "[icon]\n";
const addIcons = (
icons: Record<string, { color: string; icon: string }>,
name: string,
) => {
output += `${name} = [\n`;
for (const [key, { color, icon }] of Object.entries(icons)) {
const fg = colors[
(hex_to_color_overrides[
color as keyof typeof hex_to_color_overrides
] ||
closest(color)[identifier].name) as ColorName
]
.hex;
output +=
` { name = "${key}", text = "${icon}", fg = "${fg}" },\n`;
}
output += "]\n";
};
addIcons(icons_by_filename, "files");
addIcons(icons_by_file_extension, "exts");
await Promise.all(colorEntries.filter(([_, c]) => c.accent).map(async ([accent]) => {
const dist = `themes/${identifier}/catppuccin-${identifier}-${accent}.toml`;
const theme = await Deno.readTextFile(dist);
await Deno.writeTextFile(
dist,
theme + "\n" + output,
);
}));
}