1import { Scale, Color } from "chroma-js"
2import { Syntax } from "./syntax"
3
4interface ThemeMeta {
5 /** The name of the theme */
6 name: string
7 /** The theme's appearance. Either `light` or `dark`. */
8 appearance: ThemeAppearance
9 /** The author of the theme
10 *
11 * Ideally formatted as `Full Name <email>`
12 *
13 * Example: `John Doe <john@doe.com>`
14 */
15 author: string
16 /** SPDX License string
17 *
18 * Example: `MIT`
19 */
20 license_type?: string | ThemeLicenseType
21 license_url?: string
22 license_file: string
23 theme_url?: string
24}
25
26export type ThemeFamilyMeta = Pick<
27 ThemeMeta,
28 "name" | "author" | "license_type" | "license_url"
29>
30
31export interface ThemeConfigInputColors {
32 neutral: Scale<Color>
33 red: Scale<Color>
34 orange: Scale<Color>
35 yellow: Scale<Color>
36 green: Scale<Color>
37 cyan: Scale<Color>
38 blue: Scale<Color>
39 violet: Scale<Color>
40 magenta: Scale<Color>
41}
42
43export type ThemeConfigInputColorsKeys = keyof ThemeConfigInputColors
44
45/** Allow any part of a syntax highlight style to be overriden by the theme
46 *
47 * Example:
48 * ```ts
49 * override: {
50 * syntax: {
51 * boolean: {
52 * underline: true,
53 * },
54 * },
55 * }
56 * ```
57 */
58export type ThemeConfigInputSyntax = Partial<Syntax>
59
60interface ThemeConfigOverrides {
61 syntax: ThemeConfigInputSyntax
62}
63
64type ThemeConfigProperties = ThemeMeta & {
65 input_color: ThemeConfigInputColors
66 override: ThemeConfigOverrides
67}
68
69export type ThemeConfig = {
70 [K in keyof ThemeConfigProperties]: ThemeConfigProperties[K]
71}
72
73export enum ThemeAppearance {
74 Light = "light",
75 Dark = "dark",
76}
77
78export enum ThemeLicenseType {
79 MIT = "MIT",
80 Apache2 = "Apache License 2.0",
81}