DEV Community

Discussion on: 🌙 How I set Dark Mode for Gatsby website

Collapse
 
amaltapalov profile image
Amal Tapalov • Edited

Some devs prefered write this way, some people use checked property. There is always a place to play with code. Everybody chooses what they prefer. Piece!

Example code:

<input
    id="theme-mode"
    type="checkbox"
    checked={theme === 'dark'}
    onChange={e => {
    window.__setPreferredTheme(e.target.checked ? 'dark' : 'light')
   }}
/>        
Collapse
 
deathshadow60 profile image
deathshadow60

Again, not JavaScript's job if you can avoid it, since you're alienating large swaths of users. Much less onEvent attributes being relics of two decades ago that should have been axed at that time...

... and using some rubbish framework or pre-processor to do "templates" with it doesn't fix that. If anything, it simply proves that people are throwing JavaScript client-side in ways that are NONE of JavaScript's flipping business.

See 90%+ of what people do with mentally enfeebled trash like React or jQuery... the stuff I have to rip out in my day job of sites in court for WCAG violations!

Thread Thread
 
amaltapalov profile image
Amal Tapalov • Edited

So much pain is in the comment above 😀
Thanks for WCAG reference