Skip to content

Commit dea024a

Browse files
committed
style: implement elegant dark mode and dynamic palette rotation
1 parent 0507caa commit dea024a

2 files changed

Lines changed: 53 additions & 9 deletions

File tree

src/App.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ const MotionA = motion.a as React.FC<React.AnchorHTMLAttributes<HTMLAnchorElemen
3232
children?: React.ReactNode;
3333
}>;
3434

35+
const PALETTES = [
36+
{ a1: '#f472b6', a2: '#818cf8', a3: '#2dd4bf' }, // Cyberpunk
37+
{ a1: '#34d399', a2: '#60a5fa', a3: '#fbbf24' }, // Forest
38+
{ a1: '#a78bfa', a2: '#fb7185', a3: '#38bdf8' }, // Royal
39+
{ a1: '#fcd34d', a2: '#f87171', a3: '#c084fc' }, // Candy
40+
];
41+
3542
// Theme Toggle Component
3643
const ThemeToggle = () => {
3744
const [isDark, setIsDark] = useState(() => {
@@ -43,8 +50,21 @@ const ThemeToggle = () => {
4350
});
4451

4552
useEffect(() => {
46-
document.documentElement.setAttribute('data-theme', isDark ? 'dark' : 'light');
53+
const root = document.documentElement;
54+
root.setAttribute('data-theme', isDark ? 'dark' : 'light');
4755
localStorage.setItem('theme', isDark ? 'dark' : 'light');
56+
57+
if (isDark) {
58+
const palette = PALETTES[Math.floor(Math.random() * PALETTES.length)];
59+
root.style.setProperty('--accent-1', palette.a1);
60+
root.style.setProperty('--accent-2', palette.a2);
61+
root.style.setProperty('--accent-3', palette.a3);
62+
} else {
63+
// Reset to default neobrutalist bright colors in light mode
64+
root.style.removeProperty('--accent-1');
65+
root.style.removeProperty('--accent-2');
66+
root.style.removeProperty('--accent-3');
67+
}
4868
}, [isDark]);
4969

5070
return (

src/index.css

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
:root {
2-
--bg: #f0f0f0;
2+
--bg: #f8f9fa;
33
--fg: #1a1a1a;
44
--accent-1: #ff6b6b;
55
--accent-2: #4ecdc4;
@@ -8,17 +8,41 @@
88
--border: #000000;
99
--shadow: #000000;
1010
--font-main: 'Inter', system-ui, -apple-system, sans-serif;
11+
--accent-rgb-1: 255, 107, 107;
1112
}
1213

1314
[data-theme="dark"] {
14-
--bg: #1a1a1a;
15-
--fg: #f0f0f0;
16-
--accent-1: #ff6b6b;
17-
--accent-2: #4ecdc4;
18-
--accent-3: #ffe66d;
19-
--card-bg: #2d2d2d;
20-
--border: #f0f0f0;
15+
--bg: #0a0a0a;
16+
--fg: #e5e7eb;
17+
--card-bg: #111111;
18+
--border: #262626;
2119
--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 */
27+
}
28+
29+
[data-theme="dark"] .prose code {
30+
background: #1f1f1f;
31+
border: 1px solid #333;
32+
}
33+
34+
[data-theme="dark"] .prose pre {
35+
background: #000000;
36+
border-color: var(--border);
37+
box-shadow: 4px 4px 0 #000;
38+
}
39+
40+
[data-theme="dark"] .prose blockquote {
41+
background: rgba(255, 255, 255, 0.03);
42+
}
43+
44+
[data-theme="dark"] .bento-item:hover {
45+
border-color: var(--accent-1);
2246
}
2347

2448
* {

0 commit comments

Comments
 (0)