frontend: remove the stylix overlay and add hyperhive and Catppuccin light and dark themes
This commit is contained in:
parent
989d1d578c
commit
91e2d26133
1 changed files with 486 additions and 413 deletions
54
frontend/packages/shared/src/settings/themes.ts
Normal file
54
frontend/packages/shared/src/settings/themes.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
// The themes a user can pick, apart from how they are applied. The palettes are
|
||||
// in `../colors.css`, one `:root[data-theme="<id>"]` block per id here; a new
|
||||
// theme is one entry here and one palette there. Each theme is light or dark.
|
||||
// `auto` is not a theme: it leaves `data-theme` off, and the OS preference
|
||||
// picks hyperhive light or hyperhive dark.
|
||||
|
||||
export type ThemeScheme = "light" | "dark";
|
||||
|
||||
export interface ThemeDef {
|
||||
id: string;
|
||||
label: string;
|
||||
scheme: ThemeScheme;
|
||||
}
|
||||
|
||||
export const THEMES: readonly ThemeDef[] = [
|
||||
{ id: "hyperhive-light", label: "hyperhive light", scheme: "light" },
|
||||
{ id: "hyperhive-dark", label: "hyperhive dark", scheme: "dark" },
|
||||
{
|
||||
id: "catppuccin-latte-mauve",
|
||||
label: "catppuccin latte mauve",
|
||||
scheme: "light",
|
||||
},
|
||||
{
|
||||
id: "catppuccin-mocha-mauve",
|
||||
label: "catppuccin mocha mauve",
|
||||
scheme: "dark",
|
||||
},
|
||||
{
|
||||
id: "catppuccin-mocha-mara",
|
||||
label: "catppuccin mocha mara",
|
||||
scheme: "dark",
|
||||
},
|
||||
];
|
||||
|
||||
/** The stored choice that follows the OS preference. */
|
||||
export const AUTO_THEME = "auto";
|
||||
|
||||
/** What a page uses until the user has picked. */
|
||||
export const DEFAULT_THEME = "hyperhive-dark";
|
||||
|
||||
/**
|
||||
* The choice a stored value stands for. The values from before themes existed
|
||||
* map to their successors (`system` to `auto`, `light` and `dark` to the
|
||||
* hyperhive themes); anything unknown is `fallback`.
|
||||
*/
|
||||
export function themeChoice(
|
||||
stored: unknown,
|
||||
fallback: string = DEFAULT_THEME,
|
||||
): string {
|
||||
if (stored === AUTO_THEME || stored === "system") return AUTO_THEME;
|
||||
if (stored === "light") return "hyperhive-light";
|
||||
if (stored === "dark") return "hyperhive-dark";
|
||||
return THEMES.some((t) => t.id === stored) ? (stored as string) : fallback;
|
||||
}
|
||||
Loading…
Reference in a new issue