Something went wrong. Try again.
Tea journaling on ATProto (alpha)
Something went wrong. Try again.
1.7 kB · 63 lines
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364package components
import ( "tangled.org/oolong.social/oolong/internal/entities" "tangled.org/oolong.social/oolong/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']" data-svelte-modal-shell class="space-y-5" > <div data-modal-shell-error hidden class="bg-red-50 border border-red-200 rounded-lg p-3 text-sm text-red-800"></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> }}