fix: read system preference to prevent light theme flash on initial l…#7820
Open
desireddymohithreddy0925 wants to merge 3 commits into
Open
fix: read system preference to prevent light theme flash on initial l…#7820desireddymohithreddy0925 wants to merge 3 commits into
desireddymohithreddy0925 wants to merge 3 commits into
Conversation
…oad for dark mode users
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. |
…tead of md: to fix CI
Contributor
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #7802
Previously, the inline blocking script in
layout.tsxdefaulted to rendering the dark theme if no theme was saved inlocalStorage. 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 inlayout.tsxto properly readwindow.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
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.