chore: run with user prefs

This commit is contained in:
Cory Dransfeldt 2024-10-30 20:34:13 -07:00
parent 31a03ba1bb
commit 1b89de2af7
No known key found for this signature in database
9 changed files with 20 additions and 138 deletions

View file

@ -47,42 +47,6 @@
</noscript>
</head>
<body>
<script>
document.addEventListener("DOMContentLoaded", () => {
(() => {
const storageType =
document.querySelector("theme-toggle")?.getAttribute("storage") === "local"
? localStorage
: sessionStorage;
const currentTheme = storageType.getItem("theme") || "auto";
const metaColorScheme = document.querySelector('meta[name="color-scheme"]');
const lightIcon = document.querySelector(".light");
const darkIcon = document.querySelector(".dark");
const autoIcon = document.querySelector(".auto");
if (currentTheme === "auto") {
metaColorScheme.setAttribute("content", "light dark");
document.documentElement.style.colorScheme = "";
} else {
metaColorScheme.setAttribute("content", currentTheme);
document.documentElement.style.colorScheme = currentTheme;
}
lightIcon.style.display = "none";
darkIcon.style.display = "none";
autoIcon.style.display = "none";
if (currentTheme === "light") {
lightIcon.style.display = "inline";
} else if (currentTheme === "dark") {
darkIcon.style.display = "inline";
} else {
autoIcon.style.display = "inline";
}
})();
});
</script>
<div class="main-wrapper">
<main>
{% render "header.liquid", globals:globals, page:page, nav:nav %}