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:
Roland 2026-07-29 19:38:04 -06:00
parent 1bf8ea3da8
commit ea50ee2f16
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
10 changed files with 290 additions and 52 deletions

View file

@ -0,0 +1,43 @@
import React, {useContext} from 'react';
import {ThemeContext} from '../../contexts/contexts';
import {systemTheme, themeChoices} from '../../themes/names';
import {Icon} from './Icon';
/*
* The theme picker.
*
* Used on the Settings page. The navigation bar has its own compact menu; both
* read their options from `themeChoices` so they cannot drift apart.
*/
export interface ThemePickerProps {
/** Show each theme's description under its name. */
withDescriptions?: boolean;
}
export function ThemePicker({withDescriptions = true}: ThemePickerProps) {
const {savedTheme, setTheme} = useContext(ThemeContext);
// A user who has never chosen is following the system preference.
const selected = savedTheme ?? systemTheme;
return <div role='radiogroup' aria-label='Theme' className='wrolpi-theme-picker'>
{themeChoices.map(choice => {
const active = choice.value === selected;
return <button
key={choice.value}
type='button'
role='radio'
aria-checked={active}
className={`wrolpi-theme-option${active ? ' wrolpi-theme-option-active' : ''}`}
onClick={() => setTheme(choice.value)}
>
<span className='wrolpi-theme-option-name'>
<Icon name={choice.icon}/>
{choice.text}
</span>
{withDescriptions &&
<span className='wrolpi-theme-option-description'>{choice.description}</span>}
</button>
})}
</div>
}