mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
feat(insights): surface inputs, method and a cited standard for all 11 derived metrics
Only Sleep and Readiness reached a provenance surface; the other nine shipped a number with the cited standard buried in a code comment. Give every derived metric a path to its inputs + method + cited standard: - Recovery, Stress and Strain get a ScoreAnatomyView detail page and a tappable ring (they were read-only dead-ends). Stress surfaces its 'HRV-derived proxy, NOT an EDA/galvanic measurement' caveat; Strain cites the TRIMP load model; Recovery the HRV-guided recovery literature. - The vitals tiles (baseline, HRV balance, BMI, fitness age, vascular age) gain an info explainer affordance carrying the method + standard, since they render as tiles with no detail page. - The coincident-deviation flag gains a dashboard tile (shown only when it fired) with the same explainer (median ± k·MAD basis). - A single standards map (src/components/insights/derived/standards.ts) pins each metric's method copy key, standard name and a real linkable URL (DOI / WHO / Wikipedia) so the citation a metric exposes stays one source. Add the per-metric method/caveat/description copy across all six locales. Map storage units to display symbols so a baseline tile reads '36.6 °C', not '36.6 celsius'. Show the band word under the strip rings so a value reads 'low 62', not a bare reddish 62. Drop the empty dashed sparkline placeholder when no trailing series exists rather than reserving dead space, and give the tile a series + provenance slot for when one does.
This commit is contained in:
1 parent
b92d5cec82
commit
551d352581
15 files changed
+960
-250
No files matched your search
@@ -6,35 +6,68 @@ import { useTranslations } from "@/lib/i18n/context";
|
||||
import { SubPageShell } from "@/components/insights/sub-page-shell";
|
||||
import {
|
||||
CompositeScoreAnatomy,
|
||||
type CompositeMetricId,
|
||||
type AnatomyMetricId,
|
||||
} from "@/components/insights/derived/composite-score-anatomy";
|
||||
|
||||
/**
|
||||
* v1.10.0 — `/insights/scores/<metric>` — the composite score-anatomy
|
||||
* detail surface.
|
||||
* v1.10.0 — `/insights/scores/<metric>` — the score-anatomy detail surface.
|
||||
*
|
||||
* Reached on tap from a composite's dashboard / insights entry. Renders the
|
||||
* Oura-style anatomy view (big ring + ranked contributor rows + cited
|
||||
* standard) for one composite. The `[metric]` param is validated against the
|
||||
* two W3 composites — an unknown slug falls back to the readiness view's
|
||||
* insufficient state rather than 404-ing, so a stale link never dead-ends.
|
||||
* Reached on tap from a score's dashboard / insights entry. Renders the
|
||||
* Oura-style anatomy view (big ring + ranked contributor rows where the
|
||||
* score decomposes + cited standard + method + honesty caveat) for one
|
||||
* derived score — the two composites (sleep, readiness) AND the three
|
||||
* persisted nightly scores (recovery, stress, strain), which previously had
|
||||
* no detail page. The `[metric]` slug is validated against the known set; an
|
||||
* unknown slug falls back to the readiness view's insufficient state rather
|
||||
* than 404-ing, so a stale link never dead-ends.
|
||||
*/
|
||||
|
||||
const SLUG_TO_METRIC: Record<string, CompositeMetricId> = {
|
||||
const SLUG_TO_METRIC: Record<string, AnatomyMetricId> = {
|
||||
sleep: "SLEEP_SCORE",
|
||||
readiness: "READINESS",
|
||||
recovery: "RECOVERY_SCORE",
|
||||
stress: "STRESS_SCORE",
|
||||
strain: "STRAIN_SCORE",
|
||||
};
|
||||
|
||||
/** Localised page header per metric (title + one-line description). */
|
||||
const HEADER_KEYS: Record<
|
||||
AnatomyMetricId,
|
||||
{ title: string; description: string }
|
||||
> = {
|
||||
SLEEP_SCORE: {
|
||||
title: "insights.derived.composite.SLEEP_SCORE.title",
|
||||
description: "insights.derived.composite.SLEEP_SCORE.description",
|
||||
},
|
||||
READINESS: {
|
||||
title: "insights.derived.composite.READINESS.title",
|
||||
description: "insights.derived.composite.READINESS.description",
|
||||
},
|
||||
RECOVERY_SCORE: {
|
||||
title: "insights.derived.scores.recovery",
|
||||
description: "insights.derived.composite.RECOVERY_SCORE.description",
|
||||
},
|
||||
STRESS_SCORE: {
|
||||
title: "insights.derived.scores.stress",
|
||||
description: "insights.derived.composite.STRESS_SCORE.description",
|
||||
},
|
||||
STRAIN_SCORE: {
|
||||
title: "insights.derived.scores.strain",
|
||||
description: "insights.derived.composite.STRAIN_SCORE.description",
|
||||
},
|
||||
};
|
||||
|
||||
export default function CompositeScorePage() {
|
||||
const params = useParams<{ metric: string }>();
|
||||
const { t } = useTranslations();
|
||||
const slug = typeof params.metric === "string" ? params.metric : "";
|
||||
const metric: CompositeMetricId = SLUG_TO_METRIC[slug] ?? "READINESS";
|
||||
const metric: AnatomyMetricId = SLUG_TO_METRIC[slug] ?? "READINESS";
|
||||
const header = HEADER_KEYS[metric];
|
||||
|
||||
return (
|
||||
<SubPageShell
|
||||
title={t(`insights.derived.composite.${metric}.title`)}
|
||||
description={t(`insights.derived.composite.${metric}.description`)}
|
||||
title={t(header.title)}
|
||||
description={t(header.description)}
|
||||
coachLaunch
|
||||
>
|
||||
<CompositeScoreAnatomy metric={metric} />
|
||||
|
||||
Reference in new issue
Block a user