updated project no. and added theme transition · SohanRC/30DaysOfJavaScript@5cbdb80 · GitHub
Skip to content

Commit 5cbdb80

Browse files
committed
updated project no. and added theme transition
1 parent 77b059e commit 5cbdb80

18 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎.vscode/settings.json‎

Lines changed: 3 additions & 0 deletions

‎30DaysOfJavaScript/script.js‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ function toggleDarkLight() {
2121
} else {
2222
button.innerHTML = "🌙";
2323
}
24+
25+
var trans = () => {
26+
document.documentElement.classList.add("transition");
27+
window.setTimeout(() => {
28+
document.documentElement.classList.remove("transition");
29+
}, 500);
30+
};
31+
2432
var currentClass = body.className;
25-
body.className = currentClass == "dark-mode" ? "light-mode" : "dark-mode";
33+
// body.className = currentClass == "dark-mode" ? "light-mode" : "dark-mode";
34+
if (currentClass == "dark-mode") {
35+
trans();
36+
body.className = "light-mode";
37+
} else {
38+
trans();
39+
body.className = "dark-mode";
40+
}
2641
}

‎30DaysOfJavaScript/style.css‎

Lines changed: 12 additions & 4 deletions
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)