Move javascript files from dir source to assets

This commit is contained in:
Djordje Atlialp 2019-02-22 15:21:13 +01:00
parent 702e87ed7d
commit fdd4b8ec05
No known key found for this signature in database
GPG key ID: 94FF806E6BF61DD3
4 changed files with 0 additions and 0 deletions

18
assets/js/theme.js Normal file
View file

@ -0,0 +1,18 @@
// Toggle theme
const getTheme = window.localStorage && window.localStorage.getItem("theme");
const themeToggle = document.querySelector(".theme-toggle");
const isDark = getTheme === "dark";
if (getTheme !== null) {
document.body.classList.toggle("dark-theme", isDark);
}
themeToggle.addEventListener("click", () => {
document.body.classList.toggle("dark-theme");
window.localStorage &&
window.localStorage.setItem(
"theme",
document.body.classList.contains("dark-theme") ? "dark" : "light",
);
});