feat(insights): show the metric explainer inline under each category heading

The per-category explainer text only lived behind the "?" popover next to
the heading. Render the same localised definition inline as a muted caption
directly beneath the title, where the short scaffold line already sits, so
the one- to two-sentence definition is discoverable without a tap.

Both surfaces read the identical insights.subPage.explainer.<metric>Body
key, so there is no duplicated copy and all six locales stay covered. The
"?" glyph stays in place as the always-available pointer to the same text.
HealthkitMetricPage already forwards explainerMetric to the shell, so every
routed metric sub-page picks up the inline caption from this one change.
This commit is contained in:
Marc-André Bombeck committed 2026-06-01 17:31:02 +02:00
1 parent 0e3a8f9cd3
commit c2808a9c70
2 files changed
+45 -1

No files matched your search

@@ -47,7 +47,30 @@ describe("<SubPageShell>", () => {
</SubPageShell>,
);
// The shell uses a `<p>` for the description; no `<p>` appears when
// the description prop is absent.
// neither a description nor an explainer metric is supplied.
expect(html).not.toMatch(/<p[^>]*class="text-muted-foreground/);
});
it("renders the explainer body inline beneath the heading", () => {
const html = render(
<SubPageShell title="Blood pressure" explainerMetric="bloodPressure">
<span />
</SubPageShell>,
);
// The inline caption reuses the same body string the `?` popover reads.
expect(html).toMatch(/data-slot="metric-explainer-inline"/);
expect(html).toContain(
"Blood pressure is the force your blood exerts on the artery walls",
);
});
it("keeps the explainer trigger glyph when explainerMetric is set", () => {
const html = render(
<SubPageShell title="Blood pressure" explainerMetric="bloodPressure">
<span />
</SubPageShell>,
);
// The `?` glyph stays available alongside the inline caption.
expect(html).toMatch(/data-slot="metric-explainer-trigger"/);
});
});