diff --git a/appview/pages/pages.go b/appview/pages/pages.go index d1ea52a2..db8c354f 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -1279,10 +1279,12 @@ func (p *Pages) EditIssueFragment(w io.Writer, params EditIssueParams) error { } type ThreadReactionFragmentParams struct { - Kind models.ReactionKind - Count int - Users []string - IsReacted bool + Kind models.ReactionKind + Count int + Users []string + IsReacted bool + CommentRkey string + SubjectUri string } func (p *Pages) ThreadReactionFragment(w io.Writer, params ThreadReactionFragmentParams) error { diff --git a/appview/pages/templates/fragments/comment/commentBody.html b/appview/pages/templates/fragments/comment/commentBody.html index 2a8d35e8..3bd7b8c1 100644 --- a/appview/pages/templates/fragments/comment/commentBody.html +++ b/appview/pages/templates/fragments/comment/commentBody.html @@ -5,7 +5,8 @@ {{ template "repo/fragments/reactions" (dict "Reactions" .Reactions "UserReacted" .UserReacted - "ThreadAt" .Comment.FeedCommentAtUri) }} + "ThreadAt" .Comment.FeedCommentAtUri + "HideIfEmpty" true) }} {{ else }}
[deleted by author]
{{ end }} diff --git a/appview/pages/templates/fragments/comment/commentHeader.html b/appview/pages/templates/fragments/comment/commentHeader.html index 8fcd6181..51f814a4 100644 --- a/appview/pages/templates/fragments/comment/commentHeader.html +++ b/appview/pages/templates/fragments/comment/commentHeader.html @@ -10,12 +10,17 @@ {{ template "timestamp" . }} {{ $isCommentOwner := and .LoggedInUser (eq .LoggedInUser.Did .Comment.Did.String) }} - {{ if and $isCommentOwner (not .Comment.Deleted) }} + {{ if not .Comment.Deleted }}
- {{ if not .Comment.IsLegacy }} - {{ template "editCommentBtn" . }} + {{ if .LoggedInUser }} + {{ template "repo/fragments/reactionsPopup" (dict "CommentRkey" (string .Comment.Rkey) "Scope" "header") }} + {{ end }} + {{ if $isCommentOwner }} + {{ if not .Comment.IsLegacy }} + {{ template "editCommentBtn" . }} + {{ end }} + {{ template "deleteCommentBtn" . }} {{ end }} - {{ template "deleteCommentBtn" . }}
{{ end }} @@ -40,9 +45,8 @@ class="text-gray-500 dark:text-gray-400 flex gap-1 items-center group cursor-pointer hover:no-underline no-underline" hx-get="/comment/edit?aturi={{ .Comment.AtUri }}" > - {{ i "pencil" "size-3 inline group-[.htmx-request]:hidden" }} - {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }} - edit + {{ i "pencil" "size-4 inline group-[.htmx-request]:hidden" }} + {{ i "loader-circle" "size-4 animate-spin hidden group-[.htmx-request]:inline" }} {{ end }} @@ -52,8 +56,7 @@ hx-delete="/comment?aturi={{ .Comment.AtUri }}" hx-confirm="Are you sure you want to delete your comment?" > - {{ i "trash-2" "size-3 inline group-[.htmx-request]:hidden" }} - {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }} - delete + {{ i "trash-2" "size-4 inline group-[.htmx-request]:hidden" }} + {{ i "loader-circle" "size-4 animate-spin hidden group-[.htmx-request]:inline" }} {{ end }} diff --git a/appview/pages/templates/repo/fragments/reaction.html b/appview/pages/templates/repo/fragments/reaction.html index ac02aaec..cb1f8b48 100644 --- a/appview/pages/templates/repo/fragments/reaction.html +++ b/appview/pages/templates/repo/fragments/reaction.html @@ -1,22 +1,20 @@ {{ define "repo/fragments/reaction" }} {{ end }} diff --git a/appview/pages/templates/repo/fragments/reactions.html b/appview/pages/templates/repo/fragments/reactions.html index 0ca5c200..99c0fa39 100644 --- a/appview/pages/templates/repo/fragments/reactions.html +++ b/appview/pages/templates/repo/fragments/reactions.html @@ -3,47 +3,26 @@ {{- $reactions := .Reactions -}} {{- $userReacted := .UserReacted -}} {{- $threadAt := .ThreadAt -}} + {{- $parts := splitOn (string $threadAt) "/" -}} + {{- $commentRkey := index $parts (sub (len $parts) 1) -}} - {{ template "reactionsPopup" }} - {{ range $kind := const.OrderedReactionKinds }} {{ $reactionData := index $reactions $kind }} {{ template "repo/fragments/reaction" (dict - "Kind" $kind - "Count" $reactionData.Count - "IsReacted" (index $userReacted $kind) - "Users" $reactionData.Users) }} + "Kind" $kind + "Count" $reactionData.Count + "IsReacted" (index $userReacted $kind) + "Users" $reactionData.Users + "CommentRkey" $commentRkey + "SubjectUri" $threadAt) }} {{ end }} - -{{ end }} -{{ define "reactionsPopup" }} -
- - {{ i "smile" "size-4" }} - -
- {{ range $kind := const.OrderedReactionKinds }} - - {{ end }} -
-
+ {{ if or (not .HideIfEmpty) (gt (len $reactions) 0) }} + {{ template "repo/fragments/reactionsPopup" (dict "CommentRkey" $commentRkey "Scope" "body") }} + {{ end }} + + {{ end }} diff --git a/appview/pages/templates/repo/fragments/reactionsPopup.html b/appview/pages/templates/repo/fragments/reactionsPopup.html new file mode 100644 index 00000000..394342b9 --- /dev/null +++ b/appview/pages/templates/repo/fragments/reactionsPopup.html @@ -0,0 +1,32 @@ +{{ define "repo/fragments/reactionsPopup" }} + {{ $id := printf "%s-%s" (string .CommentRkey) .Scope }} + +
+ {{ range $kind := const.OrderedReactionKinds }} + + {{ end }} +
+{{ end }} diff --git a/appview/pages/templates/repo/issues/issue.html b/appview/pages/templates/repo/issues/issue.html index 67d8c2c7..9cbcf59f 100644 --- a/appview/pages/templates/repo/issues/issue.html +++ b/appview/pages/templates/repo/issues/issue.html @@ -61,7 +61,7 @@ {{ $bgColor = "bg-green-600 dark:bg-green-700" }} {{ $icon = "circle-dot" }} {{ end }} -
+
{{ i $icon "w-3 h-3 mr-1.5 text-white dark:text-white" }} {{ if eq .Issue.State "open" }}Open{{ else }}Closed{{ end }} @@ -80,7 +80,9 @@ {{ if and .LoggedInUser (eq .LoggedInUser.Did .Issue.Did) }} - {{ template "issueActions" . }} +
+ {{ template "issueActions" . }} +
{{ end }}
@@ -103,7 +105,7 @@ {{ define "deleteIssue" }} diff --git a/appview/state/reaction.go b/appview/state/reaction.go index ba1a5238..e0a5eddf 100644 --- a/appview/state/reaction.go +++ b/appview/state/reaction.go @@ -81,10 +81,12 @@ func (s *State) React(w http.ResponseWriter, r *http.Request) { l.Info("created atproto record", "uri", resp.Uri) s.pages.ThreadReactionFragment(w, pages.ThreadReactionFragmentParams{ - Kind: reactionKind, - Count: reactionMap[reactionKind].Count, - Users: reactionMap[reactionKind].Users, - IsReacted: true, + Kind: reactionKind, + Count: reactionMap[reactionKind].Count, + Users: reactionMap[reactionKind].Users, + IsReacted: true, + CommentRkey: subjectUri.RecordKey().String(), + SubjectUri: subject, }) return @@ -119,10 +121,12 @@ func (s *State) React(w http.ResponseWriter, r *http.Request) { } s.pages.ThreadReactionFragment(w, pages.ThreadReactionFragmentParams{ - Kind: reactionKind, - Count: reactionMap[reactionKind].Count, - Users: reactionMap[reactionKind].Users, - IsReacted: false, + Kind: reactionKind, + Count: reactionMap[reactionKind].Count, + Users: reactionMap[reactionKind].Users, + IsReacted: false, + CommentRkey: subjectUri.RecordKey().String(), + SubjectUri: subject, }) return