diff --git a/output/modal.js b/output/modal.js index 92390b8..5f3fe57 100644 --- a/output/modal.js +++ b/output/modal.js @@ -18,12 +18,9 @@ const toggleModal = (event) => { event.preventDefault(); const modal = document.getElementById(event.currentTarget.dataset.target); if (!modal) return; - modal && (isModalOpen(modal) ? closeModal(modal) : openModal(modal)); + modal && (modal.open ? closeModal(modal) : openModal(modal)); }; -// Is modal open -const isModalOpen = (modal) => modal.hasAttribute("open") && modal.getAttribute("open") !== "false"; - // Open modal const openModal = (modal) => { const { documentElement: html } = document; @@ -36,7 +33,7 @@ const openModal = (modal) => { visibleModal = modal; html.classList.remove(openingClass); }, animationDuration); - modal.setAttribute("open", true); + modal.showModal(); }; // Close modal @@ -47,7 +44,7 @@ const closeModal = (modal) => { setTimeout(() => { html.classList.remove(closingClass, isOpenClass); html.style.removeProperty(scrollbarWidthCssVar); - modal.removeAttribute("open"); + modal.close(); }, animationDuration); }; diff --git a/src/site_generator.rs b/src/site_generator.rs index 0b4bcaa..38a7508 100644 --- a/src/site_generator.rs +++ b/src/site_generator.rs @@ -89,7 +89,7 @@ fn generate_header() -> Markup { li { h1 { "The Biggs Brief" }} } ul { - li { button data-target="about" onclick="toggleModal(event)" { "About" } } + li { button data-target="modal-about" onclick="toggleModal(event)" { "About" } } li { } @@ -123,11 +123,11 @@ fn about_modal(entries: Vec) -> Markup { links.sort(); html! { - dialog id="about" { + dialog id="modal-about" { article { header { - a href="#" aria-label="Close" rel="prev" {} - p { strong { "About" }} + button aria-label="Close" rel="prev" data-target="modal-about" onclick="toggleModal(event)" {} + h3 { "About" } } p { "I couldn't find a RSS reader that I liked so I decided to build my own."