Skip to content

Commit da4bb6f

Browse files
silverwindlunny
andauthored
Fix label styles affecting shabox (#13734)
* Fix label styles affecting shabox Add common parent .labels-list to issue labels lists to prevent affecting other elements. Fixes: #13704 * Update templates/shared/issuelist.tmpl * Update templates/shared/issuelist.tmpl Co-authored-by: Lunny Xiao <[email protected]>
1 parent b2435af commit da4bb6f

File tree

4 files changed

+23
-35
lines changed

4 files changed

+23
-35
lines changed

modules/templates/helper.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,12 @@ func NewFuncMap() []template.FuncMap {
364364
return ""
365365
},
366366
"RenderLabels": func(labels []*models.Label) template.HTML {
367-
html := ""
368-
367+
html := `<span class="labels-list">`
369368
for _, label := range labels {
370-
html = fmt.Sprintf("%s<div class='ui label' style='color: %s; background-color: %s'>%s</div>",
371-
html, label.ForegroundColor(), label.Color, RenderEmoji(label.Name))
369+
html += fmt.Sprintf("<div class='ui label' style='color: %s; background-color: %s'>%s</div>",
370+
label.ForegroundColor(), label.Color, RenderEmoji(label.Name))
372371
}
373-
372+
html += "</span>"
374373
return template.HTML(html)
375374
},
376375
}}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<div class="ui labels list">
22
<span class="no-select item {{if .ctx.HasSelectedLabel}}hide{{end}}">{{.ctx.i18n.Tr "repo.issues.new.no_label"}}</span>
3-
{{range .ctx.Labels}}
4-
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
5-
{{end}}
6-
{{range .ctx.OrgLabels}}
7-
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
8-
{{end}}
3+
<span class="labels-list">
4+
{{range .ctx.Labels}}
5+
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
6+
{{end}}
7+
{{range .ctx.OrgLabels}}
8+
{{template "repo/issue/labels/label" dict "root" $ "label" .}}
9+
{{end}}
10+
</span>
911
</div>

templates/shared/issuelist.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
{{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}}
3838
{{end}}
3939
{{end}}
40-
{{range .Labels}}
41-
<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>
42-
{{end}}
40+
<span class="labels-list">
41+
{{range .Labels}}
42+
<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>
43+
{{end}}
44+
</span>
4345
</div>
4446
<div class="desc issue-item-bottom-row df ac fw my-1">
4547
<a class="index ml-0 mr-2" href="{{if .HTMLURL}}{{.HTMLURL}}{{else}}{{$.Link}}/{{.Index}}{{end}}">

web_src/less/_repository.less

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,35 +2856,20 @@
28562856
}
28572857
}
28582858

2859-
.labels.list {
2860-
display: flex;
2859+
.labels-list {
2860+
display: inline-flex;
28612861
flex-wrap: wrap;
28622862
}
28632863

2864-
.labels.list .item,
2865-
.timeline-item .label {
2866-
padding: .3em .5em !important;
2867-
margin-left: 0;
2868-
margin-right: 0;
2869-
margin-bottom: 3px;
2870-
}
2871-
2872-
.issue-item-top-row .label {
2873-
margin-left: 0;
2874-
margin-right: 0;
2864+
.labels-list .label {
28752865
margin-top: 1.5px;
28762866
margin-bottom: 1.5px;
2877-
}
2878-
2879-
.labels.list .item,
2880-
.timeline-item .label,
2881-
.issue-item-top-row .label {
28822867
margin-right: 3px;
2883-
display: inline !important;
2868+
margin-left: 0;
2869+
display: inline-block !important;
28842870
}
28852871

2886-
.timeline-item .label:last-of-type,
2887-
.issue-item-top-row .label:last-of-type {
2872+
.labels-list .label:last-of-type {
28882873
margin-right: 0;
28892874
}
28902875

0 commit comments

Comments
 (0)