import type { HeatmapColorScheme } from "~/hooks/useAppPreferences.js"; // ─── Heatmap colour palettes ─────────────────────────────────────────────────── // Each palette is [minPct, overlayRgba, barRgba] — overlay is semi-transparent // (for heatmap mode strips), bar is more opaque (for bar-mode project view). export const HEATMAP_PALETTES: Record = { "green-red": [ [0, "rgba(34,197,94,0.18)", "rgba(34,197,94,0.70)"], [25, "rgba(132,204,22,0.25)", "rgba(132,204,22,0.75)"], [50, "rgba(250,204,21,0.32)", "rgba(250,204,21,0.80)"], [75, "rgba(249,115,22,0.40)", "rgba(249,115,22,0.82)"], [90, "rgba(239,68,68,0.48)", "rgba(239,68,68,0.85)"], [100, "rgba(185,28,28,0.58)", "rgba(185,28,28,0.88)"], [125, "rgba(109,40,217,0.64)", "rgba(109,40,217,0.88)"], ], "blue-orange": [ [0, "rgba(56,189,248,0.22)", "rgba(56,189,248,0.70)"], [25, "rgba(59,130,246,0.28)", "rgba(59,130,246,0.75)"], [50, "rgba(251,191,36,0.35)", "rgba(251,191,36,0.80)"], [75, "rgba(249,115,22,0.42)", "rgba(249,115,22,0.82)"], [90, "rgba(239,68,68,0.50)", "rgba(239,68,68,0.85)"], [100, "rgba(185,28,28,0.58)", "rgba(185,28,28,0.88)"], [125, "rgba(109,40,217,0.64)", "rgba(109,40,217,0.88)"], ], "purple-yellow": [ [0, "rgba(167,139,250,0.22)", "rgba(167,139,250,0.70)"], [25, "rgba(139,92,246,0.28)", "rgba(139,92,246,0.75)"], [50, "rgba(250,204,21,0.35)", "rgba(250,204,21,0.80)"], [75, "rgba(245,158,11,0.42)", "rgba(245,158,11,0.82)"], [90, "rgba(239,68,68,0.50)", "rgba(239,68,68,0.85)"], [100, "rgba(185,28,28,0.58)", "rgba(185,28,28,0.88)"], [125, "rgba(109,40,217,0.64)", "rgba(109,40,217,0.88)"], ], "mono": [ [0, "rgba(156,163,175,0.18)", "rgba(156,163,175,0.60)"], [25, "rgba(107,114,128,0.25)", "rgba(107,114,128,0.68)"], [50, "rgba(75,85,99,0.30)", "rgba(75,85,99,0.74)"], [75, "rgba(55,65,81,0.36)", "rgba(55,65,81,0.80)"], [90, "rgba(31,41,55,0.42)", "rgba(31,41,55,0.85)"], [100, "rgba(17,24,39,0.52)", "rgba(17,24,39,0.88)"], [125, "rgba(0,0,0,0.60)", "rgba(0,0,0,0.90)"], ], }; // pct = (totalHoursPerDay / 8) * 100. Returns rgba string or null for 0%. // mode: "overlay" for heatmap strips, "bar" for solid bar fill. export function heatmapColor(pct: number, scheme: HeatmapColorScheme, mode: "overlay" | "bar" = "overlay"): string | null { if (pct <= 0) return null; const palette = HEATMAP_PALETTES[scheme] ?? HEATMAP_PALETTES["green-red"]; let entry = palette[0]!; for (const row of palette) { if (pct > row[0]) entry = row; else break; } return mode === "bar" ? entry[2] : entry[1]; } // Legacy alias used by heatmap overlay (overlay mode, green-red default) export function heatmapBgColor(pct: number, scheme: HeatmapColorScheme = "green-red"): string | null { return heatmapColor(pct, scheme, "overlay"); }