mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 07:56:18 -05:00
ui: cards get legible titles, contained posters, and meta beside the title
Four defects on /videos, /docs and /archives. Titles were invisible outside light. `.card-link` carried a literal `color: black` from before the themes existed -- about 1.1:1 on the dark, night and amber panels. It applies to every card title and to the channel/author/domain line beside it. The date was fine, since it takes `--muted` from the card body, which is what made this look like a card bug rather than a link bug. Titles now take `--text`: they are links, but they are the card's text, not a wall of blue. Posters were cropped, not mis-proportioned. The image carried a fixed 290x163 box; a card in the default grid is about 233px wide and Mantine's Card sets `overflow: hidden`, so the browser painted the middle 233px of a 290px image. The ratio was right in the layout tree and wrong on screen. Replaced with caps on both axes -- the card's width and `--card-poster-max-height: 200px` -- with `width`/`height` left `auto` so the pair behaves as "contain". Bounding the width alone was tried first and is not enough: a square thumbnail then stands as tall as the card is wide, and a portrait book cover taller still. The meta line was foot-anchored, so on /docs a PDF with no author had its date shoved up to 55px below the title, at the bottom of a card that was tall only because of its neighbour in the row. It now sits directly under the title. Archive cards read buttons-then-domain, because the buttons were children and the meta was what got pushed to the foot. Card gains an `actions` slot, rendered last and anchored to the foot, so a row lines its buttons up however many lines each title took. Gallery gains a poster row covering all five ratios and a row showing meta/actions against unequal titles. 1076 jest tests, 145 in ui-layout.cy.js, clean build. Every new guard was checked against a planted regression: dropping the height cap reddens the square and portrait cases and leaves 16:9 green; `width: 100%` reddens containment; restoring `color: black` reddens dark/night/amber and leaves light green; re-anchoring the meta and swapping the slot order redden both the jest order test and the cypress geometry tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e3feffdb35
commit
e46a44d253
8 changed files with 361 additions and 41 deletions
|
|
@ -894,6 +894,37 @@ describe('Card', () => {
|
|||
|
||||
expect(container.firstChild.style.borderBottom).toBe('');
|
||||
});
|
||||
|
||||
it('puts the meta line under the title and the actions last', () => {
|
||||
/*
|
||||
* Order is the half of the fix jsdom can judge. An Archive card renders its domain
|
||||
* and date as `meta` and its Details/Open buttons as `actions`; before `actions`
|
||||
* existed the buttons were children and the meta was foot-anchored, so every archive
|
||||
* card read buttons-then-domain. Which slot lands where is what this asserts; that
|
||||
* the foot anchoring actually resolves is in ui-layout.cy.js, since `margin-top:
|
||||
* auto` needs a layout engine.
|
||||
*/
|
||||
renderUI(<Card title='Rainwater Harvesting'
|
||||
meta='engineering775.com'
|
||||
actions={<button type='button'>Details</button>}>
|
||||
<span>body</span>
|
||||
</Card>);
|
||||
|
||||
const body = screen.getByText('Rainwater Harvesting').parentElement;
|
||||
expect([...body.children].map(child => child.textContent)).toEqual([
|
||||
'Rainwater Harvesting', 'engineering775.com', 'body', 'Details',
|
||||
]);
|
||||
expect(body.querySelector('.wrolpi-card-actions')).toHaveStyle({marginTop: 'auto'});
|
||||
expect(body.querySelector('.wrolpi-card-meta').style.marginTop).toBe('');
|
||||
});
|
||||
|
||||
it('renders no actions row when a card has no actions', () => {
|
||||
// Otherwise every card in a grid pays for an empty foot, and the spacing below the
|
||||
// meta line differs between a card with buttons and one without.
|
||||
const {container} = renderUI(<Card title='Plain' meta='docs/'/>);
|
||||
|
||||
expect(container.querySelector('.wrolpi-card-actions')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('CardGroup', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue