feat(ui): light mode and new theming system (#1468)

This commit is contained in:
Alex
2026-05-26 01:07:33 -04:00
committed by GitHub
parent 3211d7818a
commit 22ff6d8e90
131 changed files with 2816 additions and 3391 deletions
@@ -1,21 +1,34 @@
import {describe, expect, expectTypeOf, it} from 'vitest';
import {AppState} from './app-state.model';
import {
APP_THEME_OPTIONS,
AppearancePreference,
AppState,
AppTheme,
CustomPrimary,
DEFAULT_APP_THEME,
THEME_REGISTRY,
} from './app-state.model';
describe('app-state.model', () => {
it('supports partially specified visual state presets', () => {
it('supports partially specified visual theme state', () => {
const appState: AppState = {
preset: 'midnight',
primary: '#112233'
themePreference: DEFAULT_APP_THEME,
appearancePreference: 'system',
};
expect(appState.preset).toBe('midnight');
expect(appState.surface).toBeUndefined();
expect(appState.themePreference).toBe(DEFAULT_APP_THEME);
expect(appState.appearancePreference).toBe('system');
});
it('keeps each field optional and string-based', () => {
expectTypeOf<AppState['preset']>().toEqualTypeOf<string | undefined>();
expectTypeOf<AppState['primary']>().toEqualTypeOf<string | undefined>();
expectTypeOf<AppState['surface']>().toEqualTypeOf<string | undefined>();
it('keeps each field optional and constrained to supported values', () => {
expectTypeOf<AppState['themePreference']>().toEqualTypeOf<AppTheme | undefined>();
expectTypeOf<AppState['appearancePreference']>().toEqualTypeOf<AppearancePreference | undefined>();
expectTypeOf<AppState['customPrimary']>().toEqualTypeOf<CustomPrimary | undefined>();
});
it('derives theme options from the registry', () => {
expect(APP_THEME_OPTIONS).toBe(THEME_REGISTRY);
expect(APP_THEME_OPTIONS.some(option => option.name === DEFAULT_APP_THEME)).toBe(true);
});
});
@@ -1,5 +1,18 @@
import type {AppTheme, CustomPrimary} from './theme-registry';
export type AppearancePreference = 'light' | 'dark' | 'system';
export {
APP_THEME_OPTIONS,
CUSTOM_PRIMARY_OPTIONS,
DEFAULT_APP_THEME,
DEFAULT_CUSTOM_PRIMARY,
THEME_REGISTRY,
} from './theme-registry';
export type {AppTheme, CustomPrimary} from './theme-registry';
export interface AppState {
preset?: string;
primary?: string;
surface?: string;
themePreference?: AppTheme;
appearancePreference?: AppearancePreference;
customPrimary?: CustomPrimary;
}
@@ -0,0 +1,29 @@
export const THEME_REGISTRY = [
{name: 'grimmory', labelKey: 'layout.theme.options.grimmory'},
{name: 'cobalt', labelKey: 'layout.theme.options.cobalt'},
{name: 'ember', labelKey: 'layout.theme.options.ember'},
{name: 'crimson', labelKey: 'layout.theme.options.crimson'},
{name: 'rose', labelKey: 'layout.theme.options.rose'},
{name: 'forest', labelKey: 'layout.theme.options.forest'},
{name: 'meadow', labelKey: 'layout.theme.options.meadow'},
{name: 'teal', labelKey: 'layout.theme.options.teal'},
{name: 'lagoon', labelKey: 'layout.theme.options.lagoon'},
{name: 'violet', labelKey: 'layout.theme.options.violet'},
{name: 'fuchsia', labelKey: 'layout.theme.options.fuchsia'},
{name: 'slate', labelKey: 'layout.theme.options.slate'},
{name: 'custom', labelKey: 'layout.theme.options.custom'},
] as const;
export type AppTheme = (typeof THEME_REGISTRY)[number]['name'];
export const DEFAULT_APP_THEME: AppTheme = 'grimmory';
export const APP_THEME_OPTIONS = THEME_REGISTRY;
export const CUSTOM_PRIMARY_OPTIONS = [
'red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal',
'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose',
] as const;
export type CustomPrimary = (typeof CUSTOM_PRIMARY_OPTIONS)[number];
export const DEFAULT_CUSTOM_PRIMARY: CustomPrimary = 'orange';