User avatar
Jeder neocat_floof_googly_woozy neocat_flag_agender 🔜 eth0 @jeder@miau.jeder.pl
2y
meow
how the fuck do you do a very simple theme switch for web

possbly 0 js lines or lower
if not, 20 max
2
0
1
0

User avatar
-> @kopper@wetdry.world @kopper@brain.d.on-t.work
2y
@jeder depends on what you mean by theme switch. if it's just light/dark or high/low contrast there's a css property to handle it with the system theme which can do 0 js

otherwise i imagine it'd be as simple as adding/removing a class in the html or body tag (and writing your css to depend on that class existing), which shouldn't be more than 10 lines of js unless you have a lot of themes
1
0
1
0
User avatar
ruby @sk@catcatnya.com
2y
@kopper @jeder but then, if you implement it with a simple css class, the automatic, system-defined @media (prefers-color-scheme: dark) media query won't work without extra effort (you'd have to think something up that supports automatic/light/dark..)
1
0
1
0
User avatar
ruby @sk@catcatnya.com
2y
@kopper @jeder tbh i'd love to see an elegant and simple solution for this
1
0
1
0
User avatar
-> @kopper@wetdry.world @kopper@brain.d.on-t.work
2y
@sk @jeder you can use js to detect media changes and add a class but yeah this doesn't work without js.

if it was an attribute or a :psuedo-class or something instead of a media query you could do an html:is(:dark, .dark) or something but that's not the case, unfortunately
1
0
0
0
User avatar
ruby @sk@catcatnya.com
2y
@kopper @jeder true, :is(:dark, .dark) looks like it would be an elegant pattern...
0
0
1
0
User avatar
Jeder neocat_floof_googly_woozy neocat_flag_agender 🔜 eth0 @jeder@miau.jeder.pl
2y
can't be arsed
anyway
my website now has a light mode
you need to change system theme but like, Whatever
1
0
0
0
User avatar
Jeder neocat_floof_googly_woozy neocat_flag_agender 🔜 eth0 @jeder@miau.jeder.pl
2y
not sure if my use of display: none is halal but whatever
0
0
0
0