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>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All flavor names of Catppuccin
|
|
|
|
*/
|
|
|
|
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-01-02 20:31:41 +00:00
|
|
|
/**
|
|
|
|
* All color names of Catppuccin
|
|
|
|
*/
|
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
|
|
|
/**
|
|
|
|
* Generic to map type T to all Catppuccin color names
|
|
|
|
*/
|
|
|
|
export type Colors<T> = Record<ColorName, T>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A flavor of Catppuccin
|
|
|
|
*/
|
|
|
|
export type CatppuccinFlavor = Readonly<{
|
|
|
|
/**
|
|
|
|
* Name of the flavor
|
|
|
|
*/
|
|
|
|
name: string;
|
|
|
|
|
2024-05-17 20:56:11 +00:00
|
|
|
/**
|
|
|
|
* Emoji associated with the flavor. Requires Unicode 13.0 (2020) or later to render
|
|
|
|
*/
|
|
|
|
emoji: string;
|
|
|
|
|
2024-02-12 21:03:48 +00:00
|
|
|
/**
|
|
|
|
* Order of the flavor in the palette spec
|
|
|
|
*/
|
|
|
|
order: number;
|
|
|
|
|
2023-12-28 10:43:11 +00:00
|
|
|
/**
|
|
|
|
* Whether the flavor is a dark theme
|
|
|
|
*/
|
|
|
|
dark: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An object containing all the colors of the flavor
|
|
|
|
*/
|
|
|
|
colors: CatppuccinColors;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A typed Object.entries iterable of the colors of the flavor
|
|
|
|
*/
|
|
|
|
colorEntries: Entries<CatppuccinColors>;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All colors of Catppuccin
|
|
|
|
*/
|
|
|
|
export type CatppuccinColors = Readonly<Colors<ColorFormat>>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All flavors of Catppuccin
|
|
|
|
*/
|
|
|
|
export type CatppuccinFlavors = Flavors<CatppuccinFlavor>;
|
|
|
|
|
|
|
|
export type Flavors<T> = {
|
|
|
|
/**
|
|
|
|
* Light variant
|
|
|
|
*/
|
|
|
|
latte: T;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Low-saturation, low-contrast dark variant
|
|
|
|
*/
|
|
|
|
frappe: T;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mid-saturation, mid-contrast dark variant
|
|
|
|
*/
|
|
|
|
macchiato: T;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* High-saturation, High-contrast dark variant
|
|
|
|
*/
|
|
|
|
mocha: T;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type ColorFormat = Readonly<{
|
2024-02-12 21:03:48 +00:00
|
|
|
/**
|
|
|
|
* Name of the color
|
|
|
|
*/
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Order of the color in the palette spec
|
|
|
|
*/
|
|
|
|
order: number;
|
|
|
|
|
2023-12-28 10:43:11 +00:00
|
|
|
/**
|
|
|
|
* String-formatted hex value
|
|
|
|
* @example "#babbf1"
|
|
|
|
*/
|
|
|
|
hex: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the color is intended to be used as an accent color.
|
|
|
|
*/
|
|
|
|
accent: boolean;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All flavors of Catppuccin
|
|
|
|
*/
|
2024-03-25 22:17:04 +00:00
|
|
|
export const flavors: CatppuccinFlavors = entriesFromObject(definitions)
|
2023-12-28 10:43:11 +00:00
|
|
|
.reduce((acc, [flavorName, flavor]) => {
|
|
|
|
acc[flavorName] = {
|
|
|
|
...flavor,
|
|
|
|
colorEntries: entriesFromObject(flavor.colors),
|
|
|
|
};
|
|
|
|
return acc;
|
|
|
|
}, {} as CatppuccinFlavors);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A typed `Object.entries()` iterable of all Catppuccin flavors
|
|
|
|
*/
|
2024-03-25 22:17:04 +00:00
|
|
|
export const flavorEntries: Entries<CatppuccinFlavors> = entriesFromObject(
|
|
|
|
flavors,
|
|
|
|
);
|