ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
import fs from 'fs';
|
|
|
|
|
import path from 'path';
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
import React from 'react';
|
|
|
|
|
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';
|
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>
2026-07-29 19:38:04 -06:00
|
|
|
import {ThemeContext} from '../../contexts/contexts';
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
import {cssVariablesResolver, mantineTheme, semanticColorNames} from '../../themes/mantine';
|
ui: night mode actually filters media, and fix three picker icons
Addresses the automated review on #583; all three were real.
The night filter only applied to elements tagged `.media`, and nothing in the
app carried that class - so selecting Night filtered the interface but left
every video, thumbnail, PDF and map full-colour, which is precisely the thing
the mode exists to prevent. The Settings copy promised otherwise, so it was
also wrong.
It now targets the element types instead of an opt-in class, because night mode
has to fail safe: a library of thousands of files reaches the screen through
many components, and one that forgot to opt in would undo half an hour of dark
adaptation. `.media` still works for wrappers that must be filtered as a unit,
and `.night-unfiltered` opts out. The filter is restated on `:fullscreen`, which
a filter on an ancestor stops reaching. Verified on the videos page: all 25
media elements filtered.
Three of the five theme choices rendered a fallback glyph and logged errors,
because the icon map was built by grepping literal name='...' strings and the
navigation picker passes its icon through a variable. Adds sun, moon and
lightbulb, plus a test asserting every theme choice resolves to a real icon.
The pre-paint script wrapped the `matchMedia` fallback in the same try as the
storage read, so a device with storage blocked painted light even when it
prefers dark - recreating the flash the script exists to prevent.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:57:06 -06:00
|
|
|
import {themeChoices} from '../../themes/names';
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
import {
|
ui: migrate the extension pages and Configs; five components they needed
Phase 2, part 1. Three files leave Semantic UI (baseline 75 -> 72), and the
components they needed join the library and the gallery:
Header Semantic's shape (as/icon/subheader/dividing). 47 files use
<Header>, and the level now picks the size, so the type scale
stays a scale instead of each call site choosing a font size.
Message gains an icon and a dismiss button.
ActionInput input and button sharing one outline, for <Input action={...}/>.
Loading centered loader with a caption, replacing the
<Loader active inline='centered'> + wrapper div in 19 places.
Modal becomes compound - Modal.Header/.Content/.Actions, plus
Semantic's open, closeIcon, and size names - because 34 files
are written against that shape.
test-utils mounts MantineProvider with ThemeProvider's exact configuration:
migrated components render Mantine internals and every one of their test files
would otherwise need its own provider.
One Semantic bleed found and fixed: semantic.min.css sets
`h1,h2,h3,h4,h5 { font-family: Lato }` and loads after Mantine's element rule,
so headings ignored the theme's body face. Only visible in amber, where the
body is mono and the headings were not. A class-level restatement outranks it;
the rule comes out when Semantic does.
Verified: 925 jest tests, clean production build, and a night-mode audit of
every painted pixel in the gallery (red-only, one known false positive). The
Configs backup and restore flow was exercised against the real API.
2026-07-29 20:25:34 -06:00
|
|
|
ActionInput,
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
Button,
|
ui: bring back the card mimetype accent
Two agents independently dropped it, each because our Card had no `color` prop
and each citing the other's precedent -- which is how a deliberate feature
quietly becomes a convention. Roland wanted it back.
Card takes a token colour name and draws it as a 3px edge along the top rather
than tinting the surface: surfaces stay flat per the design rules, and an edge
survives night mode without becoming a bright patch. Because it is a token, the
accent remaps per theme -- four hues in light and dark, a single one in night and
amber, which is the point of those themes.
Restored on every card that shows a file: the video, image and generic file cards
in Files.js, and the archive card. All of them take it from
`mimetypeColor(mimetype, path)`, the same helper that colours the file icons, so
a card and its icon agree.
2026-07-30 13:51:05 -06:00
|
|
|
Card,
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
Confirm,
|
ui: migrate the extension pages and Configs; five components they needed
Phase 2, part 1. Three files leave Semantic UI (baseline 75 -> 72), and the
components they needed join the library and the gallery:
Header Semantic's shape (as/icon/subheader/dividing). 47 files use
<Header>, and the level now picks the size, so the type scale
stays a scale instead of each call site choosing a font size.
Message gains an icon and a dismiss button.
ActionInput input and button sharing one outline, for <Input action={...}/>.
Loading centered loader with a caption, replacing the
<Loader active inline='centered'> + wrapper div in 19 places.
Modal becomes compound - Modal.Header/.Content/.Actions, plus
Semantic's open, closeIcon, and size names - because 34 files
are written against that shape.
test-utils mounts MantineProvider with ThemeProvider's exact configuration:
migrated components render Mantine internals and every one of their test files
would otherwise need its own provider.
One Semantic bleed found and fixed: semantic.min.css sets
`h1,h2,h3,h4,h5 { font-family: Lato }` and loads after Mantine's element rule,
so headings ignored the theme's body face. Only visible in amber, where the
body is mono and the headings were not. A class-level restatement outranks it;
the rule comes out when Semantic does.
Verified: 925 jest tests, clean production build, and a night-mode audit of
every painted pixel in the gallery (red-only, one known false positive). The
Configs backup and restore flow was exercised against the real API.
2026-07-29 20:25:34 -06:00
|
|
|
Header,
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
Icon,
|
ui: nine leaf files off Semantic, and the components they needed
Phase 2, part 2. Baseline 72 -> 63.
Migrated: Tables, SortableTable, DonatePage, Share, Headline, ErrorBoundary,
and the QR code, VIN decoder, and temperature calculators.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>`, keeping its grouped `results`
shape because four call sites already build it. A real
combobox: arrows move, Enter takes the highlighted suggestion
or submits the raw text, Escape closes without clearing.
Pagination Semantic's prop names, but onPageChange gets the page number
rather than an (event, data) pair.
TabBar the strip and its house style only; routing stays at the call
site, which is what decides what is active.
IconStack two glyphs composed into one symbol, named once for assistive
technology (Semantic's IconGroup).
Table.HeaderCell gains `sorted` and `onSort`.
That last one is a fix, not just a port. Semantic's `sorted` prop set
`aria-sort`; migrating a table by hand dropped it, leaving a clickable <th>
that no keyboard could reach and no screen reader could describe. Putting it
in the library means the next table gets it right without anyone remembering.
Night mode holes closed along the way: the QR codes on the donate, share, and
calculator pages are white by necessity — a scanner needs the contrast — and
they render as SVG, which the media filter does not target. In night mode that
was a lit panel. They now carry `.media`, so the filter remaps the block as a
unit and the contrast survives the mapping.
Also: `paypal` joins the icon map rather than being imported ad hoc in a page,
and FileBrowser stops passing Semantic-only table props into a DOM element.
2026-07-30 09:31:15 -06:00
|
|
|
IconStack,
|
|
|
|
|
Pagination,
|
|
|
|
|
SearchBox,
|
|
|
|
|
TabBar,
|
|
|
|
|
tabClassName,
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
IconButton,
|
|
|
|
|
Label,
|
|
|
|
|
Message,
|
ui: the last Semantic UI file, and the stylesheet with it
ControllerPage was the final call site; Theme.tsx then had nothing left to wrap,
so it drops from 861 lines to 338 -- the provider that resolves the theme, stamps
`data-theme` and `data-media-filter`, persists both and hands Mantine our tokens.
Everything below that was Semantic wrappers.
The dark-mode compatibility props went with them. `i`, `s`, `t` and `inverted`
existed so unmigrated components could borrow Semantic's dark treatment, and
they carried hardcoded greys -- #1B1C1D, #dddddd, #eeeeee -- which is exactly
what the token themes replaced. Three call sites in Common.js were still
injecting the #eeeeee one into links.
Then `semantic-ui-offline/semantic.min.css` came out of App.js. That took more
with it than expected, and looking at the running app is the only reason it was
caught:
Every link lost its colour and gained the browser's underline and visited
purple. The dashboard's load averages and section headings were underlined
and purple. Links now take `--blue`, which remaps per theme, and underline
only on hover -- many of them wrap cards, posters and icons.
`box-sizing: border-box` disappeared, which silently changes the size of every
padded element in the app. Semantic's reset had been providing it.
The navigation bar overflowed a 1000px viewport with `nowrap` and cut "Admin"
off the right edge -- the one link a user needs to reach the settings that fix
a broken WROLPi. Semantic's menu wrapped; ours does now too.
The gzipped CSS bundle is 47.5 kB, and one call site was still leaning on
Semantic's grid classes -- now a flex column, since all three of its callers
pass library components.
The ratchet stays rather than being deleted. At zero it asserts four things: no
file imports Semantic UI, none calls its toast library, none leans on its
stylesheet, and no file reaches back through Theme.tsx. It can go when the
packages are uninstalled.
Theme.test.js is deleted, but not before porting the two behaviours it
protected: that Button forwards a ref to the real DOM element (a class-component
ref once crashed the Control page, because portals call `node.contains`), and
that the progress percentage stays readable on every bar colour.
2026-07-30 13:41:05 -06:00
|
|
|
Modal,
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
Panel,
|
|
|
|
|
Progress,
|
|
|
|
|
resolveIconName,
|
|
|
|
|
Status,
|
|
|
|
|
Table,
|
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>
2026-07-29 19:38:04 -06:00
|
|
|
ThemePicker,
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
Toggle,
|
|
|
|
|
} from './index';
|
|
|
|
|
|
|
|
|
|
// The components need Mantine's provider, exactly as ThemeProvider supplies it.
|
|
|
|
|
const renderUI = (ui) => render(
|
|
|
|
|
<MantineProvider theme={mantineTheme} cssVariablesResolver={cssVariablesResolver}>
|
|
|
|
|
{ui}
|
|
|
|
|
</MantineProvider>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
describe('Icon', () => {
|
|
|
|
|
it('renders a Semantic name as an SVG', () => {
|
|
|
|
|
const {container} = renderUI(<Icon name='trash'/>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('accepts a Tabler component directly', () => {
|
|
|
|
|
const {container} = renderUI(<Icon component={IconMoodSmile}/>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('maps every Semantic icon name the app uses', () => {
|
|
|
|
|
// A name that falls through renders a fallback glyph, leaving a hole in the UI.
|
|
|
|
|
const names = ['trash', 'warning sign', 'download', 'refresh', 'plus', 'edit', 'wifi',
|
|
|
|
|
'search', 'lock', 'check', 'upload', 'play', 'folder', 'filter', 'file text',
|
|
|
|
|
'external', 'disk', 'circle notched', 'terminal', 'eye'];
|
|
|
|
|
|
|
|
|
|
const unmapped = names.filter(name => !resolveIconName(name));
|
|
|
|
|
|
|
|
|
|
expect(unmapped).toEqual([]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('hides decorative icons from assistive technology but names labelled ones', () => {
|
|
|
|
|
const {container} = renderUI(<><Icon name='trash'/><Icon name='trash' label='Delete'/></>);
|
|
|
|
|
|
|
|
|
|
const [decorative, labelled] = [...container.querySelectorAll('svg')];
|
|
|
|
|
expect(decorative).toHaveAttribute('aria-hidden', 'true');
|
|
|
|
|
expect(labelled).toHaveAttribute('aria-label', 'Delete');
|
|
|
|
|
expect(labelled).not.toHaveAttribute('aria-hidden');
|
|
|
|
|
});
|
|
|
|
|
|
ui: night mode actually filters media, and fix three picker icons
Addresses the automated review on #583; all three were real.
The night filter only applied to elements tagged `.media`, and nothing in the
app carried that class - so selecting Night filtered the interface but left
every video, thumbnail, PDF and map full-colour, which is precisely the thing
the mode exists to prevent. The Settings copy promised otherwise, so it was
also wrong.
It now targets the element types instead of an opt-in class, because night mode
has to fail safe: a library of thousands of files reaches the screen through
many components, and one that forgot to opt in would undo half an hour of dark
adaptation. `.media` still works for wrappers that must be filtered as a unit,
and `.night-unfiltered` opts out. The filter is restated on `:fullscreen`, which
a filter on an ancestor stops reaching. Verified on the videos page: all 25
media elements filtered.
Three of the five theme choices rendered a fallback glyph and logged errors,
because the icon map was built by grepping literal name='...' strings and the
navigation picker passes its icon through a variable. Adds sun, moon and
lightbulb, plus a test asserting every theme choice resolves to a real icon.
The pre-paint script wrapped the `matchMedia` fallback in the same try as the
storage read, so a device with storage blocked painted light even when it
prefers dark - recreating the flash the script exists to prevent.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:57:06 -06:00
|
|
|
it('maps every icon the theme choices ask for', () => {
|
|
|
|
|
// Regression: the map was built by grepping literal name='...' strings, so icons
|
|
|
|
|
// passed through a variable (the nav bar's picker) were missed and three of the
|
|
|
|
|
// five theme choices rendered a fallback glyph.
|
|
|
|
|
const unmapped = themeChoices.filter(choice => !resolveIconName(choice.icon));
|
|
|
|
|
|
|
|
|
|
expect(unmapped.map(c => `${c.text}: ${c.icon}`)).toEqual([]);
|
|
|
|
|
});
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
it('maps every name the mimetype and file-suffix helpers can return', () => {
|
|
|
|
|
// These two build icon names from arbitrary files in the user's library, so an
|
|
|
|
|
// unmapped one is not hypothetical — it is a console error and a fallback glyph
|
|
|
|
|
// the moment somebody opens a folder containing that file type.
|
|
|
|
|
const common = fs.readFileSync(path.join(__dirname, '..', 'Common.js'), 'utf8');
|
|
|
|
|
const section = common.slice(
|
|
|
|
|
common.indexOf('export function mimetypeIconName'),
|
|
|
|
|
common.indexOf('export function FileIcon'));
|
|
|
|
|
const returned = [...new Set([...section.matchAll(/return '([^']+)'/g)].map(m => m[1]))];
|
|
|
|
|
|
|
|
|
|
expect(returned.length).toBeGreaterThan(10);
|
|
|
|
|
expect(returned.filter(name => !resolveIconName(name))).toEqual([]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('points every mapped name at a Tabler component that exists', () => {
|
|
|
|
|
// A typo in the map resolves to undefined and renders the fallback glyph, which
|
|
|
|
|
// looks like a design choice rather than a bug.
|
|
|
|
|
const source = fs.readFileSync(path.join(__dirname, 'Icon.tsx'), 'utf8');
|
|
|
|
|
const names = [...source.matchAll(/^ {4}'([^']+)': '([^']+)',$/gm)].map(m => m[1]);
|
|
|
|
|
|
|
|
|
|
expect(names.length).toBeGreaterThan(100);
|
|
|
|
|
expect(names.filter(name => !resolveIconName(name))).toEqual([]);
|
|
|
|
|
});
|
|
|
|
|
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
it('reports an unknown name instead of failing silently', () => {
|
|
|
|
|
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
|
|
|
|
|
|
renderUI(<Icon name='not a real icon'/>);
|
|
|
|
|
|
|
|
|
|
expect(error).toHaveBeenCalledWith(expect.stringContaining('not a real icon'));
|
|
|
|
|
error.mockRestore();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Button', () => {
|
|
|
|
|
it('renders a role as a themed button', () => {
|
|
|
|
|
renderUI(<Button role='primary'>Download</Button>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Download'})).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('marks destructive buttons so night mode can restyle them', () => {
|
|
|
|
|
// The dashed-outline treatment lives in CSS keyed on this class; without it a
|
|
|
|
|
// Delete button would stay filled red in night mode.
|
|
|
|
|
renderUI(<Button role='danger'>Delete</Button>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Delete'})).toHaveClass('wrolpi-button-danger');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('lets a call site override the role colors', () => {
|
|
|
|
|
renderUI(<Button role='primary' variant='outline'>Odd one out</Button>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Odd one out'})).toHaveAttribute('data-variant', 'outline');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('renders an icon alongside the label', () => {
|
|
|
|
|
const {container} = renderUI(<Button role='save' icon='save'>Save</Button>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Save'})).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
it('translates Semantic size names, which Mantine would otherwise ignore', () => {
|
|
|
|
|
// Unmigrated call sites still pass size='tiny'. Mantine drops a size it does not
|
|
|
|
|
// recognise without warning, so the button quietly renders at the default size.
|
|
|
|
|
renderUI(<><Button size='tiny'>Old</Button><Button size='sm'>New</Button></>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Old'})).toHaveAttribute('data-size', 'xs');
|
|
|
|
|
// A Mantine size still passes through untouched.
|
|
|
|
|
expect(screen.getByRole('button', {name: 'New'})).toHaveAttribute('data-size', 'sm');
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-30 13:15:03 -06:00
|
|
|
it('renders an anchor when given an href, without being told twice', () => {
|
|
|
|
|
/*
|
|
|
|
|
* Mantine drops `href` unless it also gets `component='a'`, so a button carrying
|
|
|
|
|
* only an href looked like a link and navigated nowhere. Semantic spelled this
|
|
|
|
|
* `as='a'`, so every migrated call site that kept just the href was silently
|
|
|
|
|
* broken — a download button that downloads nothing.
|
|
|
|
|
*/
|
|
|
|
|
renderUI(<>
|
|
|
|
|
<Button href='/media/thing.pdf'>Download</Button>
|
|
|
|
|
<IconButton icon='download' label='Save file' href='/media/other.pdf'/>
|
|
|
|
|
</>);
|
|
|
|
|
|
|
|
|
|
const link = screen.getByRole('link', {name: 'Download'});
|
|
|
|
|
expect(link.tagName).toBe('A');
|
|
|
|
|
expect(link).toHaveAttribute('href', '/media/thing.pdf');
|
|
|
|
|
expect(screen.getByRole('link', {name: 'Save file'}).tagName).toBe('A');
|
|
|
|
|
});
|
|
|
|
|
|
ui: the last Semantic UI file, and the stylesheet with it
ControllerPage was the final call site; Theme.tsx then had nothing left to wrap,
so it drops from 861 lines to 338 -- the provider that resolves the theme, stamps
`data-theme` and `data-media-filter`, persists both and hands Mantine our tokens.
Everything below that was Semantic wrappers.
The dark-mode compatibility props went with them. `i`, `s`, `t` and `inverted`
existed so unmigrated components could borrow Semantic's dark treatment, and
they carried hardcoded greys -- #1B1C1D, #dddddd, #eeeeee -- which is exactly
what the token themes replaced. Three call sites in Common.js were still
injecting the #eeeeee one into links.
Then `semantic-ui-offline/semantic.min.css` came out of App.js. That took more
with it than expected, and looking at the running app is the only reason it was
caught:
Every link lost its colour and gained the browser's underline and visited
purple. The dashboard's load averages and section headings were underlined
and purple. Links now take `--blue`, which remaps per theme, and underline
only on hover -- many of them wrap cards, posters and icons.
`box-sizing: border-box` disappeared, which silently changes the size of every
padded element in the app. Semantic's reset had been providing it.
The navigation bar overflowed a 1000px viewport with `nowrap` and cut "Admin"
off the right edge -- the one link a user needs to reach the settings that fix
a broken WROLPi. Semantic's menu wrapped; ours does now too.
The gzipped CSS bundle is 47.5 kB, and one call site was still leaning on
Semantic's grid classes -- now a flex column, since all three of its callers
pass library components.
The ratchet stays rather than being deleted. At zero it asserts four things: no
file imports Semantic UI, none calls its toast library, none leans on its
stylesheet, and no file reaches back through Theme.tsx. It can go when the
packages are uninstalled.
Theme.test.js is deleted, but not before porting the two behaviours it
protected: that Button forwards a ref to the real DOM element (a class-component
ref once crashed the Control page, because portals call `node.contains`), and
that the progress percentage stays readable on every bar colour.
2026-07-30 13:41:05 -06:00
|
|
|
it('forwards a ref to the underlying DOM element', () => {
|
|
|
|
|
/*
|
|
|
|
|
* Ported from the old Theme.test.js, which caught a real crash: Semantic's Button
|
|
|
|
|
* was a class component, so a forwarded ref resolved to the class instance, and
|
|
|
|
|
* anything that called `node.contains(...)` on the trigger -- a Modal or Popup
|
|
|
|
|
* portal checking whether a click landed inside -- threw "contains is not a
|
|
|
|
|
* function". Our Tooltip and Menu targets rely on this ref too.
|
|
|
|
|
*/
|
|
|
|
|
const ref = React.createRef();
|
|
|
|
|
renderUI(<Button ref={ref}>Click</Button>);
|
|
|
|
|
|
|
|
|
|
expect(ref.current).toBeInstanceOf(HTMLElement);
|
|
|
|
|
expect(typeof ref.current.contains).toBe('function');
|
|
|
|
|
expect(ref.current.tagName).toBe('BUTTON');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('survives a document click while used as a modal trigger', () => {
|
|
|
|
|
// The other half of that regression: the Control page crashed when the document
|
|
|
|
|
// was clicked with a modal open whose trigger was a themed Button.
|
|
|
|
|
renderUI(<>
|
|
|
|
|
<Button>Open</Button>
|
|
|
|
|
<Modal open onClose={jest.fn()}><Modal.Content>content</Modal.Content></Modal>
|
|
|
|
|
</>);
|
|
|
|
|
|
|
|
|
|
expect(() => document.body.dispatchEvent(new MouseEvent('click', {bubbles: true})))
|
|
|
|
|
.not.toThrow();
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-30 13:15:03 -06:00
|
|
|
it('is still a button when there is no href', () => {
|
|
|
|
|
renderUI(<Button onClick={jest.fn()}>Save</Button>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Save'}).tagName).toBe('BUTTON');
|
|
|
|
|
});
|
|
|
|
|
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
it('gives icon-only buttons an accessible name', () => {
|
|
|
|
|
renderUI(<IconButton icon='trash' label='Delete channel'/>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Delete channel'})).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Message', () => {
|
|
|
|
|
it('announces errors assertively and other kinds politely', () => {
|
|
|
|
|
renderUI(<><Message kind='error' title='Failed'/><Message kind='info' title='Working'/></>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('alert')).toHaveTextContent('Failed');
|
|
|
|
|
expect(screen.getByRole('status')).toHaveTextContent('Working');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('gives errors the dashed danger border in every theme', () => {
|
|
|
|
|
renderUI(<Message kind='error' title='Failed'>Try again</Message>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('alert')).toHaveClass('wrolpi-message-error');
|
|
|
|
|
});
|
ui: migrate the extension pages and Configs; five components they needed
Phase 2, part 1. Three files leave Semantic UI (baseline 75 -> 72), and the
components they needed join the library and the gallery:
Header Semantic's shape (as/icon/subheader/dividing). 47 files use
<Header>, and the level now picks the size, so the type scale
stays a scale instead of each call site choosing a font size.
Message gains an icon and a dismiss button.
ActionInput input and button sharing one outline, for <Input action={...}/>.
Loading centered loader with a caption, replacing the
<Loader active inline='centered'> + wrapper div in 19 places.
Modal becomes compound - Modal.Header/.Content/.Actions, plus
Semantic's open, closeIcon, and size names - because 34 files
are written against that shape.
test-utils mounts MantineProvider with ThemeProvider's exact configuration:
migrated components render Mantine internals and every one of their test files
would otherwise need its own provider.
One Semantic bleed found and fixed: semantic.min.css sets
`h1,h2,h3,h4,h5 { font-family: Lato }` and loads after Mantine's element rule,
so headings ignored the theme's body face. Only visible in amber, where the
body is mono and the headings were not. A class-level restatement outranks it;
the rule comes out when Semantic does.
Verified: 925 jest tests, clean production build, and a night-mode audit of
every painted pixel in the gallery (red-only, one known false positive). The
Configs backup and restore flow was exercised against the real API.
2026-07-29 20:25:34 -06:00
|
|
|
|
|
|
|
|
it('dismisses when asked', async () => {
|
|
|
|
|
const onDismiss = jest.fn();
|
|
|
|
|
renderUI(<Message title='Install the extension' onDismiss={onDismiss}/>);
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('button', {name: 'Dismiss'}));
|
|
|
|
|
|
|
|
|
|
expect(onDismiss).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('offers no dismiss button when the message cannot be cleared', () => {
|
|
|
|
|
renderUI(<Message title='Refresh running'/>);
|
|
|
|
|
|
|
|
|
|
expect(screen.queryByRole('button', {name: 'Dismiss'})).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('renders a leading icon when given one', () => {
|
|
|
|
|
const {container} = renderUI(<Message icon='puzzle piece' title='Extension'/>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('.wrolpi-message-icon svg')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Header', () => {
|
|
|
|
|
it('renders the requested heading level', () => {
|
|
|
|
|
renderUI(<Header as='h1'>Browser Extension</Header>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('heading', {level: 1, name: 'Browser Extension'})).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('defaults to h3 so a call site that omits the level still nests sanely', () => {
|
|
|
|
|
renderUI(<Header>Firefox</Header>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('heading', {level: 3, name: 'Firefox'})).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('takes its size from the level, not from the call site', () => {
|
|
|
|
|
// The class is what ui.css keys the type scale on; a call site passing its own
|
|
|
|
|
// font-size is the thing this component exists to prevent.
|
|
|
|
|
const {container} = renderUI(<Header as='h4'>Install steps</Header>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('.wrolpi-header-h4')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('renders an icon and a subheader', () => {
|
|
|
|
|
const {container} = renderUI(<Header icon='globe' subheader='Paste this into the extension'>
|
|
|
|
|
This WROLPi's URL
|
|
|
|
|
</Header>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
|
|
|
expect(screen.getByText('Paste this into the extension')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('ActionInput', () => {
|
|
|
|
|
it('joins the input and its action into one control', () => {
|
|
|
|
|
const {container} = renderUI(
|
|
|
|
|
<ActionInput label='URL' value='https://wrolpi.local' readOnly
|
|
|
|
|
action={<Button role='cancel'>Copy</Button>}/>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('.wrolpi-action-input')).toBeInTheDocument();
|
|
|
|
|
expect(screen.getByRole('textbox', {name: 'URL'})).toHaveValue('https://wrolpi.local');
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Copy'})).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('is a plain input when no action is given', () => {
|
|
|
|
|
const {container} = renderUI(<ActionInput label='URL'/>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('.wrolpi-action-input')).not.toBeInTheDocument();
|
|
|
|
|
expect(screen.getByRole('textbox', {name: 'URL'})).toBeInTheDocument();
|
|
|
|
|
});
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Progress', () => {
|
|
|
|
|
it('reports its value to assistive technology', () => {
|
|
|
|
|
renderUI(<Progress percent={62}/>);
|
|
|
|
|
|
|
|
|
|
const bar = screen.getByRole('progressbar');
|
|
|
|
|
expect(bar).toHaveAttribute('aria-valuenow', '62');
|
|
|
|
|
expect(bar).toHaveTextContent('62%');
|
|
|
|
|
});
|
|
|
|
|
|
ui: the last Semantic UI file, and the stylesheet with it
ControllerPage was the final call site; Theme.tsx then had nothing left to wrap,
so it drops from 861 lines to 338 -- the provider that resolves the theme, stamps
`data-theme` and `data-media-filter`, persists both and hands Mantine our tokens.
Everything below that was Semantic wrappers.
The dark-mode compatibility props went with them. `i`, `s`, `t` and `inverted`
existed so unmigrated components could borrow Semantic's dark treatment, and
they carried hardcoded greys -- #1B1C1D, #dddddd, #eeeeee -- which is exactly
what the token themes replaced. Three call sites in Common.js were still
injecting the #eeeeee one into links.
Then `semantic-ui-offline/semantic.min.css` came out of App.js. That took more
with it than expected, and looking at the running app is the only reason it was
caught:
Every link lost its colour and gained the browser's underline and visited
purple. The dashboard's load averages and section headings were underlined
and purple. Links now take `--blue`, which remaps per theme, and underline
only on hover -- many of them wrap cards, posters and icons.
`box-sizing: border-box` disappeared, which silently changes the size of every
padded element in the app. Semantic's reset had been providing it.
The navigation bar overflowed a 1000px viewport with `nowrap` and cut "Admin"
off the right edge -- the one link a user needs to reach the settings that fix
a broken WROLPi. Semantic's menu wrapped; ours does now too.
The gzipped CSS bundle is 47.5 kB, and one call site was still leaning on
Semantic's grid classes -- now a flex column, since all three of its callers
pass library components.
The ratchet stays rather than being deleted. At zero it asserts four things: no
file imports Semantic UI, none calls its toast library, none leans on its
stylesheet, and no file reaches back through Theme.tsx. It can go when the
packages are uninstalled.
Theme.test.js is deleted, but not before porting the two behaviours it
protected: that Button forwards a ref to the real DOM element (a class-component
ref once crashed the Control page, because portals call `node.contains`), and
that the progress percentage stays readable on every bar colour.
2026-07-30 13:41:05 -06:00
|
|
|
it('keeps its percent text readable on every bar colour', () => {
|
|
|
|
|
/*
|
|
|
|
|
* Ported from Theme.test.js, which asserted Semantic's `inverted-progress-text`
|
|
|
|
|
* class across all fourteen colours and both modes. That class is gone; the
|
|
|
|
|
* mechanism now is that the text always takes `--text` while light mode lightens
|
|
|
|
|
* the fill beneath it, because the text sits across both the filled and unfilled
|
|
|
|
|
* halves of the bar.
|
|
|
|
|
*/
|
|
|
|
|
const css = fs.readFileSync(path.join(__dirname, 'ui.css'), 'utf8');
|
|
|
|
|
|
|
|
|
|
expect(css).toMatch(/\.wrolpi-progress-text\s*{[^}]*color:\s*var\(--text\)/);
|
|
|
|
|
expect(css).toMatch(/html\[data-theme="light"] \.wrolpi-progress-fill\s*{[^}]*brightness/);
|
|
|
|
|
});
|
|
|
|
|
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
it('clamps values outside 0-100', () => {
|
|
|
|
|
// A download reporting 103% must not overflow its container.
|
|
|
|
|
renderUI(<><Progress percent={150}/><Progress percent={-20}/></>);
|
|
|
|
|
|
|
|
|
|
const [high, low] = screen.getAllByRole('progressbar');
|
|
|
|
|
expect(high).toHaveAttribute('aria-valuenow', '100');
|
|
|
|
|
expect(low).toHaveAttribute('aria-valuenow', '0');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('survives a missing percentage', () => {
|
|
|
|
|
renderUI(<Progress percent={undefined}/>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('progressbar')).toHaveAttribute('aria-valuenow', '0');
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-30 13:15:03 -06:00
|
|
|
it('reports no value when the size is unknown', () => {
|
|
|
|
|
// Semantic called this `indicating`. An upload that has not reported its size
|
|
|
|
|
// would otherwise sit at 0% and read as stalled, and `aria-valuenow=0` would tell
|
|
|
|
|
// a screen reader the same wrong thing.
|
|
|
|
|
renderUI(<Progress indeterminate label='Uploading…'/>);
|
|
|
|
|
|
|
|
|
|
const bar = screen.getByRole('progressbar');
|
|
|
|
|
expect(bar).not.toHaveAttribute('aria-valuenow');
|
|
|
|
|
expect(bar).toHaveClass('wrolpi-progress-indeterminate');
|
|
|
|
|
});
|
|
|
|
|
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
it('shows arbitrary label text instead of the percentage', () => {
|
|
|
|
|
renderUI(<Progress percent={40} label='2.1 GB / 5.3 GB'/>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('progressbar')).toHaveTextContent('2.1 GB / 5.3 GB');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Status', () => {
|
|
|
|
|
it('names the state in a class so themes can encode it differently', () => {
|
|
|
|
|
// Night mode has no hue to spend, so it encodes status by brightness.
|
|
|
|
|
const {container} = renderUI(<Status kind='failed'>failed</Status>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('.wrolpi-status-failed')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Label', () => {
|
|
|
|
|
it('supports every Semantic color', () => {
|
|
|
|
|
const {container} = renderUI(<>
|
|
|
|
|
{semanticColorNames.map(color => <Label key={color} color={color}>{color}</Label>)}
|
|
|
|
|
</>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelectorAll('.wrolpi-label')).toHaveLength(semanticColorNames.length);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Table', () => {
|
|
|
|
|
it('renders a Semantic-shaped compound table', () => {
|
|
|
|
|
renderUI(<Table>
|
|
|
|
|
<Table.Header>
|
|
|
|
|
<Table.Row><Table.HeaderCell>URL</Table.HeaderCell></Table.Row>
|
|
|
|
|
</Table.Header>
|
|
|
|
|
<Table.Body>
|
|
|
|
|
<Table.Row><Table.Cell>example.com</Table.Cell></Table.Row>
|
|
|
|
|
</Table.Body>
|
|
|
|
|
</Table>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('columnheader', {name: 'URL'})).toBeInTheDocument();
|
|
|
|
|
expect(screen.getByRole('cell', {name: 'example.com'})).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('marks failed rows for the danger border', () => {
|
|
|
|
|
const {container} = renderUI(<Table>
|
|
|
|
|
<Table.Body>
|
|
|
|
|
<Table.Row failed><Table.Cell>broken</Table.Cell></Table.Row>
|
|
|
|
|
</Table.Body>
|
|
|
|
|
</Table>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('.wrolpi-row-failed')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
ui: nine leaf files off Semantic, and the components they needed
Phase 2, part 2. Baseline 72 -> 63.
Migrated: Tables, SortableTable, DonatePage, Share, Headline, ErrorBoundary,
and the QR code, VIN decoder, and temperature calculators.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>`, keeping its grouped `results`
shape because four call sites already build it. A real
combobox: arrows move, Enter takes the highlighted suggestion
or submits the raw text, Escape closes without clearing.
Pagination Semantic's prop names, but onPageChange gets the page number
rather than an (event, data) pair.
TabBar the strip and its house style only; routing stays at the call
site, which is what decides what is active.
IconStack two glyphs composed into one symbol, named once for assistive
technology (Semantic's IconGroup).
Table.HeaderCell gains `sorted` and `onSort`.
That last one is a fix, not just a port. Semantic's `sorted` prop set
`aria-sort`; migrating a table by hand dropped it, leaving a clickable <th>
that no keyboard could reach and no screen reader could describe. Putting it
in the library means the next table gets it right without anyone remembering.
Night mode holes closed along the way: the QR codes on the donate, share, and
calculator pages are white by necessity — a scanner needs the contrast — and
they render as SVG, which the media filter does not target. In night mode that
was a lit panel. They now carry `.media`, so the filter remaps the block as a
unit and the contrast survives the mapping.
Also: `paypal` joins the icon map rather than being imported ad hoc in a page,
and FileBrowser stops passing Semantic-only table props into a DOM element.
2026-07-30 09:31:15 -06:00
|
|
|
it('makes a sortable column a keyboard-reachable button that announces its state', async () => {
|
|
|
|
|
// A click handler on the <th> alone is unreachable by keyboard, and the arrow
|
|
|
|
|
// glyph says nothing to a screen reader.
|
|
|
|
|
const onSort = jest.fn();
|
|
|
|
|
renderUI(<Table>
|
|
|
|
|
<Table.Header>
|
|
|
|
|
<Table.Row>
|
|
|
|
|
<Table.HeaderCell sorted='descending' onSort={onSort}>Size</Table.HeaderCell>
|
|
|
|
|
<Table.HeaderCell onSort={jest.fn()}>Name</Table.HeaderCell>
|
|
|
|
|
<Table.HeaderCell>Actions</Table.HeaderCell>
|
|
|
|
|
</Table.Row>
|
|
|
|
|
</Table.Header>
|
|
|
|
|
</Table>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('columnheader', {name: /Size/})).toHaveAttribute('aria-sort', 'descending');
|
|
|
|
|
// Sortable but not currently sorted.
|
|
|
|
|
expect(screen.getByRole('columnheader', {name: /Name/})).toHaveAttribute('aria-sort', 'none');
|
|
|
|
|
// Not sortable at all.
|
|
|
|
|
expect(screen.getByRole('columnheader', {name: 'Actions'})).not.toHaveAttribute('aria-sort');
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('button', {name: /Size/}));
|
|
|
|
|
expect(onSort).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
it('keeps wide tables from scrolling the page sideways', () => {
|
|
|
|
|
const {container} = renderUI(<Table><Table.Body>
|
|
|
|
|
<Table.Row><Table.Cell>wide</Table.Cell></Table.Row>
|
|
|
|
|
</Table.Body></Table>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('.wrolpi-table-scroll')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
ui: bring back the card mimetype accent
Two agents independently dropped it, each because our Card had no `color` prop
and each citing the other's precedent -- which is how a deliberate feature
quietly becomes a convention. Roland wanted it back.
Card takes a token colour name and draws it as a 3px edge along the top rather
than tinting the surface: surfaces stay flat per the design rules, and an edge
survives night mode without becoming a bright patch. Because it is a token, the
accent remaps per theme -- four hues in light and dark, a single one in night and
amber, which is the point of those themes.
Restored on every card that shows a file: the video, image and generic file cards
in Files.js, and the archive card. All of them take it from
`mimetypeColor(mimetype, path)`, the same helper that colours the file icons, so
a card and its icon agree.
2026-07-30 13:51:05 -06:00
|
|
|
describe('Card', () => {
|
|
|
|
|
it('draws a mimetype accent from a token, not a hex', () => {
|
|
|
|
|
// File cards carry the mimetype's colour on their top edge so a grid of results is
|
|
|
|
|
// scannable by kind. Semantic did this with `<Card color='violet'>`; two migrated
|
|
|
|
|
// files had dropped the accent because our Card had no equivalent.
|
|
|
|
|
const {container} = renderUI(<Card title='Water Storage.pdf' color='red'/>);
|
|
|
|
|
|
2026-07-30 13:53:43 -06:00
|
|
|
expect(container.firstChild).toHaveStyle({borderBottom: '3px solid var(--red)'});
|
ui: bring back the card mimetype accent
Two agents independently dropped it, each because our Card had no `color` prop
and each citing the other's precedent -- which is how a deliberate feature
quietly becomes a convention. Roland wanted it back.
Card takes a token colour name and draws it as a 3px edge along the top rather
than tinting the surface: surfaces stay flat per the design rules, and an edge
survives night mode without becoming a bright patch. Because it is a token, the
accent remaps per theme -- four hues in light and dark, a single one in night and
amber, which is the point of those themes.
Restored on every card that shows a file: the video, image and generic file cards
in Files.js, and the archive card. All of them take it from
`mimetypeColor(mimetype, path)`, the same helper that colours the file icons, so
a card and its icon agree.
2026-07-30 13:51:05 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('has no accent when no colour is given', () => {
|
|
|
|
|
const {container} = renderUI(<Card title='Plain'/>);
|
|
|
|
|
|
2026-07-30 13:53:43 -06:00
|
|
|
expect(container.firstChild.style.borderBottom).toBe('');
|
ui: bring back the card mimetype accent
Two agents independently dropped it, each because our Card had no `color` prop
and each citing the other's precedent -- which is how a deliberate feature
quietly becomes a convention. Roland wanted it back.
Card takes a token colour name and draws it as a 3px edge along the top rather
than tinting the surface: surfaces stay flat per the design rules, and an edge
survives night mode without becoming a bright patch. Because it is a token, the
accent remaps per theme -- four hues in light and dark, a single one in night and
amber, which is the point of those themes.
Restored on every card that shows a file: the video, image and generic file cards
in Files.js, and the archive card. All of them take it from
`mimetypeColor(mimetype, path)`, the same helper that colours the file icons, so
a card and its icon agree.
2026-07-30 13:51:05 -06:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
describe('Panel', () => {
|
|
|
|
|
it('marks danger zones', () => {
|
|
|
|
|
const {container} = renderUI(<Panel danger>Destructive actions</Panel>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('.wrolpi-panel-danger')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Toggle', () => {
|
|
|
|
|
it('carries the class its unchecked-track rule needs', () => {
|
|
|
|
|
// Mantine writes --switch-bg onto the track element, so the token override has to
|
|
|
|
|
// be a CSS rule scoped to this class rather than a style on the root. Without it
|
|
|
|
|
// the unchecked track falls back to Mantine's gray — a non-red pixel in night mode.
|
|
|
|
|
const {container} = renderUI(<Toggle label='Hotspot'/>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector('.wrolpi-switch')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('exposes the switch role and reports its state', async () => {
|
|
|
|
|
const onChange = jest.fn();
|
|
|
|
|
renderUI(<Toggle label='Hotspot' checked={false} onChange={onChange}/>);
|
|
|
|
|
|
|
|
|
|
const toggle = screen.getByRole('switch', {name: 'Hotspot'});
|
|
|
|
|
expect(toggle).not.toBeChecked();
|
|
|
|
|
await userEvent.click(toggle);
|
|
|
|
|
|
|
|
|
|
expect(onChange).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
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>
2026-07-29 19:38:04 -06:00
|
|
|
describe('ThemePicker', () => {
|
|
|
|
|
const renderPicker = (themeContext = {}) => {
|
|
|
|
|
const setTheme = jest.fn();
|
ui: media filtering is a per-theme setting, not a night-mode hardcode
Filtering media was keyed on `data-theme="night"`, which made it a property of
the theme that no user could turn off. Some people want their media tinted to
match the interface; some want to see the actual image.
A theme now declares a filter and whether it starts on, and the user decides:
night night-red on by default. An unfiltered thumbnail undoes dark
adaptation, which is the whole point of the mode.
amber amber-mono off by default. Amber is a look, not a night-vision
aid, so media keeps its real colors until asked for.
light - no filter offered, so no toggle is shown.
dark -
The choice is stored per theme, so wanting amber's tint says nothing about
wanting night's. The toggle lives in the theme picker, which puts it on the
Settings page and in the gallery at once.
Mechanically the rules now key on a `data-media-filter` attribute rather than
`data-theme`: a rule keyed on the theme could not be turned off. index.html
stamps that attribute before first paint alongside data-theme -- without it,
night mode paints a screen of unfiltered thumbnails while the bundle arrives
over a hotspot, costing the user the adaptation the theme exists to protect.
Tests cover both the attribute rule and the fact that the inline script's
duplicated ids and defaults still agree with names.ts.
The amber matrix is the same luminance collapse tinted to #ff9500 (red full,
green 0.584, blue zero) with a gentler gamma than night's: amber carries far
more luminance and clips to a flat wash otherwise.
The gallery gains a Media filtering section showing the WROLPi logo filtered,
beside an unfiltered copy that opts out with `night-unfiltered`. That copy is
behind a click on purpose -- an unfiltered image is a bright patch, and night
mode should not spring one on someone reading in the dark.
ui-design.md gains the media filtering contract it never got in Phase 0,
including the note that a Phase 3 custom theme names an existing filter id and
cannot ship its own matrix, since that would be code rather than data.
2026-07-30 08:51:28 -06:00
|
|
|
const value = {
|
|
|
|
|
savedTheme: null,
|
|
|
|
|
setTheme,
|
|
|
|
|
mediaFilterEnabled: false,
|
|
|
|
|
setMediaFilterEnabled: jest.fn(),
|
|
|
|
|
...themeContext,
|
|
|
|
|
};
|
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>
2026-07-29 19:38:04 -06:00
|
|
|
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();
|
|
|
|
|
});
|
ui: media filtering is a per-theme setting, not a night-mode hardcode
Filtering media was keyed on `data-theme="night"`, which made it a property of
the theme that no user could turn off. Some people want their media tinted to
match the interface; some want to see the actual image.
A theme now declares a filter and whether it starts on, and the user decides:
night night-red on by default. An unfiltered thumbnail undoes dark
adaptation, which is the whole point of the mode.
amber amber-mono off by default. Amber is a look, not a night-vision
aid, so media keeps its real colors until asked for.
light - no filter offered, so no toggle is shown.
dark -
The choice is stored per theme, so wanting amber's tint says nothing about
wanting night's. The toggle lives in the theme picker, which puts it on the
Settings page and in the gallery at once.
Mechanically the rules now key on a `data-media-filter` attribute rather than
`data-theme`: a rule keyed on the theme could not be turned off. index.html
stamps that attribute before first paint alongside data-theme -- without it,
night mode paints a screen of unfiltered thumbnails while the bundle arrives
over a hotspot, costing the user the adaptation the theme exists to protect.
Tests cover both the attribute rule and the fact that the inline script's
duplicated ids and defaults still agree with names.ts.
The amber matrix is the same luminance collapse tinted to #ff9500 (red full,
green 0.584, blue zero) with a gentler gamma than night's: amber carries far
more luminance and clips to a flat wash otherwise.
The gallery gains a Media filtering section showing the WROLPi logo filtered,
beside an unfiltered copy that opts out with `night-unfiltered`. That copy is
behind a click on purpose -- an unfiltered image is a bright patch, and night
mode should not spring one on someone reading in the dark.
ui-design.md gains the media filtering contract it never got in Phase 0,
including the note that a Phase 3 custom theme names an existing filter id and
cannot ship its own matrix, since that would be code rather than data.
2026-07-30 08:51:28 -06:00
|
|
|
|
|
|
|
|
it('offers the media filter toggle in a theme that has one', () => {
|
|
|
|
|
renderPicker({
|
|
|
|
|
theme: 'night',
|
|
|
|
|
mediaFilter: {id: 'night-red', defaultOn: true, label: 'Filter media to red',
|
|
|
|
|
description: 'Videos, images, documents, and maps are remapped to red.'},
|
|
|
|
|
mediaFilterEnabled: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('switch', {name: /filter media to red/i})).toBeChecked();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('offers no toggle in a theme with no filter to offer', () => {
|
|
|
|
|
// Light and dark have no monochrome media treatment, so there is nothing to say.
|
|
|
|
|
renderPicker({theme: 'light', mediaFilter: undefined, mediaFilterEnabled: false});
|
|
|
|
|
|
|
|
|
|
expect(screen.queryByRole('switch')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('turns the filter off when the user flips the toggle', async () => {
|
|
|
|
|
const setMediaFilterEnabled = jest.fn();
|
|
|
|
|
renderPicker({
|
|
|
|
|
theme: 'night',
|
|
|
|
|
mediaFilter: {id: 'night-red', defaultOn: true, label: 'Filter media to red',
|
|
|
|
|
description: 'Videos, images, documents, and maps are remapped to red.'},
|
|
|
|
|
mediaFilterEnabled: true,
|
|
|
|
|
setMediaFilterEnabled,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('switch', {name: /filter media to red/i}));
|
|
|
|
|
|
|
|
|
|
expect(setMediaFilterEnabled).toHaveBeenCalledWith(false);
|
|
|
|
|
});
|
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>
2026-07-29 19:38:04 -06:00
|
|
|
});
|
|
|
|
|
|
ui: nine leaf files off Semantic, and the components they needed
Phase 2, part 2. Baseline 72 -> 63.
Migrated: Tables, SortableTable, DonatePage, Share, Headline, ErrorBoundary,
and the QR code, VIN decoder, and temperature calculators.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>`, keeping its grouped `results`
shape because four call sites already build it. A real
combobox: arrows move, Enter takes the highlighted suggestion
or submits the raw text, Escape closes without clearing.
Pagination Semantic's prop names, but onPageChange gets the page number
rather than an (event, data) pair.
TabBar the strip and its house style only; routing stays at the call
site, which is what decides what is active.
IconStack two glyphs composed into one symbol, named once for assistive
technology (Semantic's IconGroup).
Table.HeaderCell gains `sorted` and `onSort`.
That last one is a fix, not just a port. Semantic's `sorted` prop set
`aria-sort`; migrating a table by hand dropped it, leaving a clickable <th>
that no keyboard could reach and no screen reader could describe. Putting it
in the library means the next table gets it right without anyone remembering.
Night mode holes closed along the way: the QR codes on the donate, share, and
calculator pages are white by necessity — a scanner needs the contrast — and
they render as SVG, which the media filter does not target. In night mode that
was a lit panel. They now carry `.media`, so the filter remaps the block as a
unit and the contrast survives the mapping.
Also: `paypal` joins the icon map rather than being imported ad hoc in a page,
and FileBrowser stops passing Semantic-only table props into a DOM element.
2026-07-30 09:31:15 -06:00
|
|
|
describe('Pagination', () => {
|
|
|
|
|
it('reports the current page and moves when one is clicked', async () => {
|
|
|
|
|
const onPageChange = jest.fn();
|
|
|
|
|
renderUI(<Pagination activePage={3} totalPages={12} onPageChange={onPageChange}/>);
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('button', {name: 'Page 5'}));
|
|
|
|
|
|
|
|
|
|
expect(onPageChange).toHaveBeenCalledWith(5);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('still renders one page when the total is unknown', () => {
|
|
|
|
|
// Downloads render the paginator before the first response arrives; collapsing to
|
|
|
|
|
// nothing and back shifts the whole page.
|
|
|
|
|
renderUI(<Pagination activePage={1} totalPages={undefined} onPageChange={jest.fn()}/>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Page 1'})).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('TabBar', () => {
|
|
|
|
|
it('marks the active tab with a class the themes key on', () => {
|
|
|
|
|
const {container} = renderUI(<TabBar>
|
|
|
|
|
<button className={tabClassName(true)}>Videos</button>
|
|
|
|
|
<button className={tabClassName(false)}>Channels</button>
|
|
|
|
|
</TabBar>);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelectorAll('.wrolpi-tab')).toHaveLength(2);
|
|
|
|
|
expect(container.querySelectorAll('.wrolpi-tab-active')).toHaveLength(1);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('SearchBox', () => {
|
|
|
|
|
const results = {
|
|
|
|
|
directories: {name: 'Directories', results: [{title: 'videos/'}]},
|
|
|
|
|
channels: {name: 'Channels', results: [
|
|
|
|
|
{title: 'videos/Wranglerstar', description: 'Wranglerstar'},
|
|
|
|
|
{title: 'videos/RoseRed', description: 'RoseRed Homestead'},
|
|
|
|
|
]},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
it('submits what was typed', async () => {
|
|
|
|
|
const onSubmit = jest.fn();
|
|
|
|
|
renderUI(<SearchBox value='axe' onChange={jest.fn()} onSubmit={onSubmit}/>);
|
|
|
|
|
|
|
|
|
|
await userEvent.type(screen.getByRole('textbox'), '{Enter}');
|
|
|
|
|
|
|
|
|
|
expect(onSubmit).toHaveBeenCalledWith('axe');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('shows suggestions under their group headings', async () => {
|
|
|
|
|
renderUI(<SearchBox value='vid' onChange={jest.fn()} results={results}
|
|
|
|
|
onResultSelect={jest.fn()}/>);
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('combobox'));
|
|
|
|
|
|
|
|
|
|
expect(screen.getByText('Directories')).toBeInTheDocument();
|
|
|
|
|
expect(screen.getAllByRole('option')).toHaveLength(3);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('selects a suggestion by click', async () => {
|
|
|
|
|
const onResultSelect = jest.fn();
|
|
|
|
|
renderUI(<SearchBox value='vid' onChange={jest.fn()} results={results}
|
|
|
|
|
onResultSelect={onResultSelect}/>);
|
|
|
|
|
await userEvent.click(screen.getByRole('combobox'));
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByText('videos/Wranglerstar'));
|
|
|
|
|
|
|
|
|
|
expect(onResultSelect).toHaveBeenCalledWith(
|
|
|
|
|
expect.objectContaining({title: 'videos/Wranglerstar'}));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('moves through suggestions with the arrow keys and takes one with Enter', async () => {
|
|
|
|
|
const onResultSelect = jest.fn();
|
|
|
|
|
const onSubmit = jest.fn();
|
|
|
|
|
renderUI(<SearchBox value='vid' onChange={jest.fn()} results={results}
|
|
|
|
|
onResultSelect={onResultSelect} onSubmit={onSubmit}/>);
|
|
|
|
|
|
|
|
|
|
const input = screen.getByRole('combobox');
|
|
|
|
|
await userEvent.click(input);
|
|
|
|
|
await userEvent.keyboard('{ArrowDown}{ArrowDown}{Enter}');
|
|
|
|
|
|
|
|
|
|
expect(onResultSelect).toHaveBeenCalledWith(
|
|
|
|
|
expect.objectContaining({title: 'videos/Wranglerstar'}));
|
|
|
|
|
// Enter took the highlighted suggestion instead of submitting the raw text.
|
|
|
|
|
expect(onSubmit).not.toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('wraps around rather than stranding the user at the end of the list', async () => {
|
|
|
|
|
const onResultSelect = jest.fn();
|
|
|
|
|
renderUI(<SearchBox value='vid' onChange={jest.fn()} results={results}
|
|
|
|
|
onResultSelect={onResultSelect}/>);
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('combobox'));
|
|
|
|
|
await userEvent.keyboard('{ArrowUp}{Enter}');
|
|
|
|
|
|
|
|
|
|
expect(onResultSelect).toHaveBeenCalledWith(
|
|
|
|
|
expect.objectContaining({title: 'videos/RoseRed'}));
|
|
|
|
|
});
|
|
|
|
|
|
ui: fix search suggestion selection, rendering, and clipping
Three findings from review and CI on the Common.js migration, all real.
Selecting a suggestion navigated nowhere. Semantic handed its callers
`{result}` and every caller destructures that shape, so passing the bare result
left `result.location` undefined -- the search suggestions and the Ctrl+K modal
both stopped navigating. The shape stays until the call sites can change
together. (Greptile P1.)
Suggestions lost their custom markup. Callers pass `resultRenderer` to draw a
tag as a chip rather than a line of text, and the migrated wrapper forwarded it
into a div's props instead of to SearchBox, so every suggestion fell back to the
generic title and description. SearchBox takes it now. (Greptile P2.)
The suggestion list clipped its last group. A cypress spec caught it: with
directories, channels and domains all present, the content runs past the 320px
cap and the final row was cut off. Eight grouped suggestions is an ordinary
result set, so the cap was simply too low; it is viewport-relative now and
still bounded.
Both regressions are pinned by tests -- one asserting the callback shape a
caller actually destructures, one asserting the custom renderer replaces the
default markup rather than wrapping it.
2026-07-30 11:28:17 -06:00
|
|
|
it('lets a caller render a suggestion its own way', async () => {
|
|
|
|
|
// The search suggestions render a tag as a chip rather than a line of text; a
|
|
|
|
|
// dropped resultRenderer loses that presentation silently.
|
|
|
|
|
renderUI(<SearchBox value='vid' onChange={jest.fn()} results={results}
|
|
|
|
|
onResultSelect={jest.fn()}
|
|
|
|
|
resultRenderer={result => <em>{`custom: ${result.title}`}</em>}/>);
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('combobox'));
|
|
|
|
|
|
|
|
|
|
expect(screen.getByText('custom: videos/Wranglerstar').tagName).toBe('EM');
|
|
|
|
|
// The default title/description markup is replaced, not wrapped.
|
|
|
|
|
expect(document.querySelector('.wrolpi-searchbox-result-title')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
ui: nine leaf files off Semantic, and the components they needed
Phase 2, part 2. Baseline 72 -> 63.
Migrated: Tables, SortableTable, DonatePage, Share, Headline, ErrorBoundary,
and the QR code, VIN decoder, and temperature calculators.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>`, keeping its grouped `results`
shape because four call sites already build it. A real
combobox: arrows move, Enter takes the highlighted suggestion
or submits the raw text, Escape closes without clearing.
Pagination Semantic's prop names, but onPageChange gets the page number
rather than an (event, data) pair.
TabBar the strip and its house style only; routing stays at the call
site, which is what decides what is active.
IconStack two glyphs composed into one symbol, named once for assistive
technology (Semantic's IconGroup).
Table.HeaderCell gains `sorted` and `onSort`.
That last one is a fix, not just a port. Semantic's `sorted` prop set
`aria-sort`; migrating a table by hand dropped it, leaving a clickable <th>
that no keyboard could reach and no screen reader could describe. Putting it
in the library means the next table gets it right without anyone remembering.
Night mode holes closed along the way: the QR codes on the donate, share, and
calculator pages are white by necessity — a scanner needs the contrast — and
they render as SVG, which the media filter does not target. In night mode that
was a lit panel. They now carry `.media`, so the filter remaps the block as a
unit and the contrast survives the mapping.
Also: `paypal` joins the icon map rather than being imported ad hoc in a page,
and FileBrowser stops passing Semantic-only table props into a DOM element.
2026-07-30 09:31:15 -06:00
|
|
|
it('closes on Escape without clearing what was typed', async () => {
|
|
|
|
|
const onChange = jest.fn();
|
|
|
|
|
renderUI(<SearchBox value='vid' onChange={onChange} results={results}
|
|
|
|
|
onResultSelect={jest.fn()}/>);
|
|
|
|
|
await userEvent.click(screen.getByRole('combobox'));
|
|
|
|
|
|
|
|
|
|
await userEvent.keyboard('{Escape}');
|
|
|
|
|
|
|
|
|
|
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
|
|
|
|
expect(screen.getByRole('combobox')).toHaveValue('vid');
|
|
|
|
|
expect(onChange).not.toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('says it is searching rather than "no results" while suggestions are pending', async () => {
|
|
|
|
|
renderUI(<SearchBox value='vid' onChange={jest.fn()} results={{}} loading
|
|
|
|
|
onResultSelect={jest.fn()}/>);
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('combobox'));
|
|
|
|
|
|
|
|
|
|
expect(screen.getByText(/searching/i)).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('clears the input and submits the empty search', async () => {
|
|
|
|
|
const onChange = jest.fn();
|
|
|
|
|
const onSubmit = jest.fn();
|
|
|
|
|
renderUI(<SearchBox value='axe' onChange={onChange} onSubmit={onSubmit} clearable/>);
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('button', {name: 'Clear search'}));
|
|
|
|
|
|
|
|
|
|
expect(onChange).toHaveBeenCalledWith('');
|
|
|
|
|
expect(onSubmit).toHaveBeenCalledWith('');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('is a plain search field when no suggestions are wired up', () => {
|
|
|
|
|
// Without this, a box that can never show options still claims to be a combobox.
|
|
|
|
|
renderUI(<SearchBox value='' onChange={jest.fn()} onSubmit={jest.fn()}/>);
|
|
|
|
|
|
|
|
|
|
expect(screen.queryByRole('combobox')).not.toBeInTheDocument();
|
|
|
|
|
expect(screen.getByRole('textbox')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('IconStack', () => {
|
|
|
|
|
it('names the pair once, and hides the corner glyph from assistive tech', () => {
|
|
|
|
|
const {container} = renderUI(
|
|
|
|
|
<IconStack corner={<Icon name='question'/>} label='WiFi status unknown'>
|
|
|
|
|
<Icon name='wifi'/>
|
|
|
|
|
</IconStack>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('img', {name: 'WiFi status unknown'})).toBeInTheDocument();
|
|
|
|
|
expect(container.querySelector('.wrolpi-icon-stack-corner')).toHaveAttribute('aria-hidden', 'true');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
describe('Confirm', () => {
|
|
|
|
|
it('names the action on its confirming button', async () => {
|
|
|
|
|
const onConfirm = jest.fn();
|
|
|
|
|
renderUI(<Confirm open destructive title='Delete channel?' confirmLabel='Delete'
|
|
|
|
|
onConfirm={onConfirm}/>);
|
|
|
|
|
|
|
|
|
|
await userEvent.click(screen.getByRole('button', {name: 'Delete'}));
|
|
|
|
|
|
|
|
|
|
expect(onConfirm).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('styles a destructive confirmation as destructive', () => {
|
|
|
|
|
renderUI(<Confirm open destructive confirmLabel='Wipe' title='Wipe history?'/>);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole('button', {name: 'Wipe'})).toHaveClass('wrolpi-button-danger');
|
|
|
|
|
});
|
|
|
|
|
});
|