Skip to content

Commit

Permalink
update togglemode
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoglvm committed Jan 20, 2024
1 parent 77cbb0e commit 98d205d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function toggleMode() {
const html = document.documentElement;
const root = document.querySelector(":root");

html.classList.toggle("light");

Expand All @@ -8,8 +9,10 @@ function toggleMode() {
if (html.classList.contains("light")) {
img.setAttribute("src", "./assets/avatar-light.png");
img.setAttribute("alt", "Light theme profile picture");
root.style.setProperty("--bg-color", "rgb(239, 235, 239)");
} else {
img.setAttribute("src", "./assets/avatar-dark.png");
img.setAttribute("alt", "Dark theme profile picture");
root.style.setProperty("--bg-color", "rgb(22, 22, 24)");
}
}

0 comments on commit 98d205d

Please sign in to comment.