diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-08-06 18:11:36 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-08-06 18:11:36 +0200 |
commit | eb3e495ca9c6894f1eed6517873b5059fd49d5cf (patch) | |
tree | a844b16dde49a88ecc4b438ec0f3eeade9b88bde | |
parent | Correctly show subpages title (diff) | |
download | baitinq.ml-eb3e495ca9c6894f1eed6517873b5059fd49d5cf.tar.gz baitinq.ml-eb3e495ca9c6894f1eed6517873b5059fd49d5cf.tar.bz2 baitinq.ml-eb3e495ca9c6894f1eed6517873b5059fd49d5cf.zip |
Toggle Icon: Add top and left margins
-rw-r--r-- | themes/researcher/layouts/partials/toggle.html | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/themes/researcher/layouts/partials/toggle.html b/themes/researcher/layouts/partials/toggle.html index 3cdfa29..fbe2f63 100644 --- a/themes/researcher/layouts/partials/toggle.html +++ b/themes/researcher/layouts/partials/toggle.html @@ -5,13 +5,17 @@ var toggle = document.getElementById("dark-mode-toggle"); var darkTheme = document.getElementById("dark-mode-theme"); var savedTheme = localStorage.getItem("dark-mode-storage") || "light"; +const darkThemeClassName = "fas fa-moon ml-4 mt-2"; +const lightThemeClassName = "fas fa-sun ml-4 mt-2"; + setTheme(savedTheme); + toggle.addEventListener("click", () => { - if (toggle.className === "fas fa-moon") { + if (toggle.className === darkThemeClassName) { setTheme("dark"); - } else if (toggle.className === "fas fa-sun") { + } else if (toggle.className === lightThemeClassName) { setTheme("light"); } }); @@ -21,10 +25,10 @@ function setTheme(mode) { if (mode === "dark") { darkTheme.disabled = false; - toggle.className = "fas fa-sun"; + toggle.className = lightThemeClassName; } else if (mode === "light") { darkTheme.disabled = true; - toggle.className = "fas fa-moon"; + toggle.className = darkThemeClassName; } } </script> |