Add dark mode based on device color-scheme preference

Move the color palette into CSS custom properties (:root in
globals.scss) with a prefers-color-scheme: dark override, and point the
existing $color-* Sass variables at them so every component picks up
dark mode automatically. Replaced the handful of rgba($color, alpha)
call sites with color-mix(), since Sass can't alpha-blend a color that's
now a CSS variable at compile time.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-13 19:33:31 +02:00
co-authored by Claude Sonnet 5
parent a716080f7d
commit 370e77f1a6
4 changed files with 45 additions and 13 deletions
+2 -2
View File
@@ -14,10 +14,10 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: $space-3; padding: $space-3;
background: rgba($color-background, 0.3); background: color-mix(in srgb, $color-background 30%, transparent);
backdrop-filter: blur(12px); backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
border-bottom: 1px solid rgba($color-border, 0.3); border-bottom: 1px solid color-mix(in srgb, $color-border 30%, transparent);
} }
.brand { .brand {
+2 -2
View File
@@ -93,12 +93,12 @@
} }
.statusIdle { .statusIdle {
background: rgba($color-success, 0.12); background: color-mix(in srgb, $color-success 12%, transparent);
color: $color-success; color: $color-success;
} }
.statusBusy { .statusBusy {
background: rgba($color-primary, 0.12); background: color-mix(in srgb, $color-primary 12%, transparent);
color: $color-primary; color: $color-primary;
} }
+13 -9
View File
@@ -1,12 +1,16 @@
$color-text: #1a1a1a; // These resolve to the CSS custom properties defined in globals.scss, which
$color-text-muted: #6b6b6b; // swap values under `prefers-color-scheme: dark` — keep referencing them by
$color-background: #ffffff; // these names rather than hardcoding hex so components pick up dark mode
$color-surface: #f7f7f5; // automatically.
$color-border: #e2e0dc; $color-text: var(--color-text);
$color-primary: #b5432b; $color-text-muted: var(--color-text-muted);
$color-primary-contrast: #ffffff; $color-background: var(--color-background);
$color-danger: #a33; $color-surface: var(--color-surface);
$color-success: #2f7a4f; $color-border: var(--color-border);
$color-primary: var(--color-primary);
$color-primary-contrast: var(--color-primary-contrast);
$color-danger: var(--color-danger);
$color-success: var(--color-success);
$space-1: 0.25rem; $space-1: 0.25rem;
$space-2: 0.5rem; $space-2: 0.5rem;
+28
View File
@@ -1,5 +1,33 @@
@use './variables' as *; @use './variables' as *;
:root {
--color-text: #1a1a1a;
--color-text-muted: #6b6b6b;
--color-background: #ffffff;
--color-surface: #f7f7f5;
--color-border: #e2e0dc;
--color-primary: #b5432b;
--color-primary-contrast: #ffffff;
--color-danger: #a33333;
--color-success: #2f7a4f;
color-scheme: light;
}
@media (prefers-color-scheme: dark) {
:root {
--color-text: #f2ede6;
--color-text-muted: #a89e8f;
--color-background: #16130f;
--color-surface: #201c17;
--color-border: #3a342a;
--color-primary: #d9694a;
--color-primary-contrast: #ffffff;
--color-danger: #ef6b62;
--color-success: #4fbb7c;
color-scheme: dark;
}
}
*, *,
*::before, *::before,
*::after { *::after {