import { IS_BROWSER } from "fresh/runtime"; import { useSignal } from "@preact/signals"; export default function ThemeToggle() { const theme = useSignal( !IS_BROWSER ? "light" : document.documentElement.dataset.theme ?? "light", ); const toggleTheme = () => { theme.value = theme.value === "light" ? "dark" : "light"; document.documentElement.setAttribute("data-theme", theme.value); localStorage.setItem("theme", theme.value); }; return ( ); }