Skip to content

Commit a10a561

Browse files
committed
style: implement global accent shading for dark mode using color-mix
1 parent 09b11f6 commit a10a561

2 files changed

Lines changed: 22 additions & 17 deletions

File tree

src/App.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ const ThemeToggle = () => {
6363

6464
if (isDark) {
6565
const palette = PALETTES[Math.floor(Math.random() * PALETTES.length)];
66-
root.style.setProperty('--accent-1', palette.a1);
67-
root.style.setProperty('--accent-2', palette.a2);
68-
root.style.setProperty('--accent-3', palette.a3);
66+
root.style.setProperty('--raw-accent-1', palette.a1);
67+
root.style.setProperty('--raw-accent-2', palette.a2);
68+
root.style.setProperty('--raw-accent-3', palette.a3);
6969
} else {
7070
// Reset to default neobrutalist bright colors in light mode
71-
root.style.removeProperty('--accent-1');
72-
root.style.removeProperty('--accent-2');
73-
root.style.removeProperty('--accent-3');
71+
root.style.removeProperty('--raw-accent-1');
72+
root.style.removeProperty('--raw-accent-2');
73+
root.style.removeProperty('--raw-accent-3');
7474
}
7575
}, [isDark]);
7676

src/index.css

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
:root {
22
--bg: #f8f9fa;
33
--fg: #1a1a1a;
4-
--accent-1: #ff6b6b;
5-
--accent-2: #4ecdc4;
6-
--accent-3: #ffe66d;
4+
/* Default accent values */
5+
--raw-accent-1: #ff6b6b;
6+
--raw-accent-2: #4ecdc4;
7+
--raw-accent-3: #ffe66d;
8+
9+
/* In light mode, accents are 100% vibrant */
10+
--accent-1: var(--raw-accent-1);
11+
--accent-2: var(--raw-accent-2);
12+
--accent-3: var(--raw-accent-3);
13+
714
--card-bg: #ffffff;
815
--border: #000000;
916
--shadow: #000000;
1017
--font-main: 'Inter', system-ui, -apple-system, sans-serif;
11-
--accent-rgb-1: 255, 107, 107;
1218
}
1319

1420
[data-theme="dark"] {
@@ -17,13 +23,12 @@
1723
--card-bg: #111111;
1824
--border: #262626;
1925
--shadow: #000000;
20-
/* Dynamic accents will override these */
21-
--accent-1: #6366f1;
22-
/* Indigo */
23-
--accent-2: #10b981;
24-
/* Emerald */
25-
--accent-3: #f59e0b;
26-
/* Amber */
26+
27+
/* Toning down accents for dark mode: mixed with 20% background to "shade" them */
28+
/* This makes them feel less "neon" and more integrated into the dark theme */
29+
--accent-1: color-mix(in srgb, var(--raw-accent-1), var(--bg) 25%);
30+
--accent-2: color-mix(in srgb, var(--raw-accent-2), var(--bg) 25%);
31+
--accent-3: color-mix(in srgb, var(--raw-accent-3), var(--bg) 25%);
2732
}
2833

2934
[data-theme="dark"] .prose code {

0 commit comments

Comments
 (0)