Something went wrong. Try again.
Tea journaling on ATProto (alpha)
Something went wrong. Try again.
1.7 kB · 64 lines
at feat-explore
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465package components
import ( "tangled.org/arabica.social/arabica/internal/entities" "tangled.org/arabica.social/arabica/internal/lexicons")
// ModalShellProps configures the shared dialog wrapper used by entity// create/edit modals. Body content is passed as templ children.type ModalShellProps struct { Type lexicons.RecordType ActionPath string RKey string // "" = create, non-empty = edit}
func modalActionURL(path, rkey string) string { if rkey != "" { return "/api/" + path + "/" + rkey } return "/api/" + path}
templ ModalShell(props ModalShellProps) { if d := entities.Get(props.Type); d != nil { <dialog id="entity-modal" class="modal-dialog"> <div class="modal-content"> <h3 class="modal-title"> if props.RKey != "" { Edit { d.DisplayName } } else { Add { d.DisplayName } } </h3> <form if props.RKey != "" { hx-put={ modalActionURL(props.ActionPath, props.RKey) } } else { hx-post={ modalActionURL(props.ActionPath, "") } } hx-trigger="submit" hx-swap="none" hx-sync="this:drop" hx-disabled-elt="find button[type='submit']" v-scope="ModalShell()" @vue:mounted="setup($el)" class="space-y-5" > <div v-show="!!serverError" v-cloak class="bg-red-50 border border-red-200 rounded-lg p-3 text-sm text-red-800" v-text="serverError"></div> { children... } <div class="flex gap-2 pt-2"> <button type="submit" class="flex-1 btn-primary">Save</button> <button type="button" data-action="close-dialog" class="flex-1 btn-secondary" > Cancel </button> </div> </form> </div> </dialog> }}