common.ts

 1import { dark, light, mirage } from "ayu"
 2import {
 3    chroma,
 4    color_ramp,
 5    ThemeLicenseType,
 6    ThemeSyntax,
 7    ThemeFamilyMeta,
 8} from "../../common"
 9
10export const ayu = {
11    dark,
12    light,
13    mirage,
14}
15
16export const build_theme = (t: typeof dark, light: boolean) => {
17    const color = {
18        light_blue: t.syntax.tag.hex(),
19        yellow: t.syntax.func.hex(),
20        blue: t.syntax.entity.hex(),
21        green: t.syntax.string.hex(),
22        teal: t.syntax.regexp.hex(),
23        red: t.syntax.markup.hex(),
24        orange: t.syntax.keyword.hex(),
25        light_yellow: t.syntax.special.hex(),
26        gray: t.syntax.comment.hex(),
27        purple: t.syntax.constant.hex(),
28    }
29
30    const syntax: ThemeSyntax = {
31        constant: { color: t.syntax.constant.hex() },
32        "string.regex": { color: t.syntax.regexp.hex() },
33        string: { color: t.syntax.string.hex() },
34        comment: { color: t.syntax.comment.hex() },
35        keyword: { color: t.syntax.keyword.hex() },
36        operator: { color: t.syntax.operator.hex() },
37        number: { color: t.syntax.constant.hex() },
38        type: { color: color.blue },
39        boolean: { color: color.purple },
40        "punctuation.special": { color: color.purple },
41        "string.special": { color: t.syntax.special.hex() },
42        function: { color: t.syntax.func.hex() },
43    }
44
45    return {
46        ramps: {
47            neutral: chroma.scale([
48                light ? t.editor.fg.hex() : t.editor.bg.hex(),
49                light ? t.editor.bg.hex() : t.editor.fg.hex(),
50            ]),
51            red: color_ramp(chroma(color.red)),
52            orange: color_ramp(chroma(color.orange)),
53            yellow: color_ramp(chroma(color.yellow)),
54            green: color_ramp(chroma(color.green)),
55            cyan: color_ramp(chroma(color.teal)),
56            blue: color_ramp(chroma(color.blue)),
57            violet: color_ramp(chroma(color.purple)),
58            magenta: color_ramp(chroma(color.light_blue)),
59        },
60        syntax,
61    }
62}
63
64export const build_syntax = (t: typeof dark): ThemeSyntax => {
65    return {
66        constant: { color: t.syntax.constant.hex() },
67        "string.regex": { color: t.syntax.regexp.hex() },
68        string: { color: t.syntax.string.hex() },
69        comment: { color: t.syntax.comment.hex() },
70        keyword: { color: t.syntax.keyword.hex() },
71        operator: { color: t.syntax.operator.hex() },
72        number: { color: t.syntax.constant.hex() },
73        type: { color: t.syntax.regexp.hex() },
74        "punctuation.special": { color: t.syntax.special.hex() },
75        "string.special": { color: t.syntax.special.hex() },
76        function: { color: t.syntax.func.hex() },
77    }
78}
79
80export const meta: ThemeFamilyMeta = {
81    name: "Ayu",
82    author: "dempfi",
83    license_type: ThemeLicenseType.MIT,
84    license_url: "https://github.com/dempfi/ayu",
85}