Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by obedm on Friday May 29, 2020 @09:21AM
(#23349645)
Fix incoming . I'm using local storage to maintain the "dark mode" choice and it can't be accessed if cookies are blocked.
[ Parent
| on HN ]
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by Etheryte on Friday May 29, 2020 @09:30AM
(#23349754)
Thanks a lot for the quick update, really appreciate it. Works well now.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by IshKebab on Friday May 29, 2020 @09:37AM
(#23349822)
You can do dark mode purely in CSS. No need to code an explicit choice in your site.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by mikewhy on Friday May 29, 2020 @10:13AM
(#23350169)
But the point of coding the choice is ... so the user has a choice? This is a bizarre response.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by mcintyre1994 on Friday May 29, 2020 @10:27AM
(#23350302)
I think they mean using CSS `prefers-color-scheme` the user can set a light/dark preference at the browser level and your site doesn't have to have its own implementation. https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pref...
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by satvikpendem on Friday May 29, 2020 @10:41AM
(#23350438)
Yes but sometimes I want a choice. For example, I use the Dark Reader extension with a pure #000 background. Many dark modes use some grey or other non-black hue, which can be quite annoying, so I usually turn them to light mode and then Dark Reader can properly convert the light theme into my preferred black theme.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by mikewhy on Friday May 29, 2020 @10:43AM
(#23350470)
I'm aware of the prefers-color-scheme stuff added to browsers. AFAICT, only Firefox supports setting it at the browser level, while others will inherit from the system.
This would still remove the visitors ability to say "I want THIS SITE to be in light/dark mode", without affecting all other sites / apps on their system. This page could support reading from the browser/OS, while still giving the choice on top of that.
Again, this choice was probably implemented ... to give the user a choice.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by adrianmsmith on Friday May 29, 2020 @12:41PM
(#23352218)
May I ask (genuine question), why would anyone need a choice per site? Surely some people are “light mode” people and want everything in that mode and others are “dark mode” people?
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by mikewhy on Friday May 29, 2020 @01:25PM
(#23352814)
Some people are "light mode" people, and some are "dark mode".
Some people may not want everything to be light or dark mode. I am one of them.
Some articles may not work well with dark mode.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by obedm on Friday May 29, 2020 @01:50PM
(#23353166)
As the author of the site, I like switching between the two modes on all websites that support it.
Like someone above said, some sites implement it as an after-thought. In my case, I'm giving more love to dark-more because there are simply more nice color combinations in dark more than with white.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by mountainboot on Friday May 29, 2020 @01:06PM
(#23352558)
Not me, I like both modes. Often I will have one text editor in dark mode and another in light mode.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by dnissley on Friday May 29, 2020 @01:15PM
(#23352682)
Sometimes one implementation or the other just plain sucks -- typically it's bad dark mode implementations that obviously were just afterthoughts.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by satvikpendem on Friday May 29, 2020 @10:39AM
(#23350417)
You can make a pure CSS theme toggle as well. You can even use SVG to do it with a custom animation.
Re:A Visual Guide to React Mental Models: UseState, UseEffec...
by obedm on Friday May 29, 2020 @01:51PM
(#23353186)
The author here: indeed! I've debated myself over and over whether I should make dark mode the default, but I'll implement the "preferred theme" someone mentioned in another comment :)