4 ms·
Fix incoming . I'm using local storage to maintain the "dark mode" choice and it can't be accessed if cookies are blocked.
by obedm 6y ago
Fix incoming . I'm using local storage to maintain the "dark mode" choice and it can't be accessed if cookies are blocked.
- Etheryte 6y agoThanks a lot for the quick update, really appreciate it. Works well now.
- IshKebab 6y agoYou can do dark mode purely in CSS. No need to code an explicit choice in your site.
- mikewhy 6y agoBut the point of coding the choice is ... so the user has a choice? This is a bizarre response.
- mcintyre1994 6y agoI 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/prefers-color-scheme https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pref...
- satvikpendem 6y agoYes 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.
- mikewhy 6y agoI'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.
- adrianmsmith 6y agoMay 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?
- mountainboot 6y agoNot me, I like both modes. Often I will have one text editor in dark mode and another in light mode.
- dnissley 6y agoSometimes one implementation or the other just plain sucks -- typically it's bad dark mode implementations that obviously were just afterthoughts.
- mikewhy 6y agoSome 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.
- obedm 6y agoAs 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.
- satvikpendem 6y agoYou can make a pure CSS theme toggle as well. You can even use SVG to do it with a custom animation. https://codepen.io/demilad/pen/bZRjpb https://codepen.io/demilad/pen/bZRjpb
- obedm 6y agoThe 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 :)