[Theme] light/dark persistance
This commit is contained in:
@@ -15,6 +15,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||||||
/* Functions */
|
/* Functions */
|
||||||
|
|
||||||
const changeToDarkTheme = () => {
|
const changeToDarkTheme = () => {
|
||||||
|
window.localStorage.setItem("theme", "dark");
|
||||||
document.documentElement.classList.add("dark");
|
document.documentElement.classList.add("dark");
|
||||||
themeBtn?.setAttribute("title", "turn the light on");
|
themeBtn?.setAttribute("title", "turn the light on");
|
||||||
Array.from(imgs).forEach((img) => {
|
Array.from(imgs).forEach((img) => {
|
||||||
@@ -23,6 +24,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const changeToLightTheme = () => {
|
const changeToLightTheme = () => {
|
||||||
|
window.localStorage.setItem("theme", "light");
|
||||||
document.documentElement.classList.remove("dark");
|
document.documentElement.classList.remove("dark");
|
||||||
themeBtn?.setAttribute("title", "turn the light off");
|
themeBtn?.setAttribute("title", "turn the light off");
|
||||||
Array.from(imgs).forEach((img) => {
|
Array.from(imgs).forEach((img) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user