Merge branch 'master' of github.com:piharpi/jekyll-klise

This commit is contained in:
Mahendrata Harpi
2020-11-21 09:35:16 +07:00
9 changed files with 115 additions and 29 deletions

View File

@@ -2,17 +2,6 @@
// Theme switch
const body = document.body;
const lamp = document.getElementById("mode");
const data = body.getAttribute("data-theme");
const initTheme = (state) => {
if (state === "dark") {
body.setAttribute("data-theme", "dark");
} else if (state === "light") {
body.removeAttribute("data-theme");
} else {
localStorage.setItem("theme", data);
}
};
const toggleTheme = (state) => {
if (state === "dark") {
@@ -26,8 +15,6 @@
}
};
initTheme(localStorage.getItem("theme"));
lamp.addEventListener("click", () =>
toggleTheme(localStorage.getItem("theme"))
);