Skip to content
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

Store Dark Mode preferences in Local Storage #194

Closed
deadcoder0904 opened this issue Jun 18, 2020 · 13 comments
Closed

Store Dark Mode preferences in Local Storage #194

deadcoder0904 opened this issue Jun 18, 2020 · 13 comments

Comments

@deadcoder0904
Copy link

Otherwise I have to constantly switch dark mode on every article I click :)

@franky47
Copy link
Contributor

This would cause a FOUC (flash of unthemed content) when loading the website, which may not be desirable. Dark mode should stick around for local navigation between articles however, and only reset to light mode when reloading the page.

FYI, the upcoming TypeScript release of ChakraUI is supposed to solve those FOUC colorMode issues.

@deadcoder0904
Copy link
Author

It wasn't working because I started binge-reading his articles bcz there were so good. And I have a habit of opening in New Tab so it didn't work.

It works while navigating as it should :)

@leerob
Copy link
Owner

leerob commented Jun 24, 2020

It turns out that dark mode is pretty tricky when using CSS-in-JS. To properly implement in, you likely need to use CSS variables as well.

https://joshwcomeau.com/gatsby/dark-mode/
chakra-ui/chakra-ui#349 (comment)

@deadcoder0904
Copy link
Author

Yep already read Josh’s blog post & opened up an issue on Chakra UI a few days ago too. Not sure it’s solvable with Chakra chakra-ui/chakra-ui#908 (comment)

@sarthaktexas
Copy link

can we make it so it gets system setting for dark/light mode? i'm having to set it to dark mode every time i open it up.

@deadcoder0904
Copy link
Author

@sarthaktexas ohh yeah i think that might work as chakra provides an option now with preferred-color-scheme

@sarthaktexas
Copy link

yup! should I make a pull request?

@leerob
Copy link
Owner

leerob commented Sep 19, 2020

@sarthaktexas I believe that will require updating Chakra to v1 – if you're open to that, I'd love assistance!

@rodmansw
Copy link

rodmansw commented Oct 1, 2020

@leerob Actually I don't think you need to do that, let me see what can I do

@leerob
Copy link
Owner

leerob commented Oct 1, 2020

@Rodman-Sw My point is that you shouldn't need to do anything custom once you upgrade to Chakra v1. Since I will be doing that eventually, I'd prefer to stick with that rather than something custom. Does that make sense?

https://next.chakra-ui.com

@AkashRajpurohit
Copy link
Contributor

Hey @leerob I recently build a project with Next and Chakra UI with v1.0, today I just pushed the persisting of color mode on my project Github Emojis. If you are planning to upgrade Chakra-UI to 1.0, Do you mind I if try to implement the similar on leerob.io as well?

@leerob
Copy link
Owner

leerob commented Oct 11, 2020

Yeah, I'd love help migrating to v1! @AkashRajpurohit

@leerob
Copy link
Owner

leerob commented Dec 5, 2020

Fixed here -> #239

@leerob leerob closed this as completed Dec 5, 2020
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

No branches or pull requests

6 participants