-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (27 loc) · 1.11 KB
/
script.js
File metadata and controls
34 lines (27 loc) · 1.11 KB
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
32
33
34
document.addEventListener("DOMContentLoaded", function () {
// Light/Dark mode toggle
const modeToggle = document.getElementById("modeToggle");
const headerIcon = document.getElementById("headerIcon");
modeToggle.addEventListener("click", function () {
document.body.classList.toggle("dark-mode");
if (document.body.classList.contains("dark-mode")) {
modeToggle.textContent = "🌙 Dark Mode";
headerIcon.style.filter = "invert(1)";
} else {
modeToggle.textContent = "🌞 Light Mode";
headerIcon.style.filter = "invert(0)";
}
});
// Summary text toggle between + Expand and − Collapse
document.querySelectorAll("details.custom-details").forEach((detail) => {
const summary = detail.querySelector("summary");
const updateLabel = () => {
summary.textContent = detail.open ? "− Collapse" : "+ Expand";
summary.style.color = "grey"; // keep the grey love
};
// Initial state
updateLabel();
// Toggle listener
detail.addEventListener("toggle", updateLabel);
});
});