mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 07:56:18 -05:00
ui: progress bars get room for their label, and keep their band inside
Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fc0958369b
commit
5df38916f1
3 changed files with 220 additions and 7 deletions
|
|
@ -376,6 +376,55 @@ export function ThemeSamplePage() {
|
|||
</Panel>
|
||||
</Section>
|
||||
|
||||
<Section label='Progress'>
|
||||
<Panel>
|
||||
{/*
|
||||
The label sits on BOTH halves of the bar, so every one of these is really a
|
||||
contrast test: the text has to read over the fill and over the track, in all
|
||||
four themes. That is why light brightens the fill rather than using the raw
|
||||
token, and why night and amber drop it to --muted instead of a hue.
|
||||
*/}
|
||||
<div style={{maxWidth: 460}}>
|
||||
<Progress percent={0}/>
|
||||
<Progress percent={8}/>
|
||||
<Progress percent={37}/>
|
||||
<Progress percent={62}/>
|
||||
<Progress percent={94}/>
|
||||
<Progress percent={100}/>
|
||||
</div>
|
||||
|
||||
<Header as='h5'>Its own label instead of the percentage</Header>
|
||||
<div style={{maxWidth: 460}}>
|
||||
<Progress percent={41} label='2.1 GB / 5.3 GB'/>
|
||||
<Progress percent={73} label='CPU Usage (16 cores)'/>
|
||||
<Progress percent={12} label='nbd0 read 4.2 MBps'/>
|
||||
</div>
|
||||
|
||||
<Header as='h5'>No label at all, and unknown size</Header>
|
||||
<div style={{maxWidth: 460}}>
|
||||
<Progress percent={55} showPercent={false}/>
|
||||
{/* Indeterminate: a band sliding inside the bar, for work whose size is
|
||||
not known yet. It must stay within the track -- it used to slide out
|
||||
past both edges, because nothing clipped it. */}
|
||||
<Progress indeterminate label='Uploading…'/>
|
||||
<Progress indeterminate showPercent={false}/>
|
||||
</div>
|
||||
|
||||
<Header as='h5'>Carrying a meaning</Header>
|
||||
<div style={{maxWidth: 460}}>
|
||||
<Progress percent={64} color='info' label='Downloading'/>
|
||||
<Progress percent={100} color='success' label='Complete'/>
|
||||
<Progress percent={80} color='warning' label='Disk 80% full'/>
|
||||
<Progress percent={100} color='danger' label='Error: HTTP 403'/>
|
||||
</div>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginTop: 14, marginBottom: 0}}>
|
||||
A bar is 22px so its label has room; at 16px the text filled the bar edge to
|
||||
edge. Check the mid-range ones — 37% and 62% are where the label crosses the
|
||||
boundary between fill and track, which is the case that has to work.
|
||||
</p>
|
||||
</Panel>
|
||||
</Section>
|
||||
|
||||
<Section label='Messages'>
|
||||
<div style={{display: 'flex', flexDirection: 'column', gap: 10}}>
|
||||
<Message kind='info' title='Refresh started'>
|
||||
|
|
@ -683,9 +732,6 @@ export function ThemeSamplePage() {
|
|||
<Row>
|
||||
<Button role='cancel' icon='eye' onClick={() => setModalOpen(true)}>Open a modal</Button>
|
||||
</Row>
|
||||
<div style={{marginTop: 12, maxWidth: 320}}>
|
||||
<Progress indeterminate label='Uploading…'/>
|
||||
</div>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0, marginTop: 10}}>
|
||||
Semantic's compound shape is kept — Modal.Header, Modal.Content,
|
||||
Modal.Actions — so the 34 call sites written against it migrate by import.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue