-
Notifications
You must be signed in to change notification settings - Fork 0
/
portfolio.js
29 lines (25 loc) · 1.02 KB
/
portfolio.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
let modeButton = document.getElementById("mode-button");
function toggleMode() {
let currentMode = sessionStorage.getItem("mode") || "dark";
currentMode = currentMode === "dark" ? "light" : "dark";
sessionStorage.setItem("mode", currentMode);
document.body.classList.toggle("light-mode");
document.body.style.transition = "0.5s";
let icons = document.querySelectorAll(".contact-details");
for (let i = 0; i <= icons.length; i++) {
icons[i].classList.toggle("icon-light-mode");
icons[i].style.transition = "0.5s";
}
}
modeButton.addEventListener("click", toggleMode);
window.addEventListener("load", function () {
let selectedMode = sessionStorage.getItem("mode");
if (selectedMode === "light") {
document.body.classList.add("light-mode");
let icons = document.querySelectorAll(".contact-details");
for (let i = 0; i <= icons.length; i++) {
icons[i].classList.toggle("icon-light-mode");
icons[i].style.transition = "0.5s";
}
}
});