mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 21:59:58 -05:00
ui: theme picker in Settings, and ship the component gallery
The gallery at /theme-sample is now a normal route rather than a development one, and Settings links to it, so a user can see what a theme actually looks like before committing to it. Every new component belongs in the gallery: it is how the design gets reviewed, and how a component that only looks wrong in one of the four themes gets caught. Settings gains a Theme section with the new ThemePicker, which explains what each theme is for - notably that night mode filters videos, documents and maps to red as well, not just the interface. Theme names and picker options move to themes/names.ts so the component library can read them without importing components/Theme.tsx, which still pulls in Semantic UI. Theme.tsx re-exports them, so existing call sites are unchanged. The navigation bar's compact picker now reads the same list, so the two cannot drift apart. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1bf8ea3da8
commit
ea50ee2f16
10 changed files with 290 additions and 52 deletions
|
|
@ -97,28 +97,39 @@ import {
|
|||
import {MantineProvider} from "@mantine/core";
|
||||
import {Notifications} from "@mantine/notifications";
|
||||
import {cssVariablesResolver, mantineTheme} from "../themes/mantine";
|
||||
import {
|
||||
amberTheme,
|
||||
darkTheme,
|
||||
defaultTheme,
|
||||
explicitOnlyThemes,
|
||||
isDarkTheme,
|
||||
isThemeName,
|
||||
lightTheme,
|
||||
nightTheme,
|
||||
systemTheme,
|
||||
themeChoices,
|
||||
themeNames,
|
||||
themeSessionKey,
|
||||
} from "../themes/names";
|
||||
import {ColorToSemanticHexColor} from "./Vars";
|
||||
import _ from "lodash";
|
||||
import {ThemeContextValue, ThemeName, SavedThemeName} from "../types/theme";
|
||||
|
||||
export const darkTheme = 'dark';
|
||||
export const lightTheme = 'light';
|
||||
export const nightTheme = 'night';
|
||||
export const amberTheme = 'amber';
|
||||
export const defaultTheme = lightTheme;
|
||||
export const systemTheme = 'system';
|
||||
export const themeSessionKey = 'color-scheme';
|
||||
|
||||
// Every theme a user can apply, in the order the theme picker offers them.
|
||||
export const themeNames: ThemeName[] = [lightTheme, darkTheme, nightTheme, amberTheme];
|
||||
// Themes built on a dark background. Semantic components are `inverted` in these.
|
||||
const darkThemes: ThemeName[] = [darkTheme, nightTheme, amberTheme];
|
||||
// Themes a user must choose deliberately; `prefers-color-scheme` never picks them.
|
||||
const explicitOnlyThemes: ThemeName[] = [nightTheme, amberTheme];
|
||||
|
||||
export const isDarkTheme = (theme: ThemeName): boolean => darkThemes.includes(theme);
|
||||
|
||||
const isThemeName = (value: unknown): value is ThemeName => themeNames.includes(value as ThemeName);
|
||||
// Theme names and picker choices live in themes/names so the component library can use
|
||||
// them without importing this module (which still pulls in Semantic UI). Re-exported
|
||||
// here because most call sites already import them from Theme.
|
||||
export {
|
||||
amberTheme,
|
||||
darkTheme,
|
||||
defaultTheme,
|
||||
isDarkTheme,
|
||||
lightTheme,
|
||||
nightTheme,
|
||||
systemTheme,
|
||||
themeChoices,
|
||||
themeNames,
|
||||
themeSessionKey,
|
||||
};
|
||||
|
||||
/** Resolve the saved preference to the theme that should be applied right now. */
|
||||
export const resolveTheme = (saved: SavedThemeName): ThemeName => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue