mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
refactor(insights): route metric-page and chart colors through theme tokens
The per-metric reference bands, chart palettes, and status tints across the insights pages and shared charts carried hardcoded hex that glared on the light theme. Route them through the semantic and chart CSS variables; dark rendering stays byte-identical, light gets the muted set.
This commit is contained in:
1 parent
887c79ec86
commit
2afe32492b
49 files changed
+99
-89
No files matched your search
@@ -46,7 +46,7 @@ describe("resolveVerticalMarkerPositions", () => {
|
||||
);
|
||||
expect(positions).toHaveLength(1);
|
||||
expect(positions[0].pointIndex).toBe(0);
|
||||
expect(positions[0].color).toBe("#50fa7b");
|
||||
expect(positions[0].color).toBe("var(--success)");
|
||||
expect(positions[0].label).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -69,7 +69,7 @@ describe("resolveVerticalMarkerPositions", () => {
|
||||
expect(positions[0].color).toBe("#ff79c6");
|
||||
expect(positions[0].label).toBe("Mounjaro 7.5");
|
||||
// Default color preserved for the second marker.
|
||||
expect(positions[1].color).toBe("#50fa7b");
|
||||
expect(positions[1].color).toBe("var(--success)");
|
||||
expect(positions[1].label).toBeUndefined();
|
||||
});
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ interface HealthChartProps {
|
||||
* 2. A small filled dot sits at the x-axis intersection (mood-
|
||||
* chart style emoji-on-axis pattern repurposed) so a row of
|
||||
* green dots reads as "injection cadence" at a glance.
|
||||
* 3. Default green (`#50fa7b`) to match the strip-tile palette
|
||||
* 3. Default green (`var(--success)`) to match the strip-tile palette
|
||||
* for active medications; callers can override per marker.
|
||||
*
|
||||
* Off-window markers silently drop via `ifOverflow="discard"`,
|
||||
@@ -485,7 +485,7 @@ export function resolveVerticalMarkerPositions(
|
||||
if (idx === undefined) continue;
|
||||
out.push({
|
||||
pointIndex: idx,
|
||||
color: marker.color ?? "#50fa7b",
|
||||
color: marker.color ?? "var(--success)",
|
||||
label: marker.label,
|
||||
});
|
||||
}
|
||||
@@ -570,7 +570,7 @@ function buildTrendSeriesByTime(data: Array<{ date: Date; value: number }>): {
|
||||
export function HealthChart({
|
||||
types,
|
||||
title,
|
||||
colors = ["#bd93f9", "#ff79c6", "#8be9fd"],
|
||||
colors = ["var(--chart-1)", "var(--chart-3)", "var(--chart-4)"],
|
||||
unit,
|
||||
yAxisUnit,
|
||||
valueMode = "raw",
|
||||
|
||||
@@ -16,11 +16,11 @@ import type { TimeInRangeDistribution } from "@/lib/analytics/glucose-metrics";
|
||||
*/
|
||||
|
||||
const BAND_COLORS = {
|
||||
veryLow: "#ff5555", // dracula-red — urgent low
|
||||
low: "#ffb86c", // dracula-orange — low
|
||||
inRange: "#50fa7b", // dracula-green — target
|
||||
high: "#f1fa8c", // dracula-yellow — high
|
||||
veryHigh: "#ff79c6", // dracula-pink — urgent high
|
||||
veryLow: "var(--destructive)", // dracula-red — urgent low
|
||||
low: "var(--warning)", // dracula-orange — low
|
||||
inRange: "var(--success)", // dracula-green — target
|
||||
high: "var(--dracula-yellow)", // dracula-yellow — high
|
||||
veryHigh: "var(--chart-3)", // dracula-pink — urgent high
|
||||
} as const;
|
||||
|
||||
type BandKey = keyof typeof BAND_COLORS;
|
||||
|
||||
@@ -89,7 +89,7 @@ export function RecoverySection() {
|
||||
title: t("measurements.typeAnsCharge"),
|
||||
explainer: t("insights.recovery.block.ansChargeExplainer"),
|
||||
icon: Battery,
|
||||
color: "#50fa7b",
|
||||
color: "var(--success)",
|
||||
unit: unitScore,
|
||||
fractionDigits: 1,
|
||||
},
|
||||
@@ -105,7 +105,7 @@ export function RecoverySection() {
|
||||
title: t("measurements.typeDayStrain"),
|
||||
explainer: t("insights.recovery.block.dayStrainExplainer"),
|
||||
icon: Gauge,
|
||||
color: "#ffb86c",
|
||||
color: "var(--warning)",
|
||||
unit: unitScore,
|
||||
fractionDigits: 1,
|
||||
},
|
||||
@@ -116,7 +116,7 @@ export function RecoverySection() {
|
||||
title: t("measurements.typeWorkoutStrain"),
|
||||
explainer: t("insights.recovery.block.workoutStrainExplainer"),
|
||||
icon: Activity,
|
||||
color: "#ff79c6",
|
||||
color: "var(--chart-3)",
|
||||
unit: unitScore,
|
||||
fractionDigits: 1,
|
||||
},
|
||||
@@ -127,7 +127,7 @@ export function RecoverySection() {
|
||||
title: t("measurements.typeCardioLoad"),
|
||||
explainer: t("insights.recovery.block.cardioLoadExplainer"),
|
||||
icon: TrendingUp,
|
||||
color: "#bd93f9",
|
||||
color: "var(--chart-1)",
|
||||
unit: unitScore,
|
||||
},
|
||||
],
|
||||
@@ -142,7 +142,7 @@ export function RecoverySection() {
|
||||
title: t("measurements.typeAverageHeartRate"),
|
||||
explainer: t("insights.recovery.block.averageHeartRateExplainer"),
|
||||
icon: Heart,
|
||||
color: "#8be9fd",
|
||||
color: "var(--info)",
|
||||
unit: unitBpm,
|
||||
},
|
||||
{
|
||||
@@ -152,7 +152,7 @@ export function RecoverySection() {
|
||||
title: t("measurements.typeMaxHeartRate"),
|
||||
explainer: t("insights.recovery.block.maxHeartRateExplainer"),
|
||||
icon: HeartPulse,
|
||||
color: "#ff5555",
|
||||
color: "var(--destructive)",
|
||||
unit: unitBpm,
|
||||
},
|
||||
{
|
||||
@@ -162,7 +162,7 @@ export function RecoverySection() {
|
||||
title: t("measurements.typeEnergyExpenditureKj"),
|
||||
explainer: t("insights.recovery.block.energyExpenditureKjExplainer"),
|
||||
icon: Flame,
|
||||
color: "#f1fa8c",
|
||||
color: "var(--dracula-yellow)",
|
||||
unit: unitKj,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -42,7 +42,7 @@ export function SleepDurationChart({
|
||||
chartKey="sleep"
|
||||
types={["SLEEP_DURATION"]}
|
||||
title={t("charts.sleep")}
|
||||
colors={["#8be9fd"]}
|
||||
colors={["var(--info)"]}
|
||||
unit="h"
|
||||
yAxisUnit="h"
|
||||
compareBaseline={compareBaseline}
|
||||
|
||||
@@ -89,11 +89,11 @@ export const STAGE_ORDER = ["DEEP", "REM", "CORE", "ASLEEP", "AWAKE"] as const;
|
||||
* charts-visual-identity rule, no token reshuffle.
|
||||
*/
|
||||
export const STAGE_COLORS: Record<string, string> = {
|
||||
DEEP: "#bd93f9", // dracula-purple — deepest, most restorative
|
||||
REM: "#ff79c6", // dracula-pink — dream phase
|
||||
CORE: "#8be9fd", // dracula-cyan — bulk of sleep
|
||||
ASLEEP: "#50fa7b", // dracula-green — legacy iOS 15- unspecified
|
||||
AWAKE: "#f1fa8c", // dracula-yellow — wake bouts
|
||||
DEEP: "var(--chart-1)", // dracula-purple — deepest, most restorative
|
||||
REM: "var(--chart-3)", // dracula-pink — dream phase
|
||||
CORE: "var(--info)", // dracula-cyan — bulk of sleep
|
||||
ASLEEP: "var(--success)", // dracula-green — legacy iOS 15- unspecified
|
||||
AWAKE: "var(--dracula-yellow)", // dracula-yellow — wake bouts
|
||||
IN_BED: "#6272a4", // dracula-comment — pre-asleep
|
||||
};
|
||||
|
||||
|
||||
@@ -57,42 +57,42 @@ export function SleepQualitySection({ enabled }: { enabled: boolean }) {
|
||||
type: "SLEEP_SCORE",
|
||||
title: t("measurements.typeSleepScore"),
|
||||
icon: Moon,
|
||||
color: "#bd93f9",
|
||||
color: "var(--chart-1)",
|
||||
unit: t("insights.deviceScore.unitScore"),
|
||||
},
|
||||
{
|
||||
type: "SLEEP_PERFORMANCE",
|
||||
title: t("measurements.typeSleepPerformance"),
|
||||
icon: Target,
|
||||
color: "#8be9fd",
|
||||
color: "var(--info)",
|
||||
unit: "%",
|
||||
},
|
||||
{
|
||||
type: "SLEEP_EFFICIENCY",
|
||||
title: t("measurements.typeSleepEfficiency"),
|
||||
icon: Gauge,
|
||||
color: "#50fa7b",
|
||||
color: "var(--success)",
|
||||
unit: "%",
|
||||
},
|
||||
{
|
||||
type: "SLEEP_CONSISTENCY",
|
||||
title: t("measurements.typeSleepConsistency"),
|
||||
icon: Repeat,
|
||||
color: "#f1fa8c",
|
||||
color: "var(--dracula-yellow)",
|
||||
unit: "%",
|
||||
},
|
||||
{
|
||||
type: "SLEEP_NEED",
|
||||
title: t("measurements.typeSleepNeed"),
|
||||
icon: Waves,
|
||||
color: "#ffb86c",
|
||||
color: "var(--warning)",
|
||||
unit: t("insights.deviceScore.unitMinutes"),
|
||||
},
|
||||
{
|
||||
type: "SLEEP_DISTURBANCE_COUNT",
|
||||
title: t("measurements.typeSleepDisturbanceCount"),
|
||||
icon: Activity,
|
||||
color: "#ff79c6",
|
||||
color: "var(--chart-3)",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Reference in new issue
Block a user