forked from nobonobo/bootstrap4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
progress.go
60 lines (55 loc) · 1.49 KB
/
progress.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package bootstrap4
import (
"github.com/gowasm/vecty"
"github.com/gowasm/vecty/elem"
"github.com/gowasm/vecty/prop"
)
// Progress ...
type Progress struct {
vecty.Core
ID string `vecty:"prop"`
Height string `vecty:"prop"`
Markup vecty.MarkupList `vecty:"prop"`
Children vecty.ComponentOrHTML `vecty:"prop"`
}
// Render ...
func (c *Progress) Render() vecty.ComponentOrHTML {
return elem.Div(
vecty.Markup(
vecty.MarkupIf(len(c.ID) > 0, prop.ID(c.ID)),
vecty.Class("progress"),
vecty.MarkupIf(len(c.Height) > 0, vecty.Style("height", c.Height)),
),
c.Markup,
c.Children,
)
}
// ProgressBar ...
type ProgressBar struct {
vecty.Core
ID string `vecty:"prop"`
Kind Kind `vecty:"prop"`
Width string `vecty:"prop"`
Striped bool `vecty:"prop"`
Animated bool `vecty:"prop"`
Markup vecty.MarkupList `vecty:"prop"`
Children vecty.ComponentOrHTML `vecty:"prop"`
}
// Render ...
func (c *ProgressBar) Render() vecty.ComponentOrHTML {
return elem.Div(
vecty.Markup(
vecty.MarkupIf(len(c.ID) > 0, prop.ID(c.ID)),
vecty.ClassMap{
"progress-bar": true,
"progress-bar-striped": c.Striped,
"progress-bar-animated": c.Animated,
"bg-" + c.Kind.String(): len(c.Kind) > 0,
},
vecty.Attribute("role", "progress-bar"),
vecty.MarkupIf(len(c.Width) > 0, vecty.Style("width", c.Width)),
),
c.Markup,
c.Children,
)
}