-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
25 lines (20 loc) · 682 Bytes
/
Copy pathapp.js
File metadata and controls
25 lines (20 loc) · 682 Bytes
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
const lightSwitcher = document.getElementById("light-switcher");
const darkSwitcher = document.getElementById("dark-switcher");
lightSwitcher.addEventListener("click", setLightMode);
darkSwitcher.addEventListener("click", setDarkMode);
function setDarkMode() {
document.body.dataset["theme"] = "dark";
displaySwitcher(lightSwitcher);
hideSwitcher(darkSwitcher);
}
function setLightMode() {
document.body.dataset["theme"] = "light";
displaySwitcher(darkSwitcher);
hideSwitcher(lightSwitcher);
}
function displaySwitcher(switcher) {
switcher.dataset["visible"] = "true";
}
function hideSwitcher(switcher) {
switcher.dataset["visible"] = "false";
}