Skip to content

Commit b5a0388

Browse files
committed
add animation
1 parent dfd4bfb commit b5a0388

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

internal/poll/poll_option.go

+17-5
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,34 @@ var option = `<svg width="448px" height="58px" viewBox="0 0 448 58" version="1.1
1616
<g id="poll">
1717
<g id="Group" transform="translate(17.000000, 10.000000)">
1818
<rect id="Rectangle" fill="#F1F3F5" x="0" y="19" width="334" height="14" rx="2"></rect>
19-
<rect id="Rectangle" fill="#7950F2" x="0" y="19" width="{{.Width}}" height="14" rx="2"></rect>
19+
<rect id="Rectangle" fill="#7950F2" x="0" y="19" width="0" height="14" rx="2">
20+
<animate attributeName="width"
21+
begin="0.5s"
22+
dur="600ms"
23+
from="0"
24+
to="{{.Width}}"
25+
repeatCount="1"
26+
fill="freeze"
27+
calcMode="spline"
28+
keyTimes="0; 1"
29+
keySplines="0.3, 0.61, 0.355, 1.2" />
30+
</rect>
2031
<text id="100%" font-family="{{.FontFamily}}" font-size="12" font-weight="normal" letter-spacing="1.857333" fill="#212529">
2132
<tspan x="344" y="30">{{.Percent}}%</tspan>
2233
</text>
2334
<text id="Option-A" font-family="{{.FontFamily}}" font-size="12" font-weight="bold" letter-spacing="1" fill="#212529">
2435
<tspan x="0" y="12">{{.Name}}</tspan>
2536
</text>
2637
<text id="150" font-family="{{.FontFamily}}" font-size="12" font-weight="normal" letter-spacing="1" fill="#868E96">
27-
{{if .Votes}}
28-
<tspan x="386" y="30">{{.Votes}}</tspan>
29-
{{end}}
38+
{{if .Votes}}
39+
<tspan x="386" y="30">{{.Votes}}</tspan>
40+
{{end}}
3041
</text>
3142
</g>
3243
</g>
3344
</g>
34-
</svg>`
45+
</svg>
46+
`
3547

3648
// Option represents a single poll option.
3749
type Option struct {

main.go

+7
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ func getPollOptionVote(w http.ResponseWriter, r *http.Request) {
8282
return
8383
}
8484

85+
// if url := r.Header.Get("Referer"); url != "" {
86+
// log.WithField("url", url).Info("redirect")
87+
// w.Header().Set("Location", url)
88+
// response.Found(w, "Voted!")
89+
// return
90+
// }
91+
8592
response.OK(w, "Voted!")
8693
}
8794

0 commit comments

Comments
 (0)