Skip to content

Commit 8e5aea8

Browse files
silverwindlunny
andauthored
Improve label and text wrapping (#14113)
* Improve label wrapping - Adjust issue list styles so labels can wrap on the same line as the text. This relies on `display: inline` with the HTML whitespace being used as the separator. - Add global word-break: break-word. This should generally avoid text overflows in various places. * add whitespace to history labels * use overflow-wrap * restore word-break rules * use correct pre * use better selector for middle align Co-authored-by: Lunny Xiao <[email protected]>
1 parent cfc3916 commit 8e5aea8

File tree

6 files changed

+12
-19
lines changed

6 files changed

+12
-19
lines changed

modules/templates/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func NewFuncMap() []template.FuncMap {
371371
"RenderLabels": func(labels []*models.Label) template.HTML {
372372
html := `<span class="labels-list">`
373373
for _, label := range labels {
374-
html += fmt.Sprintf("<div class='ui label' style='color: %s; background-color: %s'>%s</div>",
374+
html += fmt.Sprintf("<div class='ui label' style='color: %s; background-color: %s'>%s</div> ",
375375
label.ForegroundColor(), label.Color, RenderEmoji(label.Name))
376376
}
377377
html += "</span>"

templates/repo/issue/labels/label.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
style="color: {{.label.ForegroundColor}}; background-color: {{.label.Color}}"
66
title="{{.label.Description | RenderEmojiPlain}}"
77
>
8-
{{.label.Name | RenderEmoji}}
8+
{{.label.Name | RenderEmoji}}
99
</a>

templates/shared/issuelist.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
</div>
3131
</div>
3232
<div class="issue-item-main f1 fc df">
33-
<div class="issue-item-top-row df ac fw">
34-
<a class="title mr-3" href="{{if .HTMLURL}}{{.HTMLURL}}{{else}}{{$.Link}}/{{.Index}}{{end}}">
33+
<div class="issue-item-top-row">
34+
<a class="title" href="{{if .HTMLURL}}{{.HTMLURL}}{{else}}{{$.Link}}/{{.Index}}{{end}}">
3535
{{RenderEmoji .Title}}
3636
{{if .IsPull }}
3737
{{if (index $.CommitStatus .PullRequest.ID)}}
3838
{{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}}
3939
{{end}}
4040
{{end}}
4141
</a>
42-
<span class="labels-list">
42+
<span class="labels-list ml-2">
4343
{{range .Labels}}
4444
<a class="ui label" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}{{if ne $.listType "milestone"}}&milestone={{$.MilestoneID}}{{end}}&assignee={{$.AssigneeID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description | RenderEmojiPlain}}">{{.Name | RenderEmoji}}</a>
4545
{{end}}

web_src/less/_base.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ body {
176176
overflow-y: auto;
177177
display: flex;
178178
flex-direction: column;
179+
overflow-wrap: break-word;
179180
}
180181

181182
img {

web_src/less/_repository.less

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,23 +2620,11 @@
26202620
}
26212621
}
26222622

2623-
.labels-list {
2624-
display: inline-flex;
2625-
flex-wrap: wrap;
2626-
}
2627-
26282623
.labels-list .label {
2629-
margin-top: 1.5px;
2630-
margin-bottom: 1.5px;
2631-
margin-right: 3px;
2632-
margin-left: 0;
2624+
margin: 2px 0;
26332625
display: inline-block !important;
26342626
}
26352627

2636-
.labels-list .label:last-of-type {
2637-
margin-right: 0;
2638-
}
2639-
26402628
tbody.commit-list {
26412629
vertical-align: baseline;
26422630
}
@@ -2777,7 +2765,7 @@ tbody.commit-list {
27772765
align-items: center;
27782766
justify-content: space-between;
27792767
flex-wrap: wrap;
2780-
word-break: break-all;
2768+
word-break: break-word;
27812769
}
27822770

27832771
.repo-buttons {

web_src/less/shared/issuelist.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
font-size: 16px;
3030
min-width: 0;
3131
font-weight: 600;
32+
33+
> * {
34+
vertical-align: middle;
35+
}
3236
}
3337

3438
.issue-item-bottom-row {

0 commit comments

Comments
 (0)