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-22 - Theme Switching FOUC
**Learning:** Next.js app router with Tailwind class-based dark mode requires a script in head to prevent FOUC, even if using a ThemeProvider.
**Action:** Always inject a script to set document class before hydration when implementing dark mode.
4 changes: 2 additions & 2 deletions app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function Dashboard() {
}

return (
<div className="flex h-screen w-full overflow-hidden bg-slate-50 dark:bg-background-dark">
<div className="flex h-screen w-full overflow-hidden bg-background-light dark:bg-background-dark">
{/* Tutorial Overlay */}
{showTutorial && session?.user?.email && (
<TutorialOverlay
Expand All @@ -133,7 +133,7 @@ export default function Dashboard() {


{/* Main Content */}
<main className="flex flex-1 flex-col overflow-y-auto bg-slate-50 dark:bg-background-dark">
<main className="flex flex-1 flex-col overflow-y-auto bg-background-light dark:bg-background-dark">
{/* Floating Header */}
<header className="sticky top-4 z-20 mx-4 mb-4 flex h-16 items-center justify-between rounded-2xl border border-slate-200 bg-white/80 px-6 backdrop-blur-md shadow-sm dark:border-white/5 dark:bg-[#131118]/80 transition-all">
<div className="flex items-center gap-4 md:hidden">
Expand Down
13 changes: 13 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ export default function RootLayout({
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
<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" />
<script
dangerouslySetInnerHTML={{
__html: `
try {
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
} catch (_) {}
`,
}}
/>
</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">
<Providers>
Expand Down
2 changes: 1 addition & 1 deletion app/resources/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const resources = [
export default function Resources() {
const { t } = useLanguage()
return (
<div className="flex min-h-screen w-full bg-slate-50 dark:bg-background-dark">
<div className="flex min-h-screen w-full bg-background-light dark:bg-background-dark">
<Sidebar />
<main className="flex-1 p-8">
<div className="max-w-4xl mx-auto w-full">
Expand Down
2 changes: 1 addition & 1 deletion app/study/explanation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default function SmartExplanation() {
}

return (
<div className="flex h-screen bg-slate-50 dark:bg-[#0a0a0c]">
<div className="flex h-screen bg-background-light dark:bg-background-dark">
<Sidebar />

<main className="flex-1 flex flex-col h-screen overflow-hidden relative">
Expand Down