mirror of
https://github.com/hunvreus/basecoat.git
synced 2026-12-04 14:19:05 +00:00
Prepare 1.0.0-beta.6
This commit is contained in:
@@ -8,6 +8,7 @@ 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";
|
||||
import demoInteractionsUrl from "./demo-interactions.js?url";
|
||||
import htmxUrl from "htmx.org/dist/htmx.min.js?url";
|
||||
|
||||
const styleUrls = {
|
||||
vega: vegaUrl,
|
||||
@@ -80,4 +81,50 @@ const styleUrls = {
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script is:inline>
|
||||
(() => {
|
||||
const pageKey = (href) => {
|
||||
const url = new URL(href, window.location.origin);
|
||||
return `${url.pathname.replace(/\/$/, "")}${url.search}`;
|
||||
};
|
||||
|
||||
const updateSidebarState = () => {
|
||||
const sidebar = document.getElementById("sidebar");
|
||||
if (!sidebar) return;
|
||||
|
||||
const currentKey = pageKey(window.location.href);
|
||||
sidebar.querySelectorAll("a[href]").forEach((link) => {
|
||||
const isCurrent = pageKey(link.href) === currentKey;
|
||||
if (isCurrent) {
|
||||
link.setAttribute("aria-current", "page");
|
||||
link.closest("details")?.setAttribute("open", "");
|
||||
} else {
|
||||
link.removeAttribute("aria-current");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const content = document.getElementById("content");
|
||||
if (!content) return;
|
||||
|
||||
document.body.setAttribute("hx-boost", "true");
|
||||
document.body.setAttribute("hx-target", "#content");
|
||||
document.body.setAttribute("hx-select", "#content");
|
||||
document.body.setAttribute("hx-swap", "outerHTML");
|
||||
document.body.setAttribute("hx-push-url", "true");
|
||||
|
||||
window.htmx?.process(document.body);
|
||||
updateSidebarState();
|
||||
});
|
||||
|
||||
document.addEventListener("htmx:afterSettle", () => {
|
||||
window.basecoat?.initAll?.();
|
||||
updateSidebarState();
|
||||
});
|
||||
window.addEventListener("popstate", updateSidebarState);
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script src={htmxUrl} defer></script>
|
||||
<script type="module" src={demoInteractionsUrl}></script>
|
||||
|
||||
Reference in New Issue
Block a user