ui: three silent library defects the agents' reports surfaced

Each of these was reported by an agent working around it rather than patched in
one file, which is why all three are fixed once, for every call site.

Button accepted an `href` and dropped it.  Mantine renders an anchor only when
it also gets `component='a'`; Semantic spelled that `as='a'`.  So a migrated
call site that kept just the href produced something that looks like a download
link and navigates nowhere -- silently, with no warning.  Button and IconButton
now infer the anchor from the href.

The media filter ran twice on nested media.  A `.media` wrapper filters its
subtree as one unit -- the audio player needs that, because its control glyphs
are SVG and the element-type rule does not reach them -- but the poster image
inside also matched that rule.  Two passes of a luminance-to-red matrix is not
one: the second takes 0.2126 of an already-red pixel, so the poster came out
markedly darker than everything around it.  Leaf media inside a filtered
wrapper is now left alone.

Progress had no indeterminate state.  Semantic's `indicating` animated a stripe
when the size was unknown; without it an upload that has not reported yet sits
at 0% and reads as stalled -- and `aria-valuenow="0"` tells a screen reader the
same wrong thing.  It now animates, reports no value, and falls back to a
static fill under prefers-reduced-motion.

Also: night and amber now override an inline `--label-color`.  A call site may
legitimately need many distinguishable colours -- the Flasher's chip badges use
a twelve-colour palette no four tokens can express -- but on a night-adapted
screen a green or blue chip badge defeats the entire mode.  The labels lose
their distinctness there, which is the right trade.
This commit is contained in:
Roland 2026-07-30 13:15:03 -06:00
parent d981b2506b
commit 4b7a195220
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
7 changed files with 136 additions and 5 deletions

View file

@ -152,6 +152,30 @@ describe('Button', () => {
expect(screen.getByRole('button', {name: 'New'})).toHaveAttribute('data-size', 'sm');
});
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');
});
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');
});
it('gives icon-only buttons an accessible name', () => {
renderUI(<IconButton icon='trash' label='Delete channel'/>);
@ -270,6 +294,17 @@ describe('Progress', () => {
expect(screen.getByRole('progressbar')).toHaveAttribute('aria-valuenow', '0');
});
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');
});
it('shows arbitrary label text instead of the percentage', () => {
renderUI(<Progress percent={40} label='2.1 GB / 5.3 GB'/>);