-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
icons.ts
55 lines (49 loc) · 1.32 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
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] of flavorEntries) {
let output = "[icon]\n\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 = flavors[identifier]
.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_dark = "${fg}", fg_light = "${fg}" },\n`;
}
output += "]\n";
};
addIcons(icons_by_filename, "files");
addIcons(icons_by_file_extension, "exts");
const dist = `themes/${identifier}.toml`;
const theme = await Deno.readTextFile(dist);
await Deno.writeTextFile(
dist,
theme + "\n" + output,
);
}