-
Notifications
You must be signed in to change notification settings - Fork 0
/
box.go
76 lines (65 loc) · 1.83 KB
/
box.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
package docgo
import (
"context"
h "github.com/theplant/htmlgo"
)
type BoxBuilder struct {
tag *h.HTMLTagBuilder
text string
titleTag *h.HTMLTagBuilder
}
func Note(text string) (r *BoxBuilder) {
r = &BoxBuilder{
tag: h.Tag("div").Class("mt-6 p-4 rounded-2xl bg-gray-50 border border-gray-400 shadow"),
}
r.text = text
r.titleTag = h.Tag("label").Text("Note").Class("text-gray-700 font-normal")
return
}
func Important(text string) (r *BoxBuilder) {
r = &BoxBuilder{
tag: h.Tag("div").Class("mt-6 p-4 rounded-2xl bg-yellow-50 border border-yellow-700 shadow"),
}
r.text = text
r.titleTag = h.Tag("label").Text("Important").Class("text-yellow-700 font-normal")
return
}
func Deprecated(text string) (r *BoxBuilder) {
r = &BoxBuilder{
tag: h.Tag("div").Class("mt-6 p-4 rounded-2xl bg-pink-50 border border-yellow-700 shadow"),
}
r.text = text
r.titleTag = h.Tag("label").Text("Important").Class("text-yellow-700 font-normal")
return
}
func Experiment(text string) (r *BoxBuilder) {
r = &BoxBuilder{
tag: h.Tag("div").Class("mt-6 p-4 rounded-2xl bg-purple-50 border border-purple-800 shadow"),
}
r.text = text
r.titleTag = h.Tag("label").Text("Experiment").Class("text-purple-800 font-normal")
return
}
func Tip(text string) (r *BoxBuilder) {
r = &BoxBuilder{
tag: h.Tag("div").Class("mt-6 p-4 rounded-2xl bg-green-50 border border-green-700 shadow"),
}
r.text = text
r.titleTag = h.Tag("label").Text("Tip").Class("text-green-700 font-normal")
return
}
func (b *BoxBuilder) Title(v string) (r *BoxBuilder) {
b.titleTag.Text(v)
return b
}
func (b *BoxBuilder) Children(vs ...h.HTMLComponent) (r *BoxBuilder) {
b.tag.Children(vs...)
return b
}
func (b *BoxBuilder) MarshalHTML(ctx context.Context) ([]byte, error) {
b.tag.Children(
b.titleTag,
h.P().Text(b.text).Class("mt-2"),
)
return b.tag.MarshalHTML(ctx)
}