Skip to content

Commit

Permalink
Improve label and text wrapping (go-gitea#14113)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
silverwind and lunny authored Dec 29, 2020
1 parent cfc3916 commit 8e5aea8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func NewFuncMap() []template.FuncMap {
"RenderLabels": func(labels []*models.Label) template.HTML {
html := `<span class="labels-list">`
for _, label := range labels {
html += fmt.Sprintf("<div class='ui label' style='color: %s; background-color: %s'>%s</div>",
html += fmt.Sprintf("<div class='ui label' style='color: %s; background-color: %s'>%s</div> ",
label.ForegroundColor(), label.Color, RenderEmoji(label.Name))
}
html += "</span>"
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/issue/labels/label.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
style="color: {{.label.ForegroundColor}}; background-color: {{.label.Color}}"
title="{{.label.Description | RenderEmojiPlain}}"
>
{{.label.Name | RenderEmoji}}
{{.label.Name | RenderEmoji}}
</a>
6 changes: 3 additions & 3 deletions templates/shared/issuelist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
</div>
</div>
<div class="issue-item-main f1 fc df">
<div class="issue-item-top-row df ac fw">
<a class="title mr-3" href="{{if .HTMLURL}}{{.HTMLURL}}{{else}}{{$.Link}}/{{.Index}}{{end}}">
<div class="issue-item-top-row">
<a class="title" href="{{if .HTMLURL}}{{.HTMLURL}}{{else}}{{$.Link}}/{{.Index}}{{end}}">
{{RenderEmoji .Title}}
{{if .IsPull }}
{{if (index $.CommitStatus .PullRequest.ID)}}
{{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}}
{{end}}
{{end}}
</a>
<span class="labels-list">
<span class="labels-list ml-2">
{{range .Labels}}
<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>
{{end}}
Expand Down
1 change: 1 addition & 0 deletions web_src/less/_base.less
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ body {
overflow-y: auto;
display: flex;
flex-direction: column;
overflow-wrap: break-word;
}

img {
Expand Down
16 changes: 2 additions & 14 deletions web_src/less/_repository.less
Original file line number Diff line number Diff line change
Expand Up @@ -2620,23 +2620,11 @@
}
}

.labels-list {
display: inline-flex;
flex-wrap: wrap;
}

.labels-list .label {
margin-top: 1.5px;
margin-bottom: 1.5px;
margin-right: 3px;
margin-left: 0;
margin: 2px 0;
display: inline-block !important;
}

.labels-list .label:last-of-type {
margin-right: 0;
}

tbody.commit-list {
vertical-align: baseline;
}
Expand Down Expand Up @@ -2777,7 +2765,7 @@ tbody.commit-list {
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
word-break: break-all;
word-break: break-word;
}

.repo-buttons {
Expand Down
4 changes: 4 additions & 0 deletions web_src/less/shared/issuelist.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
font-size: 16px;
min-width: 0;
font-weight: 600;

> * {
vertical-align: middle;
}
}

.issue-item-bottom-row {
Expand Down

0 comments on commit 8e5aea8

Please sign in to comment.