mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 09:56:17 -05:00
ui: Statistic and StatisticGroup, and the four defects they had
These three exports had no test of their own. Statistic had already been
caught out once -- it relied on Semantic's `Statistic.Group` for its
spacing, so it broke silently when that was uninstalled -- and they are
on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages.
Four defects, each with a test that goes red without the fix:
* StatisticGroup ruled between columns only, with a `border-right` on
every cell but the last. `auto-fit` wraps, so the seven statistics on
the Docs page became four rows on a phone with no rule between them,
and the cell ending each earlier row drew its border straight onto the
group's outer one, making that edge 2px on the right and 1px on the
left. The hairlines are now a 1px grid gap filled by an outline on
each cell, which rules both axes however the tracks fall.
Ruling the gaps with a border-coloured background behind the grid --
which is where this went first -- has the same reach but paints every
track no cell landed in: an odd count left the last slot a solid grey
block. An outline is drawn only where a cell is. Both of these are
guarded, because the second was introduced while fixing the first.
* A statistic that renders nothing left a padded cell and a stray
hairline mid-row. FanRPMStatistic returns null on a device with no fan
connector, which is most of them, so this was the Status page's normal
appearance. The group cannot render a child to find out, so the cell
is still emitted and `:empty` takes it out of the grid -- which is why
the cells carry no inline style for that rule to have to outrank.
* Statistic destructured five props and dropped the rest. LoadStatistic
and the four Status wrappers all end in `{...props}`, so anything
passed through a wrapper vanished with no error anywhere.
* VideosStatistics passed `style={{margin: '2em'}}` to every statistic,
Semantic-era spacing that the grid now provides. It beat the group's
own rule, being inline, and made that one page's statistics sit
differently from the six others.
CardGroup was the only component in the library with no class of its own,
which left nothing to assert against -- `container.firstChild` in jsdom
is Mantine's injected <style> element. It has one now, and takes
className/style/rest like its siblings.
The gallery grows a seventh statistic, so the group wraps at a normal
window width where the row hairlines can be seen, and a second group of
coloured readings as Status renders them.
Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js
rather than jest: jsdom returns zeros from getBoundingClientRect and
never resolves a var(), so it cannot judge any of it.
This commit is contained in:
parent
9d24d67f59
commit
a2aa1352fb
6 changed files with 376 additions and 35 deletions
|
|
@ -852,9 +852,10 @@ html[data-theme="amber"] .wrolpi-card-tag {
|
|||
/* ------------------------------------------------------------- Statistics */
|
||||
/*
|
||||
* A statistic carries its own spacing rather than relying on a parent to supply
|
||||
* it: unmigrated pages still drop these inside Semantic's `Statistic.Group`,
|
||||
* whose CSS only spaces elements carrying Semantic's own classes, and without
|
||||
* this the labels run together into one unreadable line.
|
||||
* it, so that one dropped on a page by itself still sits clear of its
|
||||
* neighbours. Semantic's `Statistic.Group` only spaced elements carrying
|
||||
* Semantic's own classes, so without this the labels ran together into one
|
||||
* unreadable line.
|
||||
*/
|
||||
|
||||
.wrolpi-statistic {
|
||||
|
|
@ -863,6 +864,44 @@ html[data-theme="amber"] .wrolpi-card-tag {
|
|||
margin: 0 26px 10px 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The group's hairlines are an outline on each cell, drawn into a 1px grid gap.
|
||||
*
|
||||
* Not a border per cell: a border can only separate the siblings the author can
|
||||
* count -- the old code suppressed `border-right` on the last child -- and
|
||||
* `auto-fit` wraps, so the seven statistics on the Docs page became four rows on
|
||||
* a phone with no rule between them, while the cell ending each earlier row drew
|
||||
* its border straight onto the outer one.
|
||||
*
|
||||
* Nor a border-coloured background behind the gaps, which rules both axes but
|
||||
* also paints every track no cell landed in: seven statistics in two columns
|
||||
* left the eighth slot a solid grey block. An outline is drawn outside the
|
||||
* cell, so it appears only where a cell actually is. Adjacent outlines meet in
|
||||
* the same 1px of gap, and the outer ones land on the group's own border, all in
|
||||
* the same colour, so every rule reads as a single hairline.
|
||||
*/
|
||||
.wrolpi-statistic-group {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 1px;
|
||||
background-color: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.wrolpi-statistic-cell {
|
||||
background-color: var(--panel);
|
||||
outline: 1px solid var(--border);
|
||||
padding: 14px 16px;
|
||||
}
|
||||
|
||||
/*
|
||||
* A statistic that renders nothing -- Status omits the fan reading on a device
|
||||
* with no fan connector -- must not leave a padded cell and a hairline behind.
|
||||
*/
|
||||
.wrolpi-statistic-cell:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Inside our own group the grid does the spacing, so the intrinsic margin goes. */
|
||||
.wrolpi-statistic-cell .wrolpi-statistic {
|
||||
display: block;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue