diff --git a/script.js b/script.js index cfa3ff9..49102d1 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,6 @@ function toggleMode() { const html = document.documentElement; + const root = document.querySelector(":root"); html.classList.toggle("light"); @@ -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)"); } }