mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
feat(insights): recompute the stat strip for a brushed chart window
Wire the metric sub-pages so brushing a window in the chart recomputes the Min/Max/Median/Mittelwert strip for the visible domain. The page lifts the shared brushed-window state, passes `selectableDomain` + `onDomainStats` to the chart, and threads the per-series window stats into the strip. With no selection the strip keeps the precomputed full-range summary, so the default is unchanged and costs no extra work. The strip renders the windowed numbers when present and pins a "selected range" pill to its header so the user reads the stats as their selection. Blood pressure brushes both series at once — the single chart reports systolic and diastolic stats and each strip reads its half. Covers weight, pulse, blood pressure, and the ~37 HealthKit pages that ride the shared scaffold. BMI (a derived metric with no first-class strip) and sleep (no strip) are left as-is. New copy added in all six locales. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
0995664893
commit
4dde3e1d8b
11 files changed
+103
-18
No files matched your search
@@ -7,6 +7,7 @@ import { useAuth } from "@/hooks/use-auth";
|
||||
import { useInsightsAnalytics } from "@/hooks/use-insights-analytics";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { useInsightsLayoutPrefs } from "@/hooks/use-insights-layout-prefs";
|
||||
import { useChartDomainStats } from "@/hooks/use-chart-domain-stats";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { HealthChartDynamic } from "@/components/charts/health-chart-dynamic";
|
||||
import { SlugInsightStatusCard } from "@/components/insights/slug-insight-status-card";
|
||||
@@ -50,6 +51,11 @@ export default function InsightsBlutdruckPage() {
|
||||
const sysSummary = analytics?.summaries?.BLOOD_PRESSURE_SYS ?? null;
|
||||
const diaSummary = analytics?.summaries?.BLOOD_PRESSURE_DIA ?? null;
|
||||
|
||||
// v1.12.7 — chart-reactive metric statistics. Blood pressure brushes BOTH
|
||||
// series at once: the single chart reports per-type windowed stats and each
|
||||
// strip reads its own half.
|
||||
const { statsByType, onDomainStats } = useChartDomainStats();
|
||||
|
||||
if (isEmpty) {
|
||||
return (
|
||||
<SubPageShell
|
||||
@@ -113,6 +119,7 @@ export default function InsightsBlutdruckPage() {
|
||||
fractionDigits={0}
|
||||
seriesLabel={t("charts.systolic")}
|
||||
icon={ArrowUpRight}
|
||||
windowStats={statsByType?.BLOOD_PRESSURE_SYS ?? null}
|
||||
/>
|
||||
<MetricStatStrip
|
||||
summary={diaSummary}
|
||||
@@ -120,6 +127,7 @@ export default function InsightsBlutdruckPage() {
|
||||
fractionDigits={0}
|
||||
seriesLabel={t("charts.diastolic")}
|
||||
icon={ArrowDownRight}
|
||||
windowStats={statsByType?.BLOOD_PRESSURE_DIA ?? null}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
@@ -142,6 +150,8 @@ export default function InsightsBlutdruckPage() {
|
||||
targetZones={bpTargetZones}
|
||||
compareBaseline={compareBaseline}
|
||||
userTimezone={user?.timezone}
|
||||
selectableDomain
|
||||
onDomainStats={onDomainStats}
|
||||
/>
|
||||
|
||||
{/* v1.12.4 — target card sits between the chart and the assessment on
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useAuth } from "@/hooks/use-auth";
|
||||
import { useInsightsAnalytics } from "@/hooks/use-insights-analytics";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { useInsightsLayoutPrefs } from "@/hooks/use-insights-layout-prefs";
|
||||
import { useChartDomainStats } from "@/hooks/use-chart-domain-stats";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { HealthChartDynamic } from "@/components/charts/health-chart-dynamic";
|
||||
import { SlugInsightStatusCard } from "@/components/insights/slug-insight-status-card";
|
||||
@@ -50,6 +51,10 @@ export default function InsightsPulsPage() {
|
||||
const vo2Summary = analytics?.summaries?.VO2_MAX ?? null;
|
||||
const pulseSummary = analytics?.summaries?.PULSE ?? null;
|
||||
|
||||
// v1.12.7 — brushed-window stats shared between the pulse chart and the
|
||||
// strip (the VO2 chart-row below keeps its own full-range read).
|
||||
const { statsByType, onDomainStats } = useChartDomainStats();
|
||||
|
||||
// v1.4.27 F17 — gate the sub-page on at least one pulse observation.
|
||||
// Brand-new accounts (no manual logs, no Apple-Health upload yet)
|
||||
// see a one-line empty-state with a CTA into
|
||||
@@ -119,6 +124,7 @@ export default function InsightsPulsPage() {
|
||||
unit="bpm"
|
||||
seriesLabel={t("insights.pulseSectionTitle")}
|
||||
icon={Heart}
|
||||
windowStats={statsByType?.PULSE ?? null}
|
||||
/>
|
||||
}
|
||||
diversityNudge={
|
||||
@@ -140,6 +146,8 @@ export default function InsightsPulsPage() {
|
||||
valueBands={pulseBands}
|
||||
compareBaseline={compareBaseline}
|
||||
userTimezone={user?.timezone}
|
||||
selectableDomain
|
||||
onDomainStats={onDomainStats}
|
||||
/>
|
||||
|
||||
<MetricTargetSummary slug="pulse" />
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useAuth } from "@/hooks/use-auth";
|
||||
import { useInsightsAnalytics } from "@/hooks/use-insights-analytics";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { useInsightsLayoutPrefs } from "@/hooks/use-insights-layout-prefs";
|
||||
import { useChartDomainStats } from "@/hooks/use-chart-domain-stats";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { HealthChartDynamic } from "@/components/charts/health-chart-dynamic";
|
||||
import { SlugInsightStatusCard } from "@/components/insights/slug-insight-status-card";
|
||||
@@ -39,6 +40,9 @@ export default function InsightsGewichtPage() {
|
||||
const { data: analytics, isEmpty } = useInsightsAnalytics("WEIGHT");
|
||||
const weightSummary = analytics?.summaries?.WEIGHT ?? null;
|
||||
|
||||
// v1.12.7 — brushed-window stats shared between the chart and the strip.
|
||||
const { statsByType, onDomainStats } = useChartDomainStats();
|
||||
|
||||
if (isEmpty) {
|
||||
return (
|
||||
<SubPageShell
|
||||
@@ -81,6 +85,7 @@ export default function InsightsGewichtPage() {
|
||||
unit="kg"
|
||||
seriesLabel={t("insights.weightSectionTitle")}
|
||||
icon={Scale}
|
||||
windowStats={statsByType?.WEIGHT ?? null}
|
||||
/>
|
||||
}
|
||||
diversityNudge={
|
||||
@@ -102,6 +107,8 @@ export default function InsightsGewichtPage() {
|
||||
valueBands={weightBands}
|
||||
compareBaseline={compareBaseline}
|
||||
userTimezone={user?.timezone}
|
||||
selectableDomain
|
||||
onDomainStats={onDomainStats}
|
||||
/>
|
||||
|
||||
<MetricTargetSummary slug="weight" />
|
||||
|
||||
Reference in new issue
Block a user