mini-strap/packages/components/src/offcanvas/template.html

51 lines
1.4 KiB
HTML

<div id="mobile-nav" class="off-canvas">
<div class="off-canvas-content" transition:persist>
<button class="off-canvas-toggle" data-target="#mobile-nav">
<svg
width="40px"
height="40px"
viewBox="0 0 1024 1024"
xmlns="http://www.w3.org/2000/svg"
fill="#ffffff"
>
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g
id="SVGRepo_tracerCarrier"
stroke-linecap="round"
stroke-linejoin="round"
></g>
<g id="SVGRepo_iconCarrier">
<path
fill="#cad3f5"
d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
></path>
</g>
</svg>
</button>
<div class="content">
<slot />
</div>
</div>
<div
class="off-canvas-backdrop off-canvas-toggle"
data-target="#mobile-nav"
></div>
</div>
<script>
document.addEventListener("astro:page-load", () => {
document.querySelectorAll <
HTMLElement >
".off-canvas-toggle".forEach((btn) =>
btn.addEventListener("click", () => {
const { target } = btn.dataset;
if (!target) return;
document.querySelector(target)?.classList.toggle("active");
}),
);
});
</script>