-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (23 loc) · 737 Bytes
/
script.js
File metadata and controls
28 lines (23 loc) · 737 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
26
27
28
// Dark Mode toggle with persistence
const darkToggle = document.getElementById("darkToggle");
const body = document.body;
// Load saved theme
if (localStorage.getItem("theme") === "dark") {
body.classList.add("dark");
darkToggle.textContent = "☀️";
}
// Toggle theme
darkToggle.addEventListener("click", () => {
body.classList.toggle("dark");
if (body.classList.contains("dark")) {
localStorage.setItem("theme", "dark");
darkToggle.textContent = "☀️";
} else {
localStorage.setItem("theme", "light");
darkToggle.textContent = "🌙";
}
});
// Footer year
document.getElementById("year").textContent = new Date().getFullYear();
// Mobile Menu
const menuBtn = document.querySelector(".menu-btn");