-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuttons.go
62 lines (46 loc) · 1.1 KB
/
buttons.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
package dhtmlbs
import (
"html"
"github.com/mitoteam/dhtml"
)
//https://getbootstrap.com/docs/5.3/components/buttons/
type BtnElement struct {
tag *dhtml.Tag
}
// force interface implementation declaring fake variable
var _ dhtml.ElementI = (*BtnElement)(nil)
func NewBtn() *BtnElement {
return &BtnElement{
tag: dhtml.NewTag("a"),
}
}
func (e *BtnElement) Href(url string) *BtnElement {
e.tag.Attribute("href", url)
return e
}
func (e *BtnElement) Label(v any) *BtnElement {
e.tag.Append(v)
return e
}
func (e *BtnElement) Title(title string) *BtnElement {
e.tag.Title(title)
return e
}
func (e *BtnElement) Confirm(message string) *BtnElement {
e.tag.AttributeUnsafe("onclick", "return confirm(\""+html.EscapeString(message)+"\");")
return e
}
func (e *BtnElement) Target(value string) *BtnElement {
e.tag.Attribute("target", value)
return e
}
func (e *BtnElement) Class(v any) *BtnElement {
e.tag.Class(v)
return e
}
func (e *BtnElement) GetTags() dhtml.TagList {
e.tag.GetClasses().
Add("btn text-nowrap").
AddFromSet(BtnVariantClasses, DefaultBtnVariantClass)
return e.tag.GetTags()
}