Initial commit

This commit is contained in:
mivinci 2021-07-18 16:34:01 +08:00
commit 063f2bb49a
34 changed files with 1341 additions and 0 deletions

18
static/js/main.js Normal file
View file

@ -0,0 +1,18 @@
window.addEventListener('DOMContentLoaded', function () {
const light = '🌝', dark = '🌚';
const LIGHT = 'light', DARK = 'dark';
const themeSwitcher = document.getElementById('theme-switcher');
themeSwitcher.innerHTML = localStorage.theme === LIGHT ? light : dark;
themeSwitcher.addEventListener('click', function () {
const currentTheme = localStorage.theme,
newTheme = currentTheme === LIGHT ? DARK : LIGHT,
{ classList } = document.querySelector('html'),
text = newTheme === LIGHT ? light : dark;
classList.remove(currentTheme);
classList.add(newTheme);
localStorage.theme = newTheme;
themeSwitcher.innerHTML = text;
})
});