2026-06-20 13:58:42 +08:00
|
|
|
---
|
|
|
|
|
import vegaUrl from "../assets/styles/style-vega.css?url";
|
|
|
|
|
import novaUrl from "../assets/styles/style-nova.css?url";
|
|
|
|
|
import maiaUrl from "../assets/styles/style-maia.css?url";
|
|
|
|
|
import lyraUrl from "../assets/styles/style-lyra.css?url";
|
|
|
|
|
import miraUrl from "../assets/styles/style-mira.css?url";
|
|
|
|
|
import lumaUrl from "../assets/styles/style-luma.css?url";
|
|
|
|
|
import seraUrl from "../assets/styles/style-sera.css?url";
|
|
|
|
|
import rheaUrl from "../assets/styles/style-rhea.css?url";
|
2026-06-22 18:19:38 +08:00
|
|
|
import demoInteractionsUrl from "./demo-interactions.js?url";
|
2026-06-23 18:14:19 +08:00
|
|
|
import htmxUrl from "htmx.org/dist/htmx.min.js?url";
|
2026-06-20 13:58:42 +08:00
|
|
|
|
|
|
|
|
const styleUrls = {
|
|
|
|
|
vega: vegaUrl,
|
|
|
|
|
nova: novaUrl,
|
|
|
|
|
maia: maiaUrl,
|
|
|
|
|
lyra: lyraUrl,
|
|
|
|
|
mira: miraUrl,
|
|
|
|
|
luma: lumaUrl,
|
|
|
|
|
sera: seraUrl,
|
|
|
|
|
rhea: rheaUrl,
|
|
|
|
|
};
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
<style id="docs-style-gate" is:inline>
|
|
|
|
|
html[data-style-pending] body {
|
|
|
|
|
visibility: hidden;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<script is:inline define:vars={{ styleUrls }}>
|
|
|
|
|
(() => {
|
|
|
|
|
const styleGateId = "docs-style-gate";
|
|
|
|
|
const styleLinkId = "docs-style-variant";
|
|
|
|
|
const clearStylePending = () => {
|
|
|
|
|
document.documentElement.removeAttribute("data-style-pending");
|
|
|
|
|
document.getElementById(styleGateId)?.remove();
|
|
|
|
|
};
|
|
|
|
|
const getStoredStyle = () => {
|
|
|
|
|
try {
|
|
|
|
|
return localStorage.getItem("styleVariant") || "vega";
|
|
|
|
|
} catch (_) {
|
|
|
|
|
return "vega";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const getStyleHref = (style) => {
|
|
|
|
|
const href = styleUrls[style];
|
|
|
|
|
return href?.startsWith("/docs/src/assets/styles/") ? `${href}?direct` : href;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const style = getStoredStyle();
|
|
|
|
|
const nextStyle = Object.prototype.hasOwnProperty.call(styleUrls, style) ? style : "vega";
|
|
|
|
|
const href = getStyleHref(nextStyle);
|
|
|
|
|
|
|
|
|
|
document.documentElement.dataset.styleVariant = nextStyle;
|
|
|
|
|
|
|
|
|
|
if (!href) return;
|
|
|
|
|
|
|
|
|
|
document.documentElement.setAttribute("data-style-pending", "");
|
|
|
|
|
|
|
|
|
|
const existing = document.getElementById("docs-style-variant");
|
|
|
|
|
if (existing?.getAttribute("href") === href) {
|
|
|
|
|
clearStylePending();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!existing && document.currentScript) {
|
|
|
|
|
document.write(
|
|
|
|
|
`<link id="${styleLinkId}" rel="stylesheet" href="${href}" onload="document.documentElement.removeAttribute('data-style-pending');document.getElementById('${styleGateId}')?.remove()" onerror="document.documentElement.removeAttribute('data-style-pending');document.getElementById('${styleGateId}')?.remove()">`,
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const link = existing || document.createElement("link");
|
|
|
|
|
link.id = styleLinkId;
|
|
|
|
|
link.rel = "stylesheet";
|
|
|
|
|
link.addEventListener("load", clearStylePending, { once: true });
|
|
|
|
|
link.addEventListener("error", clearStylePending, { once: true });
|
|
|
|
|
link.href = href;
|
|
|
|
|
if (!existing) document.head.appendChild(link);
|
|
|
|
|
})();
|
|
|
|
|
</script>
|
2026-06-22 18:19:38 +08:00
|
|
|
|
2026-06-23 18:14:19 +08:00
|
|
|
<script is:inline>
|
|
|
|
|
(() => {
|
2026-06-24 19:07:23 +08:00
|
|
|
const key = (href) => {
|
2026-06-23 18:14:19 +08:00
|
|
|
const url = new URL(href, window.location.origin);
|
|
|
|
|
return `${url.pathname.replace(/\/$/, "")}${url.search}`;
|
|
|
|
|
};
|
|
|
|
|
|
2026-06-24 19:07:23 +08:00
|
|
|
const syncSidebar = () => {
|
|
|
|
|
for (const link of document.querySelectorAll("#sidebar a[href]")) {
|
|
|
|
|
const isCurrent = key(link.href) === key(window.location.href);
|
2026-06-23 18:14:19 +08:00
|
|
|
if (isCurrent) {
|
|
|
|
|
link.setAttribute("aria-current", "page");
|
|
|
|
|
link.closest("details")?.setAttribute("open", "");
|
|
|
|
|
} else {
|
|
|
|
|
link.removeAttribute("aria-current");
|
|
|
|
|
}
|
2026-06-24 19:07:23 +08:00
|
|
|
}
|
2026-06-23 18:14:19 +08:00
|
|
|
};
|
|
|
|
|
|
2026-06-24 19:07:23 +08:00
|
|
|
document.addEventListener("DOMContentLoaded", syncSidebar);
|
2026-06-23 18:14:19 +08:00
|
|
|
document.addEventListener("htmx:afterSettle", () => {
|
|
|
|
|
window.basecoat?.initAll?.();
|
2026-06-24 19:07:23 +08:00
|
|
|
syncSidebar();
|
2026-06-23 18:14:19 +08:00
|
|
|
});
|
2026-06-24 19:07:23 +08:00
|
|
|
window.addEventListener("popstate", syncSidebar);
|
2026-06-23 18:14:19 +08:00
|
|
|
})();
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script src={htmxUrl} defer></script>
|
2026-06-22 18:19:38 +08:00
|
|
|
<script type="module" src={demoInteractionsUrl}></script>
|