From f1fefc308fc6c9bcf6ace373f9fde0e2df73d57c Mon Sep 17 00:00:00 2001 From: eti Date: Tue, 18 Aug 2026 18:53:28 +0200 Subject: [PATCH] appview/comments: show react button at the end of long comments show the reaction button after the body of long comments. also, show the reaction button without hover on mobile devices. Signed-off-by: eti --- appview/pages/funcmap.go | 7 +++++++ appview/pages/templates/fragments/comment/commentBody.html | 2 +- appview/pages/templates/repo/fragments/reaction.html | 2 +- appview/pages/templates/repo/fragments/reactions.html | 7 ++++--- appview/pages/templates/repo/issues/issue.html | 3 ++- .../pages/templates/repo/pulls/fragments/pullHeader.html | 3 ++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/appview/pages/funcmap.go b/appview/pages/funcmap.go index 0b5fd231..0feb7e15 100644 --- a/appview/pages/funcmap.go +++ b/appview/pages/funcmap.go @@ -18,6 +18,7 @@ import ( "reflect" "strings" "time" + "unicode/utf8" "github.com/alecthomas/chroma/v2" chromahtml "github.com/alecthomas/chroma/v2/formatters/html" @@ -333,6 +334,12 @@ func (p *Pages) funcMap() template.FuncMap { "nl2br": func(text string) template.HTML { return template.HTML(strings.ReplaceAll(template.HTMLEscapeString(text), "\n", "
")) }, + "isLongBody": func(text string) bool { + return utf8.RuneCountInString(text) > 800 || + len(strings.Split(text, "\n\n")) > 4 || + strings.Contains(text, "```") || + strings.Contains(text, "![") + }, "unwrapText": func(text string) string { paragraphs := strings.Split(text, "\n\n") diff --git a/appview/pages/templates/fragments/comment/commentBody.html b/appview/pages/templates/fragments/comment/commentBody.html index 3bd7b8c1..a551ffcf 100644 --- a/appview/pages/templates/fragments/comment/commentBody.html +++ b/appview/pages/templates/fragments/comment/commentBody.html @@ -6,7 +6,7 @@ (dict "Reactions" .Reactions "UserReacted" .UserReacted "ThreadAt" .Comment.FeedCommentAtUri - "HideIfEmpty" true) }} + "ShowPicker" (isLongBody .Comment.Body.Text)) }} {{ else }}
[deleted by author]
{{ end }} diff --git a/appview/pages/templates/repo/fragments/reaction.html b/appview/pages/templates/repo/fragments/reaction.html index cb1f8b48..f85f3081 100644 --- a/appview/pages/templates/repo/fragments/reaction.html +++ b/appview/pages/templates/repo/fragments/reaction.html @@ -1,6 +1,6 @@ {{ define "repo/fragments/reaction" }}