Salud: two cards to a row, at every width
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Asked for as "filas de 2 tarjetas para que se vea bien". The grid used the shared `.tiles`, which is two columns on a phone and **four** at ≥1000px, so on a desktop the health cards were ~240px wide — narrow enough that the unit wrapped off the number and the sparkline flattened into a squiggle with no shape, which is the one thing it is there to show. The grid now carries `vh-tiles` and the stylesheet gives that pairing two columns, on any screen. It is a scoped rule rather than a change to `.tiles` because every other grid in the app — Home's quick tiles, Stats, the admin cards, the sheets — wants the four-column version; a health card is the only tile carrying a unit, a trend arrow and a chart. The test asserts both halves, because either one alone does nothing: the class on the grid, and the rule it applies. Checked against both bugs — removing the class fails it, and so does putting the rule back to four columns.
This commit is contained in:
1 parent
aa6ec8ef22
commit
3c88e3c188
4 files changed
+44
-2
No files matched your search
@@ -1350,6 +1350,14 @@ body.chips-dragging *{cursor:inherit}
|
||||
background:color-mix(in srgb,var(--tint) 14%,var(--glass));
|
||||
border:var(--hair) solid color-mix(in srgb,var(--tint) 26%,transparent);
|
||||
-webkit-backdrop-filter:blur(10px) saturate(140%);backdrop-filter:blur(10px) saturate(140%)}
|
||||
/* Two per row, on a phone and on a 1080px desktop alike.
|
||||
Every other grid in the app goes to four columns once there is room for them, and a health card
|
||||
is the one tile that must not: it carries a label, a number *with its unit*, a trend arrow, a
|
||||
sparkline and the date it came from. At four across (≈240px) the unit wraps off the number and
|
||||
the sparkline loses its shape, which is the only reason it is there. Two columns keeps the
|
||||
number and its unit on one line at every width, and matches what the same screen looks like on
|
||||
the phone. */
|
||||
.tiles.vh-tiles{grid-template-columns:1fr 1fr}
|
||||
.vh-card .l{color:var(--tint)}
|
||||
.vh-card .l .icn{color:var(--tint)}
|
||||
.vh-card .v{color:var(--tint)}
|
||||
|
||||
@@ -421,7 +421,10 @@ export default function Health() {
|
||||
|
||||
{groups.map(g => <div key={g.group}>
|
||||
<h4 className="sec">{g.label}</h4>
|
||||
<div className="tiles">{g.cards.map(c => <MetricCard key={c.name} card={c} onOpen={openMetric} />)}</div>
|
||||
{/* Two per row (`vh-tiles`), on a phone and on a wide screen alike: every other grid in
|
||||
the app is four columns at ≥1000px, and these cards are too wide for that — the unit
|
||||
wraps off the number and the sparkline loses the shape it is there to show. */}
|
||||
<div className="tiles vh-tiles">{g.cards.map(c => <MetricCard key={c.name} card={c} onOpen={openMetric} />)}</div>
|
||||
</div>)}
|
||||
|
||||
{cards.length === 0 && <div className="small dim" style={{ margin: '0 2px 12px' }}>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import React, { act } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { useStore } from '../store/useStore.js'
|
||||
import { useUI } from '../store/useUI.js'
|
||||
|
||||
@@ -20,6 +21,11 @@ const { default: Health } = await import('./Health.jsx')
|
||||
const { default: Modals } = await import('../components/Modals.jsx')
|
||||
const { todayISO } = await import('../lib/format.js')
|
||||
|
||||
/* The layout rule this screen depends on, read as a source string the way Stats.test.js reads its
|
||||
own: the class alone does nothing, and a four-column grid here is the bug being guarded. (A path
|
||||
rather than `import.meta.url`, which is the document's in this happy-dom file, not a file URL.) */
|
||||
const cssSource = readFileSync('src/index.css', 'utf8')
|
||||
|
||||
const bucket = v => ({ n: 1, sum: v, min: v, max: v, last: v, avg: v })
|
||||
const day = (d, f, n = 1) => ({ day: d, n, f })
|
||||
|
||||
@@ -108,6 +114,22 @@ describe('Salud', () => {
|
||||
expect(api).toHaveBeenCalledWith('/api/vitals?days=7')
|
||||
})
|
||||
|
||||
it('lays the cards out two per row, which is what keeps a number and its unit on one line', async () => {
|
||||
/* Every other grid in the app goes to four columns at ≥1000px, and a health card at that width
|
||||
wraps its unit onto a second line and flattens the sparkline. The request was "filas de 2
|
||||
tarjetas", and it takes both halves: the class on the grid, and the rule in the stylesheet
|
||||
that gives it two columns at every width. */
|
||||
api.mockResolvedValue(VITALS)
|
||||
await mount()
|
||||
const grids = [...host.querySelectorAll('.tiles.vh-tiles')]
|
||||
expect(grids.length).toBeGreaterThan(1) // one per group that has cards
|
||||
expect(grids.reduce((n, g) => n + g.querySelectorAll('.vh-card').length, 0)).toBe(4)
|
||||
// ...and every grid on the screen is one of them: a group that lost the class would silently
|
||||
// go back to four columns at ≥1000px.
|
||||
expect([...host.querySelectorAll('.tiles')]).toEqual(grids)
|
||||
expect(cssSource).toContain('.tiles.vh-tiles{grid-template-columns:1fr 1fr}')
|
||||
})
|
||||
|
||||
it('paints each card with its family colour, which is what makes the grid scannable', async () => {
|
||||
// The tint is a CSS variable on the card, so the number, the icon, the sparkline and the wash
|
||||
// behind them all come from one property — this checks the wiring, not the shades.
|
||||
@@ -149,7 +171,12 @@ describe('the Today filter', () => {
|
||||
ok: true, days: 7, key: null, updatedAt: Date.now(), last: { ts: Date.now(), metrics: 2, points: 2, duplicates: 0, workouts: 0 },
|
||||
metrics: days, workouts: []
|
||||
})
|
||||
const bucket = v => ({ n: 1, sum: v, min: v, max: v, last: v, avg: v })
|
||||
/* The layout rule this screen depends on, read as a source string the way Stats.test.js reads its
|
||||
own: the class alone does nothing, and a four-column grid here is the bug being guarded. (A path
|
||||
rather than `import.meta.url`, which is the document's in this happy-dom file, not a file URL.) */
|
||||
const cssSource = readFileSync('src/index.css', 'utf8')
|
||||
|
||||
const bucket = v => ({ n: 1, sum: v, min: v, max: v, last: v, avg: v })
|
||||
const day = (d, f) => ({ day: d, n: 1, f, lastTs: Date.now() - 12 * 60000 })
|
||||
|
||||
it('shows only what came in today, and counts it', async () => {
|
||||
|
||||
Reference in new issue
Block a user