Skip to content

Commit b5926ca

Browse files
committed
render to check
1 parent 36d6b9e commit b5926ca

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

modules/badge/badge.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func (t Text) TextLength() int {
3636
}
3737

3838
type Badge struct {
39+
IDPrefix string
3940
Color string
4041
FontSize int
4142
Label Text

routers/web/devtest/devtest.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"html/template"
88
"net/http"
99
"path"
10+
"strconv"
1011
"strings"
1112
"time"
1213
"unicode"
@@ -132,7 +133,8 @@ func prepareMockDataBadgeActionsSvg(ctx *context.Context) {
132133
}
133134
}
134135
var mockSVGs []template.HTML
135-
for _, b := range badges {
136+
for i, b := range badges {
137+
b.IDPrefix = "devtest-" + strconv.FormatInt(int64(i), 10) + "-"
136138
h, err := ctx.RenderToHTML("shared/actions/runner_badge", map[string]any{"Badge": b})
137139
if err != nil {
138140
ctx.ServerError("RenderToHTML", err)

templates/shared/actions/runner_badge.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{{.Badge.Width}}" height="20"
22
role="img" aria-label="{{.Badge.Label.Text}}: {{.Badge.Message.Text}}">
33
<title>{{.Badge.Label.Text}}: {{.Badge.Message.Text}}</title>
4-
<linearGradient id="s" x2="0" y2="100%">
4+
<linearGradient id="{{.Badge.IDPrefix}}s" x2="0" y2="100%">
55
<stop offset="0" stop-color="#bbb" stop-opacity=".1" />
66
<stop offset="1" stop-opacity=".1" />
77
</linearGradient>
8-
<clipPath id="r">
8+
<clipPath id="{{.Badge.IDPrefix}}r">
99
<rect width="{{.Badge.Width}}" height="20" rx="3" fill="#fff" />
1010
</clipPath>
11-
<g clip-path="url(#r)">
11+
<g clip-path="url(#{{.Badge.IDPrefix}}r)">
1212
<rect width="{{.Badge.Label.Width}}" height="20" fill="#555" />
1313
<rect x="{{.Badge.Label.Width}}" width="{{.Badge.Message.Width}}" height="20" fill="{{.Badge.Color}}" />
14-
<rect width="{{.Badge.Width}}" height="20" fill="url(#s)" />
14+
<rect width="{{.Badge.Width}}" height="20" fill="url(#{{.Badge.IDPrefix}}s)" />
1515
</g>
1616
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif"
1717
text-rendering="geometricPrecision" font-size="{{.Badge.FontSize}}">

0 commit comments

Comments
 (0)