Monorepo for Tangled
tangled.org
1{{ define "fragments/comment/commentHeader" }}
2 <div
3 class="flex flex-wrap items-center gap-2 text-sm text-gray-500 dark:text-gray-400 "
4 hx-target="next .comment-body"
5 id="comment-header-{{ .Comment.Rkey }}"
6 {{ if .HxSwapOob }}hx-swap-oob="outerHTML"{{ end }}
7 >
8 {{ $handle := resolve .Comment.Did.String }}
9 <a class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" href="/{{ $handle }}">{{ $handle }}</a>
10 <span class="before:content-['·']"></span>
11 {{ template "timestamp" . }}
12 {{ $isCommentOwner := and .LoggedInUser (eq .LoggedInUser.Did .Comment.Did.String) }}
13 {{ if not .Comment.Deleted }}
14 <div class="ml-auto flex items-center gap-4 opacity-0 group-hover/comment:opacity-100">
15 {{ if .LoggedInUser }}
16 {{ template "repo/fragments/reactionsPopup" (dict "CommentRkey" (string .Comment.Rkey) "Scope" "header") }}
17 {{ end }}
18 {{ if $isCommentOwner }}
19 {{ if not .Comment.IsLegacy }}
20 {{ template "editCommentBtn" . }}
21 {{ end }}
22 {{ template "deleteCommentBtn" . }}
23 {{ end }}
24 </div>
25 {{ end }}
26 </div>
27{{ end }}
28
29{{ define "timestamp" }}
30 <a href="#comment-{{ .Comment.Rkey }}"
31 class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-400 hover:underline no-underline"
32 id="comment-{{ .Comment.Rkey }}">
33 {{ if .Comment.Deleted }}
34 {{ template "repo/fragments/shortTimeAgo" .Comment.Deleted }}
35 {{ else if .Comment.Edited }}
36 Edited {{ template "repo/fragments/shortTimeAgo" .Comment.Edited }}
37 {{ else }}
38 {{ template "repo/fragments/shortTimeAgo" .Comment.Created }}
39 {{ end }}
40 </a>
41{{ end }}
42
43{{ define "editCommentBtn" }}
44 <a
45 class="text-gray-500 dark:text-gray-400 flex gap-1 items-center group cursor-pointer hover:no-underline no-underline"
46 hx-get="/comment/edit?aturi={{ .Comment.AtUri }}"
47 >
48 {{ i "pencil" "size-4 inline group-[.htmx-request]:hidden" }}
49 {{ i "loader-circle" "size-4 animate-spin hidden group-[.htmx-request]:inline" }}
50 </a>
51{{ end }}
52
53{{ define "deleteCommentBtn" }}
54 <a
55 class="text-red-500 dark:text-red-400 hover:text-red-600 hover:dark:text-red-300 flex gap-1 items-center group cursor-pointer hover:no-underline no-underline"
56 hx-delete="/comment?aturi={{ .Comment.AtUri }}"
57 hx-confirm="Are you sure you want to delete your comment?"
58 >
59 {{ i "trash-2" "size-4 inline group-[.htmx-request]:hidden" }}
60 {{ i "loader-circle" "size-4 animate-spin hidden group-[.htmx-request]:inline" }}
61 </a>
62{{ end }}