Skip to content

Commit

Permalink
Update header.astro
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfieJones committed Jun 10, 2024
1 parent 599e019 commit 49b692d
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions apps/marketing-astro/src/components/header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,24 @@ const isLoggedIn = false;
</script>

<script>
const sidebar = document.getElementById(
"navbar-sidebar"
)! as HTMLDialogElement;
const sidebarButton = document.getElementById("sidebar-button")!;

sidebarButton.addEventListener("click", () => {
sidebar.showModal();
});

sidebar.addEventListener("click", (event) => {
if (event.target === sidebar) {
sidebar.close();
}
});
function initSidebar() {
const sidebar = document.getElementById(
"navbar-sidebar"
)! as HTMLDialogElement;
const sidebarButton = document.getElementById("sidebar-button")!;

sidebarButton.addEventListener("click", () => {
sidebar.showModal();
});

sidebar.addEventListener("click", (event) => {
if (event.target === sidebar) {
sidebar.close();
}
});
}

initSidebar();

document.addEventListener("astro:after-swap", initSidebar);
</script>

0 comments on commit 49b692d

Please sign in to comment.