2023-12-29 03:45:10 +00:00
|
|
|
import definitions from "./palette.json" with { type: "json" };
|
2023-12-28 10:43:11 +00:00
|
|
|
|
|
|
|
type Entries<T> = {
|
|
|
|
[K in keyof T]: [K, T[K]];
|
|
|
|
}[keyof T][];
|
|
|
|
|
|
|
|
const entriesFromObject = <T extends object>(obj: T): Entries<T> =>
|
|
|
|
Object.entries(obj) as Entries<T>;
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* All flavor names of Catppuccin.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
export type FlavorName = "latte" | "frappe" | "macchiato" | "mocha";
|
|
|
|
|
|
|
|
/**
|
2024-01-02 20:31:41 +00:00
|
|
|
* Accent colors of Catppuccin.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
2024-01-02 22:36:55 +00:00
|
|
|
export type AccentName =
|
2023-12-28 10:43:11 +00:00
|
|
|
| "rosewater"
|
|
|
|
| "flamingo"
|
|
|
|
| "pink"
|
|
|
|
| "mauve"
|
|
|
|
| "red"
|
|
|
|
| "maroon"
|
|
|
|
| "peach"
|
|
|
|
| "yellow"
|
|
|
|
| "green"
|
|
|
|
| "teal"
|
|
|
|
| "sky"
|
|
|
|
| "sapphire"
|
|
|
|
| "blue"
|
2024-01-02 20:31:41 +00:00
|
|
|
| "lavender";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Monochromatic colors of Catppuccin,
|
|
|
|
* from `text` to `crust`
|
|
|
|
*/
|
2024-01-02 22:36:55 +00:00
|
|
|
export type MonochromaticName =
|
2023-12-28 10:43:11 +00:00
|
|
|
| "text"
|
|
|
|
| "subtext1"
|
|
|
|
| "subtext0"
|
|
|
|
| "overlay2"
|
|
|
|
| "overlay1"
|
|
|
|
| "overlay0"
|
|
|
|
| "surface2"
|
|
|
|
| "surface1"
|
|
|
|
| "surface0"
|
|
|
|
| "base"
|
|
|
|
| "mantle"
|
|
|
|
| "crust";
|
|
|
|
|
2024-10-26 22:27:45 +00:00
|
|
|
type AnsiName =
|
|
|
|
| "black"
|
|
|
|
| "red"
|
|
|
|
| "green"
|
|
|
|
| "yellow"
|
|
|
|
| "blue"
|
|
|
|
| "magenta"
|
|
|
|
| "cyan"
|
|
|
|
| "white";
|
|
|
|
|
2024-01-02 20:31:41 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* All color names of Catppuccin.
|
2024-01-02 20:31:41 +00:00
|
|
|
*/
|
2024-01-02 22:36:55 +00:00
|
|
|
export type ColorName = AccentName | MonochromaticName;
|
2024-01-02 20:31:41 +00:00
|
|
|
|
2023-12-28 10:43:11 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Generic to map type T to all Catppuccin color names.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
export type Colors<T> = Record<ColorName, T>;
|
|
|
|
|
2024-10-26 22:27:45 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Generic to map type T to all ANSI color names.
|
2024-10-26 22:27:45 +00:00
|
|
|
*/
|
|
|
|
export type AnsiColors<T> = Record<AnsiName, T>;
|
|
|
|
|
2023-12-28 10:43:11 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* A flavor of Catppuccin.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
export type CatppuccinFlavor = Readonly<{
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Name of the flavor.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
name: string;
|
|
|
|
|
2024-05-17 20:56:11 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Emoji associated with the flavor. Requires Unicode 13.0 (2020) or later to render.
|
2024-05-17 20:56:11 +00:00
|
|
|
*/
|
|
|
|
emoji: string;
|
|
|
|
|
2024-02-12 21:03:48 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Order of the flavor in the palette spec.
|
2024-02-12 21:03:48 +00:00
|
|
|
*/
|
|
|
|
order: number;
|
|
|
|
|
2023-12-28 10:43:11 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Whether the flavor is a dark theme.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
dark: boolean;
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* An object containing all the colors of the flavor.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
colors: CatppuccinColors;
|
|
|
|
|
2024-10-26 22:27:45 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* An object containing all the ANSI color mappings of the flavor.
|
2024-10-26 22:27:45 +00:00
|
|
|
*/
|
|
|
|
ansiColors: CatppuccinAnsiColors;
|
|
|
|
|
2023-12-28 10:43:11 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* A typed Object.entries iterable of the colors of the flavor.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
colorEntries: Entries<CatppuccinColors>;
|
2024-10-26 22:27:45 +00:00
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* A typed Object.entries iterable of the ANSI colors of the flavor.
|
2024-10-26 22:27:45 +00:00
|
|
|
*/
|
|
|
|
ansiColorEntries: Entries<CatppuccinAnsiColors>;
|
2023-12-28 10:43:11 +00:00
|
|
|
}>;
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* All colors of Catppuccin.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
export type CatppuccinColors = Readonly<Colors<ColorFormat>>;
|
|
|
|
|
2024-10-26 22:27:45 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* All ANSI color mappings of Catppuccin.
|
2024-10-26 22:27:45 +00:00
|
|
|
*/
|
|
|
|
export type CatppuccinAnsiColors = Readonly<AnsiColors<AnsiColorGroups>>;
|
|
|
|
|
2023-12-28 10:43:11 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* All flavors of Catppuccin.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
export type CatppuccinFlavors = Flavors<CatppuccinFlavor>;
|
|
|
|
|
|
|
|
export type Flavors<T> = {
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Light variant.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
latte: T;
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Low-saturation, low-contrast dark variant.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
frappe: T;
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Mid-saturation, mid-contrast dark variant.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
macchiato: T;
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* High-saturation, High-contrast dark variant.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
|
|
|
mocha: T;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type ColorFormat = Readonly<{
|
2024-02-12 21:03:48 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Name of the color.
|
2024-02-12 21:03:48 +00:00
|
|
|
*/
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Order of the color in the palette spec.
|
2024-02-12 21:03:48 +00:00
|
|
|
*/
|
|
|
|
order: number;
|
|
|
|
|
2023-12-28 10:43:11 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* String-formatted hex value.
|
2023-12-28 10:43:11 +00:00
|
|
|
* @example "#babbf1"
|
|
|
|
*/
|
|
|
|
hex: string;
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Formatted rgb value.
|
2023-12-28 10:43:11 +00:00
|
|
|
* @example { r: 186, g: 187, b: 241}
|
|
|
|
*/
|
|
|
|
rgb: {
|
|
|
|
/**
|
|
|
|
* Red, 0-255
|
|
|
|
*/
|
|
|
|
r: number;
|
|
|
|
/**
|
|
|
|
* Green, 0-255
|
|
|
|
*/
|
|
|
|
g: number;
|
|
|
|
/**
|
|
|
|
* Blue, 0-255
|
|
|
|
*/
|
|
|
|
b: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* Formatted hsl value.
|
2023-12-28 10:43:11 +00:00
|
|
|
* @example { h: 238.9, s: 12.1, l: 83.5 }
|
|
|
|
*/
|
|
|
|
hsl: {
|
|
|
|
/**
|
|
|
|
* Hue, 0-360
|
|
|
|
*/
|
|
|
|
h: number;
|
|
|
|
/**
|
|
|
|
* Saturation, 0-100
|
|
|
|
*/
|
|
|
|
s: number;
|
|
|
|
/**
|
|
|
|
* Lightness, 0-100
|
|
|
|
*/
|
|
|
|
l: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the color is intended to be used as an accent color.
|
|
|
|
*/
|
|
|
|
accent: boolean;
|
|
|
|
}>;
|
|
|
|
|
2024-10-26 22:27:45 +00:00
|
|
|
export type AnsiColorGroups = Readonly<{
|
2024-11-01 23:06:34 +00:00
|
|
|
/**
|
|
|
|
* Name of the ANSI color.
|
|
|
|
*/
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Order of the ANSI color in the palette spec.
|
|
|
|
*/
|
|
|
|
order: number;
|
|
|
|
|
2024-10-26 22:27:45 +00:00
|
|
|
/**
|
|
|
|
* An object containing all the ANSI "normal" colors, which are the 8 standard colors from 0 to 7.
|
|
|
|
*/
|
|
|
|
normal: AnsiColorFormat;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An object containing all the ANSI "bright" colors, which are the 8 standard colors from 8 to 15.
|
|
|
|
*
|
|
|
|
* Note: These bright colors are not necessarily "brighter" than the normal colors, but rather more bold and saturated.
|
|
|
|
*/
|
|
|
|
bright: AnsiColorFormat;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
export type AnsiColorFormat = Readonly<{
|
2024-11-01 23:37:55 +00:00
|
|
|
/**
|
|
|
|
* Name of the ANSI group.
|
|
|
|
*/
|
|
|
|
name: string;
|
|
|
|
|
2024-10-26 22:27:45 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* String-formatted hex value.
|
2024-10-26 22:27:45 +00:00
|
|
|
* @example "#babbf1"
|
|
|
|
*/
|
|
|
|
hex: string;
|
|
|
|
|
2024-11-02 13:02:15 +00:00
|
|
|
/**
|
|
|
|
* Formatted rgb value.
|
|
|
|
* @example { r: 186, g: 187, b: 241}
|
|
|
|
*/
|
|
|
|
rgb: {
|
|
|
|
/**
|
|
|
|
* Red, 0-255
|
|
|
|
*/
|
|
|
|
r: number;
|
|
|
|
/**
|
|
|
|
* Green, 0-255
|
|
|
|
*/
|
|
|
|
g: number;
|
|
|
|
/**
|
|
|
|
* Blue, 0-255
|
|
|
|
*/
|
|
|
|
b: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Formatted hsl value.
|
|
|
|
* @example { h: 238.9, s: 12.1, l: 83.5 }
|
|
|
|
*/
|
|
|
|
hsl: {
|
|
|
|
/**
|
|
|
|
* Hue, 0-360
|
|
|
|
*/
|
|
|
|
h: number;
|
|
|
|
/**
|
|
|
|
* Saturation, 0-100
|
|
|
|
*/
|
|
|
|
s: number;
|
|
|
|
/**
|
|
|
|
* Lightness, 0-100
|
|
|
|
*/
|
|
|
|
l: number;
|
|
|
|
};
|
|
|
|
|
2024-10-26 22:27:45 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* The ANSI color code.
|
2024-10-26 22:27:45 +00:00
|
|
|
* @example 4
|
|
|
|
*/
|
|
|
|
code: number;
|
|
|
|
}>;
|
|
|
|
|
2024-09-20 18:15:25 +00:00
|
|
|
const { version: _, ...jsonFlavors } = definitions;
|
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* The version of the Catppuccin palette.
|
2024-09-20 18:15:25 +00:00
|
|
|
*/
|
|
|
|
export const version = definitions.version;
|
|
|
|
|
2023-12-28 10:43:11 +00:00
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* All flavors of Catppuccin.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
2024-09-20 18:15:25 +00:00
|
|
|
export const flavors: CatppuccinFlavors = entriesFromObject(
|
|
|
|
jsonFlavors,
|
|
|
|
).reduce((acc, [flavorName, flavor]) => {
|
|
|
|
acc[flavorName] = {
|
|
|
|
...flavor,
|
|
|
|
colorEntries: entriesFromObject(flavor.colors),
|
2024-10-26 22:27:45 +00:00
|
|
|
ansiColorEntries: entriesFromObject(flavor.ansiColors),
|
2024-09-20 18:15:25 +00:00
|
|
|
};
|
|
|
|
return acc;
|
|
|
|
}, {} as CatppuccinFlavors);
|
2023-12-28 10:43:11 +00:00
|
|
|
|
|
|
|
/**
|
2024-11-01 23:06:34 +00:00
|
|
|
* A typed `Object.entries()` iterable of all Catppuccin flavors.
|
2023-12-28 10:43:11 +00:00
|
|
|
*/
|
2024-03-25 22:17:04 +00:00
|
|
|
export const flavorEntries: Entries<CatppuccinFlavors> = entriesFromObject(
|
|
|
|
flavors,
|
|
|
|
);
|