-
Notifications
You must be signed in to change notification settings - Fork 368
feat(nuxt): SSR-friendly color mode preference implementation #5662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nuxt): SSR-friendly color mode preference implementation #5662
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this PR @ahmedrangel ✨
going to add @amritk to take a look at this as they did a ton of the nuxt work <3
So this does work as long as you don't mind the flash of incorrect color in the beginning as its coming from local storage. Since we are on nuxt, ideally we could set a cookie then read it on the server to get the correct color from the beginning. If you don't mind the flash we can merge this then add the cookie solution when we do SSR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sick PR
I’d tend to avoid the color flash (flashing colors aren’t great for some people), but not a super strong opinion here.
Do you see a flash while testing the PR? In my end that does not happen. If so, I thought this part would avoid it
In any case, I agree that a cookie should be used as the ideal SSR solution. If this solution is not convincing, we can close this PR. <3 |
I actually did not test it, but I know that we cannot use localStorage for SSR. That being said I don't think the SSR is quite working anymore anyway so maybe its fine. I'll test it and see 👍🏾 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep just tested and there is no flash because its not doing SSR. We'll take it for now thanks for the PR! I'll do a proper cookie fix when we fix SSR
Good! |
Problem
Currently, the nuxt module does not save the user's color mode preference when using the toggle switch, it is tied to starting with the one defined in the config.
Solution
With this PR we'll add support for saving the user's color mode preference and handle their states.
I look forward to your feedback.
Checklist
I’ve gone through the following:
pnpm changeset
).