Skip to content

fix: read system preference to prevent light theme flash on initial l…#7820

Open
desireddymohithreddy0925 wants to merge 3 commits into
JhaSourav07:mainfrom
desireddymohithreddy0925:fix/dark-mode-flash
Open

fix: read system preference to prevent light theme flash on initial l…#7820
desireddymohithreddy0925 wants to merge 3 commits into
JhaSourav07:mainfrom
desireddymohithreddy0925:fix/dark-mode-flash

Conversation

@desireddymohithreddy0925

Copy link
Copy Markdown
Contributor

Description

Fixes #7802

Previously, the inline blocking script in layout.tsx defaulted to rendering the dark theme if no theme was saved in localStorage. However, if a user's system preference was set to light mode, or vice versa, this caused a jarring flash of the wrong theme before client-side hydration corrected it.

This PR updates the <head> injection script in layout.tsx to properly read window.matchMedia('(prefers-color-scheme: dark)') during its initial synchronous execution. This ensures that the application immediately renders the correct theme matching the user's operating system preferences on their very first visit, completely eliminating the white/dark flash.

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jul 8, 2026
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 3917.41 KB 3917.41 KB 0 B
Total CSS 325.86 KB 325.86 KB 0 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Dark Mode Flash on Initial Page Load

1 participant