🐛 Fix appearance pref not loading early enough

Fixes #102
This commit is contained in:
James Panther
2022-02-06 15:10:59 +11:00
parent 88946105fd
commit 39c1b7d04a
3 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -2,7 +2,6 @@ const browserIsDark =
window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
const sitePreference = document.documentElement.getAttribute("data-default-appearance");
const userPreference = localStorage.getItem("appearance");
const switcher = document.getElementById("appearance-switcher");
if (
(browserIsDark && userPreference === null) ||
@@ -25,6 +24,7 @@ if (document.documentElement.getAttribute("data-auto-appearance") === "true") {
}
window.addEventListener("DOMContentLoaded", (event) => {
const switcher = document.getElementById("appearance-switcher");
if (switcher) {
switcher.addEventListener("click", () => {
document.documentElement.classList.toggle("dark");