Disclaimer!
This is going to be a long post. I will try and assimilate all the resources and information I have on a proper dark mode implementatio...
For further actions, you may consider blocking this person and/or reporting abuse
I don't know why, but I couldn't get your js to work exactly how you have it for the first basic "JS Implementation" in conjunction with the css in your last post . I had to do some minor tweaks. Maybe I just wasnt implmementing yours right, but this is what I ended up doing.
with my css being
(EDIT: Thought it'd be helpful to include my html button)
I could of course update with other themes and pass a variable to my JS function.
Cool posts though! I still need to work through your "Native mode" section
Oh, could you tell me more? Of where it went wrong. I would be happy to help or even better if there is a bug in my code. I could fix it up 😎
Sure. Here is a pen of my implementation of your code, I'm probably just messing up the syntax. codepen.io/tateshep/pen/YzqzKxb
Here is one of what I did to make it work how I'd expect
codepen.io/tateshep/pen/dyMbdZE
🤷
Only if more people would use and understand
hsla
😍😍I know right? It's the easiest way to write colours, yet everybody still uses hex-codes for some reason... Worst part about it is, many people apparently can't even read/write hex codes and just copy-paste them around.
I don't understand hsla, and am definitely guilty of copy pasting hex codes. You've inspired me to check it out! I'd love a more logical way of doing colors than hex codes
Nice! I sure hope it makes your life easier :D
it worked! but not available on firefox :)
Yeah the support is sketchy. But it should support all modern browser versions.
caniuse.com/#feat=prefers-color-sc...
How can this be implemented in ReactJS
Since it is a native js plugin. I don't think it should in any way interfere with the React application lifecycle. Include theme.js in your index.html and make sure to call the
switchTheme()
method from your component's onClick handle.I am not a React expert, but I am sure this should work. Let me know if it doesn't I will give it a try myself ✌
Great series, will try this on my app, too.
I came here to read more about dark mode, but I stayed for the Arnold GIF.