diff --git a/CHANGELOG.md b/CHANGELOG.md index 8531411..5f4eca9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,16 @@ 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. +Every metric is one card in one grid, 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. An earlier version put the first four metrics in catalogue order (steps, active energy, +exercise time, stand hours) in a full-width "Trends" section above the grid, with a big chart and +the window's own min/avg/high. It read as two screens stapled together — four huge cards, one per +row, above a tidy grid of small ones — and since those four are the ones most people look at, the +grid looked like it was missing its own headline metrics. The shape of a week is the sparkline on +the card now, and the chart worth reading is one tap away, where it also has the hours and the +day-by-day numbers around it. 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 diff --git a/frontend/src/index.css b/frontend/src/index.css index 3619d35..acca52a 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -1404,22 +1404,10 @@ body.chips-dragging *{cursor:inherit} /* --- the chart panels ----------------------------------------------------- Full-width panels for the few metrics people open this screen for. Same `--tint` contract as the tiles, so a panel and its card are recognisably the same metric. */ -.vh-charts{display:flex;flex-direction:column;gap:10px;margin-bottom:14px} -.vh-tchart{--tint:var(--grey);width:100%;text-align:left;display:block;font:inherit;color:inherit; - padding:12px 10px 6px;background:color-mix(in srgb,var(--tint) 9%,var(--glass)); - border:var(--hair) solid color-mix(in srgb,var(--tint) 20%,transparent); - -webkit-backdrop-filter:blur(10px) saturate(140%);backdrop-filter:blur(10px) saturate(140%)} -.vh-tchart:active{background:color-mix(in srgb,var(--tint) 14%,var(--glass))} /* Deliberately NO opaque fallback where backdrop-filter is missing, unlike the tab bar. The bar floats over scrolling content, where a see-through panel would put text on text; a card sits in the page flow, and the only thing behind it is the aura. Losing the blur there costs nothing, and the opaque fallback is exactly what made these cards look solid on a device that took it. */ -.vh-tchart-hd{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:0 2px;margin-bottom:2px} -.vh-tchart-t{display:flex;align-items:center;gap:5px;font-size:14px;font-weight:500;color:var(--label-2)} -.vh-tchart-t .icn{font-size:15px;color:var(--tint)} -.vh-tchart-v{font-size:22px;font-weight:600;letter-spacing:-.022em;color:var(--tint);font-variant-numeric:tabular-nums} -.vh-tchart-v i{margin-left:3px;font-size:12px;font-weight:500;font-style:normal;color:var(--label-2)} -.vh-tchart-ft{display:flex;gap:12px;padding:0 2px;margin-top:1px;font-size:11.5px;color:var(--label-3);font-variant-numeric:tabular-nums} .vh-window{font-weight:400;color:var(--label-3);text-transform:none;letter-spacing:0} .vh-sheet-top{margin:2px 0 12px} diff --git a/frontend/src/lib/vitals-view.js b/frontend/src/lib/vitals-view.js index 40d3ac8..51c1a9a 100644 --- a/frontend/src/lib/vitals-view.js +++ b/frontend/src/lib/vitals-view.js @@ -314,27 +314,6 @@ export function dayLabel(day, now = new Date()) { return fmtDate(day) } -/** - * The cards worth a full-width chart: the catalogue's own order (steps, heart rate, sleep…), - * only the ones the window has enough days to draw. A chart of a single point is a dot, so those - * are left to the grid's own card rather than given a panel that looks broken. - */ -export function trendCards(cards, { limit = 4, minDays = 2 } = {}) { - return cards.filter(c => c.series.length >= minDays).slice(0, limit) -} - -/** min / max / average over a card's window, for the caption under a chart. */ -export function seriesStats(card) { - const vs = (card?.series || []).map(p => p.v).filter(v => Number.isFinite(v)) - if (!vs.length) return null - return { - min: Math.min(...vs), - max: Math.max(...vs), - avg: vs.reduce((a, b) => a + b, 0) / vs.length, - days: vs.length - } -} - /* ---------- units and numbers ---------- */ // HAE's unit strings are compact and sometimes need a human spelling. Values are never converted: diff --git a/frontend/src/lib/vitals-view.test.js b/frontend/src/lib/vitals-view.test.js index ed14fcf..34c11f2 100644 --- a/frontend/src/lib/vitals-view.test.js +++ b/frontend/src/lib/vitals-view.test.js @@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest' import { METRICS, specOf, humanize, valueOfDay, metricCards, sortCards, groupedCards, trendOf, chartPoints, workoutRows, hasVitals, activeDays, ingestUrl, unitLabel, fmtValue, agoLabel, - detailRows, workoutIcon, GROUP_ORDER, tintOf, dayLabel, trendCards, seriesStats, + detailRows, workoutIcon, GROUP_ORDER, tintOf, dayLabel, hourRows, hourChartPoints, historyRows } from './vitals-view.js' @@ -213,7 +213,7 @@ describe('aliases', () => { }) }) -describe('dayLabel / trendCards / seriesStats', () => { +describe('dayLabel', () => { const now = new Date('2026-05-03T09:00:00') it('names the newest day in words when it is recent', () => { @@ -226,21 +226,7 @@ describe('dayLabel / trendCards / seriesStats', () => { expect(dayLabel(undefined, now)).toBe('') }) - it('picks the cards a full-width chart is worth, in catalogue order', () => { - const cards = metricCards(doc) - const picked = trendCards(cards, { limit: 3 }) - // In this fixture only two metrics have two days or more; heart_rate and weight_body_mass - // carry a single day each, and a one-point chart is a dot nobody can read. - expect(picked.map(c => c.name)).toEqual(['step_count', 'resting_heart_rate']) - expect(trendCards(cards, { limit: 20 }).every(c => c.series.length >= 2)).toBe(true) - // A card with a single day is left out: a one-point chart is a dot. - expect(trendCards([{ name: 'x', series: [{ day: '2026-05-03', v: 1 }] }])).toEqual([]) - }) - - it('summarises a window for the caption under a chart', () => { - expect(seriesStats(card(doc, 'step_count'))).toMatchObject({ min: 5000, max: 12000, days: 3 }) - expect(seriesStats(card(doc, 'step_count')).avg).toBe(8000) - expect(seriesStats({ series: [] })).toBeNull() + it('keeps the newest reading\'s timestamp, which is what makes a card checkable', () => { expect(card(doc, 'step_count').lastTs).toBeTruthy() }) }) diff --git a/frontend/src/views/Health.jsx b/frontend/src/views/Health.jsx index 7471a6b..8523f3a 100644 --- a/frontend/src/views/Health.jsx +++ b/frontend/src/views/Health.jsx @@ -26,7 +26,7 @@ import LineChart from '../components/LineChart.jsx' import { todayISO } from '../lib/format.js' import { groupedCards, metricCards, trendOf, chartPoints, workoutRows, hasVitals, - fmtValue, unitLabel, agoLabel, ingestUrl, detailRows, dayLabel, trendCards, seriesStats, + fmtValue, unitLabel, agoLabel, ingestUrl, detailRows, dayLabel, hourRows, hourChartPoints, historyRows } from '../lib/vitals-view.js' @@ -78,39 +78,14 @@ function MetricCard({ card, onOpen }) { } -/** - * The charts. Every card in the grid carries a sparkline, which is enough to see a shape and not - * enough to read one — so the first few metrics in the catalogue's own order (steps, heart rate, - * sleep…, the ones people open this screen for) get a panel: axes, the window's own min/max/avg, - * and the card's colour, so a panel and its tile are recognisably the same thing. - */ -function TrendSection({ cards, windowLabel, onOpen }) { - const picked = cards - if (!picked.length) return null - return <> -