Monorepo for Tangled
tangled.org
1{{ define "fragments/comment/edit" }}
2 <form
3 class="pt-2"
4 hx-patch="/comment"
5 hx-swap="outerHTML"
6 hx-trigger="submit, keydown[(ctrlKey || metaKey) && key=='Enter'] from:find textarea"
7 hx-indicator="find button[type='submit']"
8 hx-disabled-elt="find button[type='submit']"
9 >
10 <input name="aturi" type="hidden" value="{{ .Comment.AtUri }}">
11 <textarea
12 name="body"
13 class="w-full p-2 rounded border border-gray-200 dark:border-gray-700"
14 rows="5"
15 autofocus>{{ .Comment.EditableBody }}</textarea>
16 <div id="comment-error" class="error"></div>
17 {{ template "editActions" $ }}
18 </form>
19{{ end }}
20
21{{ define "editActions" }}
22 <div class="flex flex-wrap items-stretch justify-end gap-2 text-gray-500 dark:text-gray-400 text-sm pt-2">
23 {{ template "cancel" . }}
24 {{ template "save" . }}
25 </div>
26{{ end }}
27
28{{ define "save" }}
29 <button
30 type="submit"
31 class="btn-create flex gap-1 items-center group text-sm"
32 >
33 {{ i "check" "size-4" }}
34 Save
35 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
36 </button>
37{{ end }}
38
39{{ define "cancel" }}
40 <button
41 class="btn-flat text-red-500 dark:text-red-400 flex gap-1 items-center group"
42 hx-get="/comment?aturi={{ .Comment.AtUri }}"
43 hx-target="closest form"
44 hx-swap="outerHTML"
45 >
46 {{ i "x" "size-4" }}
47 Cancel
48 </button>
49{{ end }}