20 lines
No EOL
721 B
JavaScript
20 lines
No EOL
721 B
JavaScript
const $ = x => Array.from(document.querySelectorAll(x));
|
|
const $$ = x => Array.from(document.querySelector(x));
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const themeToggleBtn = document.getElementById('theme-toggle-btn');
|
|
if (themeToggleBtn) {
|
|
themeToggleBtn.addEventListener('click', function() {
|
|
const root = document.documentElement;
|
|
if (root.classList.contains("dark")) {
|
|
root.classList.remove("dark");
|
|
root.setAttribute("data-theme", "light");
|
|
localStorage.setItem("theme", "light");
|
|
} else {
|
|
root.classList.add("dark");
|
|
root.setAttribute("data-theme", "dark");
|
|
localStorage.setItem("theme", "dark");
|
|
}
|
|
});
|
|
}
|
|
}); |