forked from the42/badge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstyle.go
30 lines (25 loc) · 1.24 KB
/
style.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package badge
import "strings"
// TODO: Think of using a sort of SVG minifier after template was executed.
var flatTemplate = strings.TrimSpace(`
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{{.Bounds.Dx}}" height="20">
<linearGradient id="smooth" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<mask id="round">
<rect width="{{.Bounds.Dx}}" height="20" rx="3" fill="#fff"/>
</mask>
<g mask="url(#round)">
<rect width="{{.Bounds.SubjectDx}}" height="20" fill="#555"/>
<rect x="{{.Bounds.SubjectDx}}" width="{{.Bounds.StatusDx}}" height="20" fill="{{or .Color "#4c1" | html}}"/>
<rect width="{{.Bounds.Dx}}" height="20" fill="url(#smooth)"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="{{.Bounds.SubjectX}}" y="15" fill="#010101" fill-opacity=".3">{{.Subject | html}}</text>
<text x="{{.Bounds.SubjectX}}" y="14">{{.Subject | html}}</text>
<text x="{{.Bounds.StatusX}}" y="15" fill="#010101" fill-opacity=".3">{{.Status | html}}</text>
<text x="{{.Bounds.StatusX}}" y="14">{{.Status | html}}</text>
</g>
</svg>
`)