[Theme] dark/light theme fix
This commit is contained in:
@@ -9,22 +9,23 @@ const imgs = document.getElementsByTagName("img");
|
||||
const main = document.getElementsByTagName("main")[0];
|
||||
const isMenuOpen = () => hamburger.classList.contains("open");
|
||||
const theme = window.localStorage.getItem("theme");
|
||||
const body = document.getElementsByClassName("theme")[0];
|
||||
|
||||
/* Functions */
|
||||
|
||||
const changeToDarkTheme = () => {
|
||||
body.classList = "theme dark"
|
||||
window.localStorage.setItem("theme", "dark");
|
||||
document.documentElement.classList.add("dark");
|
||||
themeBtn?.setAttribute("title", "turn the light on");
|
||||
Array.from(imgs).forEach((img) => img.src = img.src.replace("-light", "-dark"));
|
||||
Array.from(imgs).forEach((img) => {
|
||||
if (img.src.includes("-light")) img.src = img.src.replace("-light", "-dark");
|
||||
});
|
||||
}
|
||||
|
||||
const changeToLightTheme = () => {
|
||||
body.classList = "theme light"
|
||||
window.localStorage.setItem("theme", "light");
|
||||
document.documentElement.classList.remove("dark");
|
||||
themeBtn?.setAttribute("title", "turn the light off");
|
||||
Array.from(imgs).forEach((img) => img.src = img.src.replace("-dark", "-light"));
|
||||
Array.from(imgs).forEach((img) => {
|
||||
if (img.src.includes("-dark")) img.src = img.src.replace("-dark", "-light");
|
||||
});
|
||||
}
|
||||
|
||||
const closeMenu = () => {
|
||||
|
||||
Reference in New Issue
Block a user