forked from blankspacecommunity/bs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
31 lines (26 loc) · 912 Bytes
/
script.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
29
30
31
let darkMode = true; // Initial mode is dark
function toggleMode() {
const button = document.getElementById("mode-toggle-button");
const logo = document.getElementById("logo");
const tags = document.querySelectorAll(".projects .tags span");
darkMode = !darkMode; // Toggle the mode state
if (darkMode) {
// Switch to dark mode
button.src = "dark_mode_btn.svg";
logo.src = "logo.svg";
document.body.classList.remove("high-contrast");
tags.forEach((tag) => {
const className = tag.classList[0];
tag.classList.remove(className + "-dark");
});
} else {
// Switch to light mode
button.src = "light_mode_btn.svg";
logo.src = "nightmode.svg";
document.body.classList.add("high-contrast");
tags.forEach((tag) => {
const className = tag.classList[0];
tag.classList.add(className + "-dark");
});
}
}