Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-05-21 - [Theme Switching Robustness]
**Learning:** Using Tailwind utility classes like `dark:bg-black` for the root body background can be fragile if the dark mode toggle mechanism or configuration (`darkMode: "class"`) has subtle mismatches. Using CSS variables (`bg-[var(--background)]`) that are scoped in `:root` and `.dark` blocks is more robust because it relies on standard CSS inheritance, ensuring the background color always matches the active theme class on the document root. Also, adding `color-scheme: dark` is critical for native UI elements (scrollbars) to match.
**Action:** When implementing dark mode, always define `color-scheme` in CSS and prefer CSS variables for the main background to avoid "flash" or mismatch issues.
2 changes: 2 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@

/* Base styles */
:root {
color-scheme: light;
--background: #f6f6f8;
--foreground: #0f172a;
}

.dark {
color-scheme: dark;
--background: #000000;
--foreground: #ffffff;
}
Expand Down
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function RootLayout({
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap" rel="stylesheet" />
</head>
<body className="bg-background-light dark:bg-[var(--color-background-dark)] text-slate-900 dark:text-white font-display overflow-x-hidden antialiased selection:bg-primary selection:text-white">
<body className="bg-[var(--background)] text-slate-900 dark:text-white font-display overflow-x-hidden antialiased selection:bg-primary selection:text-white">
<Providers>
{children}
</Providers>
Expand Down
1 change: 1 addition & 0 deletions components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function Sidebar() {

<button
onClick={toggleTheme}
aria-label="Toggle theme"
className="flex items-center gap-3 rounded-lg px-4 py-3 text-slate-500 hover:bg-slate-100 hover:text-slate-900 dark:text-text-secondary dark:hover:bg-surface-dark-lighter dark:hover:text-white transition-colors w-full text-left"
>
<span className={`material-symbols-outlined ${!mounted ? 'invisible' : ''}`}>
Expand Down