3 ms·
I did once a simple implementation: light, dark and system. Data was stored in localstorage. The default was system and used quite of bit scss to implement. Eff
by stop50 2y ago
I did once a simple implementation: light, dark and system.
Data was stored in localstorage. The default was system and used quite of bit scss to implement.
Effectivly it consisted of 3 parts: and theming mixing that accepted the background and foreground color, an theme mixin that generated the surrounding "body.$schema" and "@media (prefers-color-scheme: $schema)" and at last an fallback block that only activated when it doesn't support prefers-color-scheme.
The javascript was pretty short not even 50 lines and no dependency.
- stop50 2y agoToday i would do it a lot different. The stages go into layers with the fallback first. The javascript would be splitted in an early part that loads the setting and an later part which does the settings change.