Fix NavHeader for production and improve AgeRestrictedModal script

This commit is contained in:
Bad Manners 2024-08-23 17:43:02 -03:00
parent eccd4d8bfe
commit e2527064db
7 changed files with 58 additions and 54 deletions

View file

@ -6,10 +6,10 @@ import DarkModeScriptInline from "./DarkModeScriptInline.astro";
<script>
import { ENABLE_VIEW_TRANSITIONS } from "astro:env/client";
type ColorScheme = "auto" | "dark" | "light";
type ColorScheme = "auto" | "dark" | "light" | undefined;
const colorSchemeSetup = () => {
let colorScheme: ColorScheme | undefined = localStorage.colorScheme;
let colorScheme: ColorScheme = localStorage.colorScheme;
if (!colorScheme || colorScheme === "auto") {
colorScheme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
@ -25,10 +25,10 @@ import DarkModeScriptInline from "./DarkModeScriptInline.astro";
localStorage.colorScheme = colorScheme;
};
document.querySelectorAll<HTMLElementTagNameMap["button"]>("button[data-dark-mode]").forEach((button) => {
button.addEventListener("click", toggleColorScheme);
button.classList.remove("hidden");
button.style.removeProperty("display");
button.setAttribute("aria-hidden", "false");
button.addEventListener("click", toggleColorScheme);
});
};
if (ENABLE_VIEW_TRANSITIONS) {