Remove the dark-mode thing
This commit is contained in:
parent
c3bf9b61dd
commit
e05ad9372b
1 changed files with 0 additions and 16 deletions
|
@ -1,16 +0,0 @@
|
|||
function setupDarkMode() {
|
||||
const bodyClasses = document.body.classList;
|
||||
const systemDarkModeMatch = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
const localStorageDarkMode = localStorage.getItem('dark');
|
||||
|
||||
const setDark = isDark => {
|
||||
bodyClasses[isDark ? 'add' : 'remove']('dark');
|
||||
localStorage.setItem('dark', isDark ? 'yes' : 'no');
|
||||
};
|
||||
|
||||
setDark(localStorageDarkMode ? localStorageDarkMode === 'yes' : systemDarkModeMatch.matches);
|
||||
requestAnimationFrame(() => bodyClasses.remove('not-ready'));
|
||||
systemDarkModeMatch.addEventListener('change', (event) => setDark(event.matches));
|
||||
}
|
||||
|
||||
document.addEventListener("load", setupDarkMode);
|
Loading…
Add table
Add a link
Reference in a new issue