Skip to content

Commit 0b36178

Browse files
authored
fix: dark mode transition flash (JhaSourav07#2174)
## Description Fixes JhaSourav07#2166 ## Pillar - [ ] 🎨 Pillar 1 β€” New Theme Design - [ ] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [ ] πŸ• Pillar 3 β€” Timezone Logic Optimization - [x] πŸ› οΈ Other (Bug fix, refactoring, docs) ## Visual Preview ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [x] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 941a172 + f8a7f3d commit 0b36178

2 files changed

Lines changed: 1795 additions & 284 deletions

File tree

β€Žapp/layout.tsxβ€Ž

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,26 @@ export const metadata: Metadata = {
6666

6767
export default function RootLayout({ children }: { children: React.ReactNode }) {
6868
return (
69-
<html lang="en">
70-
<body className={`${inter.className} bg-black`}>
69+
<html lang="en" suppressHydrationWarning>
70+
<head>
71+
<script
72+
dangerouslySetInnerHTML={{
73+
__html: `
74+
try {
75+
const storedTheme = window.localStorage.getItem('theme');
76+
if (storedTheme === 'light') {
77+
document.documentElement.classList.remove('dark');
78+
document.documentElement.style.colorScheme = 'light';
79+
} else {
80+
document.documentElement.classList.add('dark');
81+
document.documentElement.style.colorScheme = 'dark';
82+
}
83+
} catch (_) {}
84+
`,
85+
}}
86+
/>
87+
</head>
88+
<body className={inter.className}>
7189
<ScrollRestoration />
7290
<BrandParticles />
7391
<Navbar />

0 commit comments

Comments
Β (0)