From 147c902d941af6f28de109fd14743af18f952097 Mon Sep 17 00:00:00 2001 From: "m.huber" Date: Fri, 8 Mar 2024 20:06:32 +0100 Subject: [PATCH 01/10] highlight archived labels set a border and change the tooltip --- modules/templates/util_render.go | 33 ++++++++++++------- templates/repo/issue/filter_actions.tmpl | 2 +- templates/repo/issue/filter_list.tmpl | 2 +- templates/repo/issue/labels/label.tmpl | 2 +- templates/repo/issue/labels/label_list.tmpl | 4 +-- .../issue/labels/labels_selector_field.tmpl | 4 +-- .../repo/issue/view_content/comments.tmpl | 6 ++-- templates/shared/issuelist.tmpl | 2 +- 8 files changed, 33 insertions(+), 22 deletions(-) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index cdff31698ca13..f4cafdf5bdcb4 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" + gitea_context "code.gitea.io/gitea/services/context" ) // RenderCommitMessage renders commit message with XSS-safe and special links. @@ -118,28 +119,38 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string) } // RenderLabel renders a label -func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML { - labelScope := label.ExclusiveScope() +func RenderLabel(ctx *gitea_context.Base, label *issues_model.Label) template.HTML { + var ( + description string + archivedCSS string + textColor = "#111" + isArchived = !label.ArchivedUnix.IsZero() + labelScope = label.ExclusiveScope() + ) - textColor := "#111" r, g, b := util.HexToRBGColor(label.Color) // Determine if label text should be light or dark to be readable on background color if util.UseLightTextOnBackground(r, g, b) { textColor = "#eee" } - description := emoji.ReplaceAliases(template.HTMLEscapeString(label.Description)) + if isArchived { + description = ctx.Locale.TrString("archived") + archivedCSS = fmt.Sprintf("border-width: 1px !important; border-color: %s !important;", textColor) + } else { + description = emoji.ReplaceAliases(template.HTMLEscapeString(label.Description)) + } if labelScope == "" { // Regular label - s := fmt.Sprintf("
%s
", - textColor, label.Color, description, RenderEmoji(ctx, label.Name)) + s := fmt.Sprintf("
%s
", + textColor, label.Color, archivedCSS, description, RenderEmoji(ctx, label.Name)) return template.HTML(s) } // Scoped label - scopeText := RenderEmoji(ctx, labelScope) - itemText := RenderEmoji(ctx, label.Name[len(labelScope)+1:]) + scopeText := RenderEmoji(ctx.Req.Context(), labelScope) + itemText := RenderEmoji(ctx.Req.Context(), label.Name[len(labelScope)+1:]) // Make scope and item background colors slightly darker and lighter respectively. // More contrast needed with higher luminance, empirically tweaked. @@ -166,11 +177,11 @@ func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML { itemColor := "#" + hex.EncodeToString(itemBytes) scopeColor := "#" + hex.EncodeToString(scopeBytes) - s := fmt.Sprintf(""+ + s := fmt.Sprintf(""+ "
%s
"+ "
%s
"+ "
", - description, + description, archivedCSS, textColor, scopeColor, scopeText, textColor, itemColor, itemText) return template.HTML(s) @@ -211,7 +222,7 @@ func RenderMarkdownToHtml(ctx context.Context, input string) template.HTML { //n return output } -func RenderLabels(ctx context.Context, labels []*issues_model.Label, repoLink string) template.HTML { +func RenderLabels(ctx *gitea_context.Base, labels []*issues_model.Label, repoLink string) template.HTML { htmlCode := `` for _, label := range labels { // Protect against nil value in labels - shouldn't happen but would cause a panic if so diff --git a/templates/repo/issue/filter_actions.tmpl b/templates/repo/issue/filter_actions.tmpl index a2296f6597bd3..f80d1b2399774 100644 --- a/templates/repo/issue/filter_actions.tmpl +++ b/templates/repo/issue/filter_actions.tmpl @@ -30,7 +30,7 @@ {{end}} {{$previousExclusiveScope = $exclusiveScope}}
- {{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context .}} + {{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel ctx .}} {{template "repo/issue/labels/label_archived" .}}
{{end}} diff --git a/templates/repo/issue/filter_list.tmpl b/templates/repo/issue/filter_list.tmpl index 9d3341cc814cd..2e6fbf3226f89 100644 --- a/templates/repo/issue/filter_list.tmpl +++ b/templates/repo/issue/filter_list.tmpl @@ -42,7 +42,7 @@ {{svg "octicon-check"}} {{end}} {{end}} - {{RenderLabel $.Context .}} + {{RenderLabel ctx .}}

{{template "repo/issue/labels/label_archived" .}}

{{end}} diff --git a/templates/repo/issue/labels/label.tmpl b/templates/repo/issue/labels/label.tmpl index 3ecae09373888..2d77da382676b 100644 --- a/templates/repo/issue/labels/label.tmpl +++ b/templates/repo/issue/labels/label.tmpl @@ -3,5 +3,5 @@ id="label_{{.label.ID}}" href="{{.root.RepoLink}}/{{if or .root.IsPull .root.Issue.IsPull}}pulls{{else}}issues{{end}}?labels={{.label.ID}}"{{/* FIXME: use .root.Issue.Link or create .root.Link */}} > - {{- RenderLabel $.Context .label -}} + {{- RenderLabel ctx .label -}} diff --git a/templates/repo/issue/labels/label_list.tmpl b/templates/repo/issue/labels/label_list.tmpl index 9b0061b60ebd6..33a35ec42ea62 100644 --- a/templates/repo/issue/labels/label_list.tmpl +++ b/templates/repo/issue/labels/label_list.tmpl @@ -32,7 +32,7 @@ {{range .Labels}}
  • - {{RenderLabel $.Context .}} + {{RenderLabel ctx .}} {{if .Description}}
    {{.Description | RenderEmoji $.Context}}{{end}}
    @@ -72,7 +72,7 @@ {{range .OrgLabels}}
  • - {{RenderLabel $.Context .}} + {{RenderLabel ctx .}} {{if .Description}}
    {{.Description | RenderEmoji $.Context}}{{end}}
    diff --git a/templates/repo/issue/labels/labels_selector_field.tmpl b/templates/repo/issue/labels/labels_selector_field.tmpl index e42a1de8952dc..115e794c89d27 100644 --- a/templates/repo/issue/labels/labels_selector_field.tmpl +++ b/templates/repo/issue/labels/labels_selector_field.tmpl @@ -21,7 +21,7 @@
    {{end}} {{$previousExclusiveScope = $exclusiveScope}} - {{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}  {{RenderLabel $.Context .}} + {{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}  {{RenderLabel ctx .}} {{if .Description}}
    {{.Description | RenderEmoji $.Context}}{{end}}

    {{template "repo/issue/labels/label_archived" .}}

    @@ -34,7 +34,7 @@
    {{end}} {{$previousExclusiveScope = $exclusiveScope}} - {{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}  {{RenderLabel $.Context .}} + {{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}  {{RenderLabel ctx .}} {{if .Description}}
    {{.Description | RenderEmoji $.Context}}{{end}}

    {{template "repo/issue/labels/label_archived" .}}

    diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 86cb716bb3e39..4bd300edd7427 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -173,11 +173,11 @@ {{template "shared/user/authorlink" .Poster}} {{if and .AddedLabels (not .RemovedLabels)}} - {{ctx.Locale.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels $.Context .AddedLabels $.RepoLink) $createdStr}} + {{ctx.Locale.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels ctx .AddedLabels $.RepoLink) $createdStr}} {{else if and (not .AddedLabels) .RemovedLabels}} - {{ctx.Locale.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels $.Context .RemovedLabels $.RepoLink) $createdStr}} + {{ctx.Locale.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels ctx .RemovedLabels $.RepoLink) $createdStr}} {{else}} - {{ctx.Locale.Tr "repo.issues.add_remove_labels" (RenderLabels $.Context .AddedLabels $.RepoLink) (RenderLabels $.Context .RemovedLabels $.RepoLink) $createdStr}} + {{ctx.Locale.Tr "repo.issues.add_remove_labels" (RenderLabels ctx .AddedLabels $.RepoLink) (RenderLabels ctx .RemovedLabels $.RepoLink) $createdStr}} {{end}}
    diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index e8a0079c1cdbe..42c6bfe600990 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -21,7 +21,7 @@ {{end}} {{range .Labels}} - {{RenderLabel $.Context .}} + {{RenderLabel ctx .}} {{end}} From e19dd973654ac2ab19b0d6250d4040aeaadae707 Mon Sep 17 00:00:00 2001 From: "m.huber" Date: Fri, 8 Mar 2024 20:15:29 +0100 Subject: [PATCH 02/10] no import cycle --- modules/templates/util_render.go | 14 +++++++------- templates/repo/issue/filter_actions.tmpl | 2 +- templates/repo/issue/filter_list.tmpl | 2 +- templates/repo/issue/labels/label.tmpl | 2 +- templates/repo/issue/labels/label_list.tmpl | 4 ++-- .../repo/issue/labels/labels_selector_field.tmpl | 4 ++-- templates/repo/issue/view_content/comments.tmpl | 6 +++--- templates/shared/issuelist.tmpl | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index f4cafdf5bdcb4..529070b822af0 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -20,8 +20,8 @@ import ( "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/translation" "code.gitea.io/gitea/modules/util" - gitea_context "code.gitea.io/gitea/services/context" ) // RenderCommitMessage renders commit message with XSS-safe and special links. @@ -119,7 +119,7 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string) } // RenderLabel renders a label -func RenderLabel(ctx *gitea_context.Base, label *issues_model.Label) template.HTML { +func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML { var ( description string archivedCSS string @@ -135,7 +135,7 @@ func RenderLabel(ctx *gitea_context.Base, label *issues_model.Label) template.HT } if isArchived { - description = ctx.Locale.TrString("archived") + description = locale.TrString("archived") archivedCSS = fmt.Sprintf("border-width: 1px !important; border-color: %s !important;", textColor) } else { description = emoji.ReplaceAliases(template.HTMLEscapeString(label.Description)) @@ -149,8 +149,8 @@ func RenderLabel(ctx *gitea_context.Base, label *issues_model.Label) template.HT } // Scoped label - scopeText := RenderEmoji(ctx.Req.Context(), labelScope) - itemText := RenderEmoji(ctx.Req.Context(), label.Name[len(labelScope)+1:]) + scopeText := RenderEmoji(ctx, labelScope) + itemText := RenderEmoji(ctx, label.Name[len(labelScope)+1:]) // Make scope and item background colors slightly darker and lighter respectively. // More contrast needed with higher luminance, empirically tweaked. @@ -222,7 +222,7 @@ func RenderMarkdownToHtml(ctx context.Context, input string) template.HTML { //n return output } -func RenderLabels(ctx *gitea_context.Base, labels []*issues_model.Label, repoLink string) template.HTML { +func RenderLabels(ctx context.Context, locale translation.Locale, labels []*issues_model.Label, repoLink string) template.HTML { htmlCode := `` for _, label := range labels { // Protect against nil value in labels - shouldn't happen but would cause a panic if so @@ -230,7 +230,7 @@ func RenderLabels(ctx *gitea_context.Base, labels []*issues_model.Label, repoLin continue } htmlCode += fmt.Sprintf("%s ", - repoLink, label.ID, RenderLabel(ctx, label)) + repoLink, label.ID, RenderLabel(ctx, locale, label)) } htmlCode += "" return template.HTML(htmlCode) diff --git a/templates/repo/issue/filter_actions.tmpl b/templates/repo/issue/filter_actions.tmpl index f80d1b2399774..f573b8e09ea2d 100644 --- a/templates/repo/issue/filter_actions.tmpl +++ b/templates/repo/issue/filter_actions.tmpl @@ -30,7 +30,7 @@ {{end}} {{$previousExclusiveScope = $exclusiveScope}}
    - {{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel ctx .}} + {{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context ctx.Locale .}} {{template "repo/issue/labels/label_archived" .}}
    {{end}} diff --git a/templates/repo/issue/filter_list.tmpl b/templates/repo/issue/filter_list.tmpl index 2e6fbf3226f89..d0086fdf8c2b6 100644 --- a/templates/repo/issue/filter_list.tmpl +++ b/templates/repo/issue/filter_list.tmpl @@ -42,7 +42,7 @@ {{svg "octicon-check"}} {{end}} {{end}} - {{RenderLabel ctx .}} + {{RenderLabel $.Context ctx.Locale .}}

    {{template "repo/issue/labels/label_archived" .}}

    {{end}} diff --git a/templates/repo/issue/labels/label.tmpl b/templates/repo/issue/labels/label.tmpl index 2d77da382676b..d20d5e63d7498 100644 --- a/templates/repo/issue/labels/label.tmpl +++ b/templates/repo/issue/labels/label.tmpl @@ -3,5 +3,5 @@ id="label_{{.label.ID}}" href="{{.root.RepoLink}}/{{if or .root.IsPull .root.Issue.IsPull}}pulls{{else}}issues{{end}}?labels={{.label.ID}}"{{/* FIXME: use .root.Issue.Link or create .root.Link */}} > - {{- RenderLabel ctx .label -}} + {{- RenderLabel $.Context ctx.Locale .label -}} diff --git a/templates/repo/issue/labels/label_list.tmpl b/templates/repo/issue/labels/label_list.tmpl index 33a35ec42ea62..428a4919aa1fe 100644 --- a/templates/repo/issue/labels/label_list.tmpl +++ b/templates/repo/issue/labels/label_list.tmpl @@ -32,7 +32,7 @@ {{range .Labels}}
  • - {{RenderLabel ctx .}} + {{RenderLabel $.Context ctx.Locale .}} {{if .Description}}
    {{.Description | RenderEmoji $.Context}}{{end}}
    @@ -72,7 +72,7 @@ {{range .OrgLabels}}
  • - {{RenderLabel ctx .}} + {{RenderLabel $.Context ctx.Locale .}} {{if .Description}}
    {{.Description | RenderEmoji $.Context}}{{end}}
    diff --git a/templates/repo/issue/labels/labels_selector_field.tmpl b/templates/repo/issue/labels/labels_selector_field.tmpl index 115e794c89d27..a9c33bc4eb715 100644 --- a/templates/repo/issue/labels/labels_selector_field.tmpl +++ b/templates/repo/issue/labels/labels_selector_field.tmpl @@ -21,7 +21,7 @@
    {{end}} {{$previousExclusiveScope = $exclusiveScope}} - {{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}  {{RenderLabel ctx .}} + {{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}  {{RenderLabel $.Context ctx.Locale .}} {{if .Description}}
    {{.Description | RenderEmoji $.Context}}{{end}}

    {{template "repo/issue/labels/label_archived" .}}

    @@ -34,7 +34,7 @@
    {{end}} {{$previousExclusiveScope = $exclusiveScope}} - {{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}  {{RenderLabel ctx .}} + {{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}  {{RenderLabel $.Context ctx.Locale .}} {{if .Description}}
    {{.Description | RenderEmoji $.Context}}{{end}}

    {{template "repo/issue/labels/label_archived" .}}

    diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 4bd300edd7427..a93920439874e 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -173,11 +173,11 @@ {{template "shared/user/authorlink" .Poster}} {{if and .AddedLabels (not .RemovedLabels)}} - {{ctx.Locale.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels ctx .AddedLabels $.RepoLink) $createdStr}} + {{ctx.Locale.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels $.Context ctx.Locale .AddedLabels $.RepoLink) $createdStr}} {{else if and (not .AddedLabels) .RemovedLabels}} - {{ctx.Locale.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels ctx .RemovedLabels $.RepoLink) $createdStr}} + {{ctx.Locale.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels $.Context ctx.Locale .RemovedLabels $.RepoLink) $createdStr}} {{else}} - {{ctx.Locale.Tr "repo.issues.add_remove_labels" (RenderLabels ctx .AddedLabels $.RepoLink) (RenderLabels ctx .RemovedLabels $.RepoLink) $createdStr}} + {{ctx.Locale.Tr "repo.issues.add_remove_labels" (RenderLabels $.Context ctx.Locale .AddedLabels $.RepoLink) (RenderLabels $.Context ctx.Locale .RemovedLabels $.RepoLink) $createdStr}} {{end}}
    diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 42c6bfe600990..0b3a5e98705d0 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -21,7 +21,7 @@ {{end}} {{range .Labels}} - {{RenderLabel ctx .}} + {{RenderLabel $.Context ctx.Locale .}} {{end}} From 2fc90aa329f9f4d81bf2212d00b573551f21db0f Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 11 Mar 2024 21:21:19 +0100 Subject: [PATCH 03/10] Update modules/templates/util_render.go --- modules/templates/util_render.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 529070b822af0..9524e43c63457 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -136,7 +136,7 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m if isArchived { description = locale.TrString("archived") - archivedCSS = fmt.Sprintf("border-width: 1px !important; border-color: %s !important;", textColor) + archivedCSS = fmt.Sprintf("opacity: 0.5;", textColor) } else { description = emoji.ReplaceAliases(template.HTMLEscapeString(label.Description)) } From b98144212355549beaa431f6705244c75f21c75f Mon Sep 17 00:00:00 2001 From: "m.huber" Date: Mon, 11 Mar 2024 21:32:15 +0100 Subject: [PATCH 04/10] use css class --- modules/templates/util_render.go | 20 ++++++++++---------- web_src/css/repo.css | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 9524e43c63457..02e8687545752 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -121,11 +121,11 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string) // RenderLabel renders a label func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML { var ( - description string - archivedCSS string - textColor = "#111" - isArchived = !label.ArchivedUnix.IsZero() - labelScope = label.ExclusiveScope() + description string + archivedCSSClass string + textColor = "#111" + isArchived = !label.ArchivedUnix.IsZero() + labelScope = label.ExclusiveScope() ) r, g, b := util.HexToRBGColor(label.Color) @@ -136,15 +136,15 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m if isArchived { description = locale.TrString("archived") - archivedCSS = fmt.Sprintf("opacity: 0.5;", textColor) + archivedCSSClass = "archived" } else { description = emoji.ReplaceAliases(template.HTMLEscapeString(label.Description)) } if labelScope == "" { // Regular label - s := fmt.Sprintf("
    %s
    ", - textColor, label.Color, archivedCSS, description, RenderEmoji(ctx, label.Name)) + s := fmt.Sprintf("
    %s
    ", + archivedCSSClass, textColor, label.Color, description, RenderEmoji(ctx, label.Name)) return template.HTML(s) } @@ -177,11 +177,11 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m itemColor := "#" + hex.EncodeToString(itemBytes) scopeColor := "#" + hex.EncodeToString(scopeBytes) - s := fmt.Sprintf(""+ + s := fmt.Sprintf(""+ "
    %s
    "+ "
    %s
    "+ "
    ", - description, archivedCSS, + archivedCSSClass, description, textColor, scopeColor, scopeText, textColor, itemColor, itemText) return template.HTML(s) diff --git a/web_src/css/repo.css b/web_src/css/repo.css index d60fb4db21a2f..616a5b0d15d8d 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -2401,6 +2401,10 @@ gap: 0 !important; } +.labels-list .archived { + opacity: 0.5; +} + .ui.label.scope-left { border-bottom-right-radius: 0; border-top-right-radius: 0; From c04a64e92f602884e751d63c5777448ded690256 Mon Sep 17 00:00:00 2001 From: "m.huber" Date: Mon, 11 Mar 2024 21:43:57 +0100 Subject: [PATCH 05/10] dont overwrite, extend description --- modules/templates/util_render.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 02e8687545752..828ae9f390426 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -121,7 +121,6 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string) // RenderLabel renders a label func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML { var ( - description string archivedCSSClass string textColor = "#111" isArchived = !label.ArchivedUnix.IsZero() @@ -134,11 +133,11 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m textColor = "#eee" } + description := emoji.ReplaceAliases(template.HTMLEscapeString(label.Description)) + if isArchived { - description = locale.TrString("archived") archivedCSSClass = "archived" - } else { - description = emoji.ReplaceAliases(template.HTMLEscapeString(label.Description)) + description = fmt.Sprintf("%s: %s", locale.TrString("archived"), description) } if labelScope == "" { From 6b7b378a754d30320031e8224c55bc562bdeb683 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 12 Mar 2024 16:41:39 +0100 Subject: [PATCH 06/10] own css-class --- modules/templates/util_render.go | 2 +- web_src/css/repo.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 828ae9f390426..6fbd11b7e6f89 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -136,7 +136,7 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m description := emoji.ReplaceAliases(template.HTMLEscapeString(label.Description)) if isArchived { - archivedCSSClass = "archived" + archivedCSSClass = "archived-label" description = fmt.Sprintf("%s: %s", locale.TrString("archived"), description) } diff --git a/web_src/css/repo.css b/web_src/css/repo.css index 0179878f1c8d0..7ded9c3d08b96 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -2417,7 +2417,7 @@ gap: 0 !important; } -.labels-list .archived { +.archived-label { opacity: 0.5; } From 9af7881daa289c36987d98119fe3d887c0765ada Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 12 Mar 2024 16:42:36 +0100 Subject: [PATCH 07/10] use grayscale instead of opacity --- web_src/css/repo.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/css/repo.css b/web_src/css/repo.css index 7ded9c3d08b96..c1da5dd0ff2de 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -2418,7 +2418,7 @@ } .archived-label { - opacity: 0.5; + filter: grayscale(1); } .ui.label.scope-left { From 1cd3dc116df14d53c1c0e3b8b3367c780fb8f093 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 12 Mar 2024 17:55:33 +0100 Subject: [PATCH 08/10] Update modules/templates/util_render.go Co-authored-by: delvh --- modules/templates/util_render.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 6fbd11b7e6f89..8be24f1f170ca 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -119,6 +119,7 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string) } // RenderLabel renders a label +// locale is needed due to an import cycle with our context providing the `Tr` function func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML { var ( archivedCSSClass string From 4c9b9ad449ab14e90b08c91818f022dc590a4d7a Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 12 Mar 2024 17:55:51 +0100 Subject: [PATCH 09/10] Update modules/templates/util_render.go Co-authored-by: delvh --- modules/templates/util_render.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 8be24f1f170ca..ba9b050e02aa9 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -138,7 +138,7 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m if isArchived { archivedCSSClass = "archived-label" - description = fmt.Sprintf("%s: %s", locale.TrString("archived"), description) + description = fmt.Sprintf("(%s) %s", locale.TrString("archived"), description) } if labelScope == "" { From de42f7fb2529bb1291484245df552f37fea5b0ab Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 12 Mar 2024 18:01:54 +0100 Subject: [PATCH 10/10] Update web_src/css/repo.css Co-authored-by: delvh --- web_src/css/repo.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/css/repo.css b/web_src/css/repo.css index c1da5dd0ff2de..587a3152e5562 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -2418,7 +2418,7 @@ } .archived-label { - filter: grayscale(1); + filter: grayscale(0.8); } .ui.label.scope-left {