package components // Modal renders a modal dialog. // // The itself must never be an htmx swap target: swapping its // innerHTML would replace the wrapper below (centering + close button) and // break the layout. Content is swapped into the inner element with id // "-content" instead. // // In htmx 4 "htmx:after:swap" fires on the requesting element, which lives // outside this dialog (e.g. gallery grid buttons). The listener is therefore // attached document-wide via the bare hx-on form with "from:body" (the // hx-on: form cannot carry trigger specs: attribute names may not // contain spaces) and guarded by ctx.target so only swaps into this dialog's // content open it. templ Modal(id string) {
{ children... }
}