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 fb4c03d7a0
commit 95c089edc4
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
10 changed files with 290 additions and 52 deletions

View file

@ -3,6 +3,7 @@ import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import {MantineProvider} from '@mantine/core';
import {IconMoodSmile} from '@tabler/icons-react';
import {ThemeContext} from '../../contexts/contexts';
import {cssVariablesResolver, mantineTheme, semanticColorNames} from '../../themes/mantine';
import {
Button,
@ -16,6 +17,7 @@ import {
resolveIconName,
Status,
Table,
ThemePicker,
Toggle,
} from './index';
@ -233,6 +235,57 @@ describe('Toggle', () => {
});
});
describe('ThemePicker', () => {
const renderPicker = (themeContext = {}) => {
const setTheme = jest.fn();
const value = {savedTheme: null, setTheme, ...themeContext};
render(
<MantineProvider theme={mantineTheme} cssVariablesResolver={cssVariablesResolver}>
<ThemeContext.Provider value={value}><ThemePicker/></ThemeContext.Provider>
</MantineProvider>
);
return setTheme;
};
it('offers every theme plus following the system', () => {
renderPicker();
const options = screen.getAllByRole('radio').map(o => o.textContent);
['System', 'Light', 'Dark', 'Night', 'Amber'].forEach(name => {
expect(options.some(text => text.startsWith(name))).toBe(true);
});
});
it('marks the saved theme as selected', () => {
renderPicker({savedTheme: 'night'});
const night = screen.getAllByRole('radio').find(o => o.textContent.startsWith('Night'));
expect(night).toHaveAttribute('aria-checked', 'true');
});
it('treats a user who has never chosen as following the system', () => {
renderPicker({savedTheme: null});
const system = screen.getAllByRole('radio').find(o => o.textContent.startsWith('System'));
expect(system).toHaveAttribute('aria-checked', 'true');
});
it('applies the theme a user picks', async () => {
const setTheme = renderPicker();
await userEvent.click(screen.getAllByRole('radio').find(o => o.textContent.startsWith('Amber')));
expect(setTheme).toHaveBeenCalledWith('amber');
});
it('explains what night mode is for', () => {
// Users need to know it filters media too, not just the interface.
renderPicker();
expect(screen.getByText(/night vision/i)).toBeInTheDocument();
});
});
describe('Confirm', () => {
it('names the action on its confirming button', async () => {
const onConfirm = jest.fn();