-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
33 lines (27 loc) · 1.02 KB
/
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
32
33
document.addEventListener("DOMContentLoaded", () => {
const sidebar = document.querySelector(".sidebar");
const menuToggle = document.querySelector(".menu-toggle");
const themeToggle = document.getElementById("theme-toggle");
let isLightMode = false;
// Ensure Sidebar is Closed by Default on Load
sidebar.classList.add("hidden");
// Toggle Sidebar Visibility
menuToggle.addEventListener("click", () => {
sidebar.classList.toggle("hidden");
});
// Toggle Theme (Dark and Light Mode)
themeToggle.addEventListener("click", () => {
isLightMode = !isLightMode;
document.body.classList.toggle("light-mode", isLightMode);
// Update Emoji for Theme Toggle Button
themeToggle.textContent = isLightMode ? "☀️" : "🌙";
});
// Set the Initial State for Dark Mode Button
themeToggle.textContent = isLightMode ? "☀️" : "🌙";
});
// Redirect Function
function redirectToPage(page) {
if (page) {
window.location.href = page;
}
}