Skip to content

Commit

Permalink
fixing menu dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfieJones committed Jun 9, 2024
1 parent 3f863a6 commit 3498a22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
23 changes: 14 additions & 9 deletions apps/marketing-astro/src/components/docs/mobileNavSidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@ import ChevronDownIcon from "@heroicons/react/24/solid/ChevronDownIcon";
</div>

<script>
const btn = document.getElementById("docs-nav-menu-btn")!;
const dialog = document.getElementById("docs-nav-menu-dialog")!;
function setButton() {
const btn = document.getElementById("docs-nav-menu-btn")!;
const dialog = document.getElementById("docs-nav-menu-dialog")!;

btn.addEventListener("click", (e) => {
e.preventDefault();
btn.addEventListener("click", (e) => {
e.preventDefault();

const newState =
dialog.getAttribute("data-state") === "open" ? "closed" : "open";
dialog.setAttribute("data-state", newState);
const newState =
dialog.getAttribute("data-state") === "open" ? "closed" : "open";
dialog.setAttribute("data-state", newState);

btn.setAttribute("aria-expanded", newState === "open" ? "true" : "false");
});
btn.setAttribute("aria-expanded", newState === "open" ? "true" : "false");
});
}

setButton();
document.addEventListener("astro:after-swap", setButton);
</script>
1 change: 1 addition & 0 deletions apps/marketing-astro/src/pages/docs/[...path].astro
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const sections = await getFiles();
</Root>

<script>

document.addEventListener("astro:before-swap", () => {
sessionStorage.setItem(
"docs-sidebar-nav-scroll",
Expand Down

0 comments on commit 3498a22

Please sign in to comment.