From 3c88e3c18810c1ef4192183091d2d252d3b6a730 Mon Sep 17 00:00:00 2001 From: Daniel Santillan Date: Wed, 23 Sep 2026 13:36:22 -0400 Subject: [PATCH] Salud: two cards to a row, at every width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- CHANGELOG.md | 4 ++++ frontend/src/index.css | 8 +++++++ frontend/src/views/Health.jsx | 5 +++- frontend/src/views/Health.render.test.jsx | 29 ++++++++++++++++++++++- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d19781f..8531411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ rate, sleep, weight, oxygen, workouts, and every other metric HAE can export — fork has never heard of, which land under **Other** with a humanised name and a detail sheet listing every field the watch sent. +The cards sit two to a row, on a phone and on a desktop alike — every other grid in the app goes +to four columns once there is width for them, and at four across a health card wraps its unit onto +a second line and flattens the sparkline that makes the grid readable at a glance. + Per profile, and private by construction. Each profile mints its own **ingest key** (write-only: it can add to that one profile's health file and cannot read a single number back), and rotating it disconnects a phone without signing anybody out. The health data lives in its own diff --git a/frontend/src/index.css b/frontend/src/index.css index e7fd0af..3619d35 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -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)} diff --git a/frontend/src/views/Health.jsx b/frontend/src/views/Health.jsx index 7506e41..7471a6b 100644 --- a/frontend/src/views/Health.jsx +++ b/frontend/src/views/Health.jsx @@ -421,7 +421,10 @@ export default function Health() { {groups.map(g =>

{g.label}

-
{g.cards.map(c => )}
+ {/* 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. */} +
{g.cards.map(c => )}
)} {cards.length === 0 &&
diff --git a/frontend/src/views/Health.render.test.jsx b/frontend/src/views/Health.render.test.jsx index 710ab68..acece5a 100644 --- a/frontend/src/views/Health.render.test.jsx +++ b/frontend/src/views/Health.render.test.jsx @@ -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 () => {