Files
piik/index.html
T

46 lines
1.8 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Piik</title>
<script>
const systemTheme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
let theme;
try { theme = localStorage.getItem("piik:ui-theme"); } catch {}
const launch = new URLSearchParams(location.hash.slice(1));
const launchTheme = launch.get("piik-theme");
const explicit = new URLSearchParams(location.search).get("piik-preferences")?.split(",").includes("theme");
const themes = ["light", "dark"];
if (launch.get("piik-client") === "1" && (explicit || !themes.includes(theme))) {
if (themes.includes(launchTheme)) theme = launchTheme;
if (launchTheme === "system") theme = systemTheme;
}
document.documentElement.dataset.theme = themes.includes(theme) ? theme : systemTheme;
</script>
<style>
html[data-theme=light] { color-scheme:light; background:#f4f3ef; }
html[data-theme=dark] { color-scheme:dark; background:#171a20; }
</style>
</head>
<body>
<div id="root">
<main id="boot" style="text-align:center">
<p id="boot-status" role="status">Piik · Loading…</p>
<button id="boot-refresh" onclick="location.reload()">↻ Refresh</button>
</main>
</div>
<script>
function bootFailed() {
const status = document.getElementById("boot-status");
if (status) status.textContent = "Page could not load";
}
addEventListener("piik:boot-failed", bootFailed);
addEventListener("error", event => {
if (event.target.type === "module") bootFailed();
}, true);
</script>
<script type="module" src="/src/client/main.tsx"></script>
</body>
</html>