Add dark/light mode toggle with adaptive badge colors

Implement theme switching via sun/moon toggle in nav bar. Dark
remains the default; light mode overrides surface, text, border,
accent, and status color tokens. Preference persists in localStorage
and falls back to prefers-color-scheme. An inline script in
index.html prevents flash of wrong theme on load.

Define a Tailwind v4 @custom-variant for light mode and update all
badge components (encounter method, rule, condition) to use
light:bg-{color}-100 / light:text-{color}-700 for readable contrast
on light surfaces.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-20 19:45:12 +01:00
parent cb35bf161e
commit a381633413
8 changed files with 224 additions and 22 deletions

View File

@@ -68,6 +68,49 @@
--color-status-failed-bg: rgba(248, 81, 73, 0.15);
}
@custom-variant light (&:where([data-theme="light"], [data-theme="light"] *));
/* ── Light mode overrides ─────────────────────────────────────── */
html[data-theme='light'] {
color-scheme: light;
/* Surfaces */
--color-surface-0: #ffffff;
--color-surface-1: #f6f8fa;
--color-surface-2: #eef1f4;
--color-surface-3: #d8dee4;
--color-surface-4: #ced5dc;
/* Accent (darkened for text contrast on light surfaces) */
--color-accent-200: #245f7e;
--color-accent-300: #1a5068;
--color-accent-400: #2d6a89;
/* Text */
--color-text-primary: #1f2328;
--color-text-secondary: #656d76;
--color-text-tertiary: #8b949e;
--color-text-link: #1a5068;
/* Borders */
--color-border-default: rgba(0, 0, 0, 0.15);
--color-border-muted: rgba(0, 0, 0, 0.08);
--color-border-accent: rgba(57, 94, 115, 0.35);
/* Status (adjusted for light surfaces) */
--color-status-alive: #1a7f37;
--color-status-alive-bg: rgba(26, 127, 55, 0.1);
--color-status-dead: #cf222e;
--color-status-dead-bg: rgba(207, 34, 46, 0.1);
--color-status-active: #1a7f37;
--color-status-active-bg: rgba(26, 127, 55, 0.1);
--color-status-completed: #0969da;
--color-status-completed-bg: rgba(9, 105, 218, 0.1);
--color-status-failed: #cf222e;
--color-status-failed-bg: rgba(207, 34, 46, 0.1);
}
/* ── Base layer ────────────────────────────────────────────────── */
@layer base {