elyday.dev/assets/js/main.js
elyday 0764cfc61d Add base files for new Jekyll site setup
Introduced initial setup for a Jekyll-based site, including configurations, layouts, assets, and styles. Added custom 404 page, favicon assets, SCSS themes, fonts, and a blog post template to establish the foundation for the site.
2024-12-23 00:16:48 +01:00

31 lines
835 B
JavaScript

(() => {
// Theme switch
const body = document.body;
const lamp = document.getElementById("mode");
const toggleTheme = (state) => {
if (state === "dark") {
localStorage.setItem("theme", "light");
body.removeAttribute("data-theme");
} else if (state === "light") {
localStorage.setItem("theme", "dark");
body.setAttribute("data-theme", "dark");
} else {
initTheme(state);
}
};
lamp.addEventListener("click", () =>
toggleTheme(localStorage.getItem("theme"))
);
// Blur the content when the menu is open
const cbox = document.getElementById("menu-trigger");
cbox.addEventListener("change", function () {
const area = document.querySelector(".wrapper");
this.checked
? area.classList.add("blurry")
: area.classList.remove("blurry");
});
})();