Add files via upload

This commit is contained in:
Alexander David Frick 2022-05-28 05:10:35 -05:00 committed by GitHub
parent 37a256934e
commit 5dba2c2c9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

21
website/js/dark.js Normal file
View file

@ -0,0 +1,21 @@
// Dark mode and local storage preference
function toggleDarkMode(useDark) {
if (useDark) {
document.documentElement.classList.add('dark');
document.documentElement.classList.remove('light');
}
else {
document.documentElement.classList.remove('dark');
document.documentElement.classList.add('light');
}
}
let useDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (!useDark && localStorage.getItem('dark-mode') === 'true') {
useDark = true;
toggleDarkMode(useDark);
}
else if (localStorage.getItem('dark-mode') === 'false') {
useDark = false;
toggleDarkMode(useDark);
}