-
Notifications
You must be signed in to change notification settings - Fork 0
/
frow.go
93 lines (80 loc) · 2.37 KB
/
frow.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package compton
import (
"github.com/boggydigital/compton/consts/align"
"github.com/boggydigital/compton/consts/color"
"github.com/boggydigital/compton/consts/compton_atoms"
"github.com/boggydigital/compton/consts/direction"
"github.com/boggydigital/compton/consts/font_weight"
"github.com/boggydigital/compton/consts/size"
)
type FrowElement struct {
*BaseElement
r Registrar
}
func (f *FrowElement) Elements(elements ...Element) *FrowElement {
if fi := f.GetFirstElementByTagName(compton_atoms.FlexItems); fi != nil {
fi.Append(elements...)
}
return f
}
func (f *FrowElement) PropVal(p, v string) *FrowElement {
if fi := f.GetFirstElementByTagName(compton_atoms.FlexItems); fi != nil {
fi.Append(Fspan(f.r, p+":").ForegroundColor(color.Gray))
fi.Append(Fspan(f.r, v))
}
return f
}
func (f *FrowElement) Heading(title string) *FrowElement {
if fi := f.GetFirstElementByTagName(compton_atoms.FlexItems); fi != nil {
fi.Append(Fspan(f.r, title).FontWeight(font_weight.Bolder))
}
return f
}
func (f *FrowElement) Highlight(title string) *FrowElement {
if fi := f.GetFirstElementByTagName(compton_atoms.FlexItems); fi != nil {
fi.Append(Fspan(f.r, title).FontWeight(font_weight.Bolder).ForegroundColor(color.Orange))
}
return f
}
func (f *FrowElement) Icon(class string) *FrowElement {
if fi := f.GetFirstElementByTagName(compton_atoms.FlexItems); fi != nil {
icon := SvgUse(f.r, Circle)
if class != "" {
icon.AddClass(class)
}
fi.Append(icon)
}
return f
}
func (f *FrowElement) IconColor(c color.Color) *FrowElement {
if fi := f.GetFirstElementByTagName(compton_atoms.FlexItems); fi != nil {
fi.Append(SvgUse(f.r, Circle).ForegroundColor(c))
}
return f
}
func (f *FrowElement) LinkExternal(title, href string) *FrowElement {
if fi := f.GetFirstElementByTagName(compton_atoms.FlexItems); fi != nil {
linkDecoration := Fspan(f.r, "").
FontWeight(font_weight.Bolder).
ForegroundColor(color.Cyan)
link := AText(title, href)
link.SetAttribute("target", "_top")
linkDecoration.Append(link)
fi.Append(linkDecoration)
}
return f
}
func Frow(r Registrar) *FrowElement {
frow := &FrowElement{
BaseElement: NewElement(compton_atoms.Frow, nil),
r: r,
}
fi := FlexItems(r, direction.Row).
ColumnGap(size.XSmall).
RowGap(size.Unset).
AlignItems(align.Center).
FontSize(size.Small)
fi.AddClass("frow")
frow.Append(fi)
return frow
}