mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
feat(blood-pressure): label the in-target window dynamically and gate thin data
The BD-Zielbereich tile narrated a static "· 90 T" scope even for a user with only a few weeks of history or a handful of readings — a headline that reads like a stable quarter-long average when it is really a thin sample. Add a shared, reusable window-confidence helper that, given a window length and the readings observed inside it, returns the EFFECTIVE label span (the real calendar span capped at the window, so "· 23 T" until ~90 days of history exist) and a sufficiency flag (false below five readings). The helper is metric-agnostic so the glucose time-in-range / GMI and sleep tiles can reuse it. Wire it into the in-target headline: below the confidence floor the tile shows "sammelt noch Daten" instead of a hard percentage, with the dynamic span label; above it the percentage shows with the real span. The Health-Score BP pillar reads the same sufficiency notion through the shared input builder, so a thin-data user no longer gets a confident pillar grading off a few readings — the all-time rate still rescues a deep-history account with a quiet quarter. The 90-day pair count and effective span thread from the analytics route and the dashboard snapshot through to the tile.
This commit is contained in:
1 parent
461ed5b5e0
commit
e9138bb4f6
20 files changed
+416
-17
No files matched your search
@@ -114,4 +114,26 @@ describe("BD-Zielbereich tile (v1.4.28 FB-C1/C2 rewrite)", () => {
|
||||
expect(html).toContain('data-slot="trend-card-value-row"');
|
||||
expect(html).toContain("—");
|
||||
});
|
||||
|
||||
it("renders the empty-hint placeholder instead of a percentage on thin data (v1.17 W1b)", () => {
|
||||
const html = render(
|
||||
<TrendCard
|
||||
label="BP in Target · 23d"
|
||||
latest={null}
|
||||
emptyHint="collecting data"
|
||||
unit="%"
|
||||
avg7={null}
|
||||
avg30={null}
|
||||
slope30={null}
|
||||
icon={Target}
|
||||
directionSentiment="up-good"
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('data-slot="trend-card-empty-hint"');
|
||||
expect(html).toContain("collecting data");
|
||||
// The dynamic span label is shown in place of the static "· 90 T".
|
||||
expect(html).toContain("BP in Target · 23d");
|
||||
// No numeric headline value renders when the hint takes the slot.
|
||||
expect(html).not.toContain('data-slot="trend-card-value"');
|
||||
});
|
||||
});
|
||||
@@ -89,6 +89,16 @@ interface TrendCardProps {
|
||||
* `null` / `undefined` suppresses the caption (current data path).
|
||||
*/
|
||||
staleDays?: number | null;
|
||||
/**
|
||||
* v1.17 W1b — short text shown in the headline slot in place of the
|
||||
* "—" placeholder when `latest === null`. Used by the BD-Zielbereich
|
||||
* tile to render "collecting data" while the trailing window has too
|
||||
* few readings to narrate a confident percentage. When omitted the
|
||||
* legacy "—" placeholder renders. Rendered at a smaller size than a
|
||||
* numeric headline so the longer string fits the deterministic tile
|
||||
* height.
|
||||
*/
|
||||
emptyHint?: string | null;
|
||||
}
|
||||
|
||||
export function TrendCard({
|
||||
@@ -109,6 +119,7 @@ export function TrendCard({
|
||||
compareBaseline = "none",
|
||||
compareDelta = null,
|
||||
staleDays = null,
|
||||
emptyHint = null,
|
||||
}: TrendCardProps) {
|
||||
const { t } = useTranslations();
|
||||
const fmt = useFormatters();
|
||||
@@ -215,6 +226,20 @@ export function TrendCard({
|
||||
className="mt-2 flex items-baseline gap-x-1.5"
|
||||
data-slot="trend-card-value-row"
|
||||
>
|
||||
{latest === null && emptyHint ? (
|
||||
// v1.17 W1b — thin-data placeholder. Renders the caller's short
|
||||
// text (e.g. "collecting data") where the numeric headline would
|
||||
// sit, at a smaller size so the longer phrase fits the tile's
|
||||
// deterministic height. No unit; the arrow slot below still
|
||||
// renders its muted placeholder so the row width stays stable.
|
||||
<span
|
||||
className="text-muted-foreground min-w-0 truncate text-base font-medium leading-none"
|
||||
data-slot="trend-card-empty-hint"
|
||||
>
|
||||
{emptyHint}
|
||||
</span>
|
||||
) : (
|
||||
<>
|
||||
<span
|
||||
className={cn(
|
||||
"shrink-0 whitespace-nowrap font-semibold tracking-tight tabular-nums",
|
||||
@@ -253,6 +278,8 @@ export function TrendCard({
|
||||
<span className="text-muted-foreground min-w-0 truncate text-sm tabular-nums">
|
||||
{unit}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
<span
|
||||
className="ml-auto inline-flex h-4 w-4 shrink-0 items-center justify-center"
|
||||
data-slot="trend-card-arrow"
|
||||
|
||||
Reference in new issue
Block a user