mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-19 14:36:22 -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
|
|
@ -975,14 +975,37 @@ html .mantine-Notification-closeButton:hover {
|
|||
|
||||
/* --------------------------------------------------------------- Progress */
|
||||
|
||||
/*
|
||||
* Tall enough for the label inside it. At 16px a 14px line box left half a pixel of air
|
||||
* above and below the text, which on the Status page is 44 bars of cramped 11px bold --
|
||||
* legible only if you already knew what it said.
|
||||
*
|
||||
* `overflow: hidden` is what keeps the indeterminate band inside the bar. Without it the
|
||||
* band slides from `margin-left: -35%` to `100%` in full view, so the animation ran from
|
||||
* outside the left edge to outside the right one, painting over whatever sat beside it.
|
||||
*/
|
||||
.wrolpi-progress {
|
||||
position: relative;
|
||||
height: 16px;
|
||||
height: 22px;
|
||||
min-width: 120px;
|
||||
overflow: hidden;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bars stacked directly on top of each other need a gap; bars that a container already
|
||||
* spaces do not. On the Status page the CPU and RAM bars are bare siblings in a Panel and
|
||||
* were touching, while the drive-bandwidth bars each sit alone in a Grid column and get
|
||||
* their spacing from the Grid.
|
||||
*
|
||||
* `* +` distinguishes those two cases by itself: it fires only when a bar actually follows
|
||||
* something, so an only-child bar in a column is untouched.
|
||||
*/
|
||||
* + .wrolpi-progress {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.wrolpi-progress-fill {
|
||||
height: 100%;
|
||||
background: var(--progress-color, var(--blue));
|
||||
|
|
@ -1029,15 +1052,29 @@ html .mantine-Notification-closeButton:hover {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
/* 12px rather than 11: these labels carry units and device names, not just a number. */
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
font-variant-numeric: tabular-nums;
|
||||
/* A long label must not push the bar wider than the column it was given. */
|
||||
padding: 0 6px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/*
|
||||
* The percent text sits on both the filled and empty halves of the bar, so the
|
||||
* fill has to stay light enough in light mode for dark text to read over it.
|
||||
*
|
||||
* MEASURED, and only light actually clears it. The label against the fill is
|
||||
* 5.49:1 in light (the brightness filter below 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-15:1
|
||||
* everywhere. Reaching AA over the fill needs the label drawn twice, clipped to
|
||||
* the fill boundary, so each half gets its own colour -- and in night not even
|
||||
* that would do it, since `--text` is only ~4:1 against pure black and the fill
|
||||
* is lighter than black by definition. Left as it is, deliberately, rather than
|
||||
* asserted at a threshold chosen to pass.
|
||||
*/
|
||||
html[data-theme="light"] .wrolpi-progress {
|
||||
background: var(--panel);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue