Monorepo for Tangled
at ce74be2b113da0d6b66ecf434758dc087291f3db 58 lines 2.2 kB view raw
1{{ define "repo/issues/fragments/issueCommentHeader" }} 2 <div class="flex flex-wrap items-center gap-2 text-sm text-gray-500 dark:text-gray-400 "> 3 {{ $handle := resolve .Comment.Did }} 4 <a class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" href="/{{ $handle }}">{{ $handle }}</a> 5 {{ template "hats" $ }} 6 <span class="before:content-['·']"></span> 7 {{ template "timestamp" . }} 8 {{ $isCommentOwner := and .LoggedInUser (eq .LoggedInUser.Did .Comment.Did) }} 9 {{ if and $isCommentOwner (not .Comment.Deleted) }} 10 {{ template "editIssueComment" . }} 11 {{ template "deleteIssueComment" . }} 12 {{ end }} 13 </div> 14{{ end }} 15 16{{ define "hats" }} 17 {{ $isIssueAuthor := eq .Comment.Did .Issue.Did }} 18 {{ if $isIssueAuthor }} 19 (author) 20 {{ end }} 21{{ end }} 22 23{{ define "timestamp" }} 24 <a href="#comment-{{ .Comment.Id }}" 25 class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-400 hover:underline no-underline" 26 id="comment-{{ .Comment.Id }}"> 27 {{ if .Comment.Deleted }} 28 {{ template "repo/fragments/shortTimeAgo" .Comment.Deleted }} 29 {{ else if .Comment.Edited }} 30 edited {{ template "repo/fragments/shortTimeAgo" .Comment.Edited }} 31 {{ else }} 32 {{ template "repo/fragments/shortTimeAgo" .Comment.Created }} 33 {{ end }} 34 </a> 35{{ end }} 36 37{{ define "editIssueComment" }} 38 <a 39 class="text-gray-500 dark:text-gray-400 flex gap-1 items-center group cursor-pointer" 40 hx-get="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment/{{ .Comment.Id }}/edit" 41 hx-swap="outerHTML" 42 hx-target="#comment-body-{{.Comment.Id}}"> 43 {{ i "pencil" "size-3" }} 44 </a> 45{{ end }} 46 47{{ define "deleteIssueComment" }} 48 <a 49 class="text-gray-500 dark:text-gray-400 flex gap-1 items-center group cursor-pointer" 50 hx-delete="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment/{{ .Comment.Id }}/" 51 hx-confirm="Are you sure you want to delete your comment?" 52 hx-swap="outerHTML" 53 hx-target="#comment-body-{{.Comment.Id}}" 54 > 55 {{ i "trash-2" "size-3" }} 56 {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }} 57 </a> 58{{ end }}