-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
28 lines (26 loc) · 964 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
document.addEventListener("DOMContentLoaded", function() {
const themeLight = document.getElementById("theme-light");
const themeDark = document.getElementById("theme-dark");
const switcher = document.getElementById("theme-switcher");
// Load saved theme preference
const savedTheme = localStorage.getItem("theme");
if (savedTheme === "dark") {
themeLight.disabled = true;
themeDark.disabled = false;
} else {
themeLight.disabled = false;
themeDark.disabled = true;
}
// Event listener for theme switcher
switcher.addEventListener("click", function() {
if (themeLight.disabled) {
themeLight.disabled = false;
themeDark.disabled = true;
localStorage.setItem("theme", "light");
} else {
themeLight.disabled = true;
themeDark.disabled = false;
localStorage.setItem("theme", "dark");
}
});
});