mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-30 03:46:29 -05:00
ui: statistics carry no chrome, only spacing
The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
This commit is contained in:
parent
a2aa1352fb
commit
d697265267
4 changed files with 145 additions and 105 deletions
|
|
@ -725,8 +725,8 @@ describe('StatisticGroup', () => {
|
|||
it('leaves a cell empty when its statistic renders nothing', () => {
|
||||
// `FanRPMStatistic` returns null on a device with no fan connector, which is most of
|
||||
// them. The group cannot know that in advance, so the cell is still emitted and
|
||||
// `.wrolpi-statistic-cell:empty` hides it -- which only works while the cell has no
|
||||
// padding or background of its own inline for that rule to have to outrank.
|
||||
// `.wrolpi-statistic-cell:empty` takes it back out -- which only works while the cell
|
||||
// has nothing of its own inline for that rule to have to outrank.
|
||||
const Nothing = () => null;
|
||||
const {container} = renderUI(<StatisticGroup>
|
||||
<Statistic value='1,432' label='Videos'/>
|
||||
|
|
@ -738,21 +738,30 @@ describe('StatisticGroup', () => {
|
|||
expect(cells[1].getAttribute('style')).toBeNull();
|
||||
});
|
||||
|
||||
it('draws its hairlines with the grid, not a border per cell', () => {
|
||||
// A per-cell border can only separate siblings the author can count -- the old code
|
||||
// suppressed `borderRight` on the last child -- and `auto-fit` wraps. Seven
|
||||
// statistics on a phone became four rows with no rule between them, while the cell
|
||||
// ending each earlier row drew its border straight onto the outer one. A 1px gap
|
||||
// over a border-coloured background rules both axes however the tracks fall.
|
||||
it('draws no chrome of its own, in markup or in style', () => {
|
||||
// The group is spacing only: the statistics sit on whatever surface they were dropped
|
||||
// onto and take its colour. An inline border or background here would override the
|
||||
// stylesheet and could not be themed, so nothing may set one.
|
||||
const {container} = renderUI(<StatisticGroup>
|
||||
<Statistic value='1,432' label='Videos'/>
|
||||
<Statistic value='896' label='Archives'/>
|
||||
</StatisticGroup>);
|
||||
|
||||
const group = container.querySelector('.wrolpi-statistic-group');
|
||||
expect(group.style.border).toBe('');
|
||||
expect(group.style.background).toBe('');
|
||||
expect(group.style.backgroundColor).toBe('');
|
||||
for (const cell of container.querySelectorAll('.wrolpi-statistic-cell')) {
|
||||
expect(cell.style.borderRight).toBe('');
|
||||
expect(cell.getAttribute('style')).toBeNull();
|
||||
}
|
||||
expect(container.querySelector('.wrolpi-statistic-group')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('still passes a style from the caller through', () => {
|
||||
const {container} = renderUI(<StatisticGroup style={{maxWidth: 600}}>
|
||||
<Statistic value='1,432' label='Videos'/>
|
||||
</StatisticGroup>);
|
||||
|
||||
expect(container.querySelector('.wrolpi-statistic-group')).toHaveStyle({maxWidth: '600px'});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue