Files
website-v2/static/js/DetectMode.js
Greg Newman f009e91019 🚜 WIP light/dark mode
Hooked up light and dark mode to the nav.
In addition to changing the content colors the logo is swapped based on mode.
2023-04-26 11:19:39 -04:00

16 lines
551 B
JavaScript

let explicitelyPreferScheme = false;
if (window.localStorage) {
if (localStorage.getItem('colorMode') === 'dark') {
document.documentElement.classList.add('dark');
explicitelyPreferScheme = 'dark';
} else if (localStorage.getItem('colorMode') === 'light') {
document.documentElement.classList.remove('dark');
explicitelyPreferScheme = 'light';
}
}
if (explicitelyPreferScheme !== 'light' && window.matchMedia('(prefers-color-scheme:dark)').matches) {
document.documentElement.classList.add('dark');
}