-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.go
99 lines (83 loc) · 2.1 KB
/
header.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
94
95
96
97
98
99
package carbon
import "io"
type header struct {
attrs []Attr
expandedByDefault bool
isSideNavOpen bool
uiShellAriaLabel string
href string
company any
platformName any
persistHamburgerMenu bool
expansionBreakpoint int16
}
var _ Component = (*header)(nil)
func Header() *header {
return &header{
attrs: nil,
expandedByDefault: false,
isSideNavOpen: false,
uiShellAriaLabel: "",
href: "",
company: nil,
platformName: nil,
persistHamburgerMenu: false,
expansionBreakpoint: 1056,
}
}
func (h *header) Attr(name string, value string) *header {
h.attrs = append(h.attrs, Attr{name, value})
return h
}
func (h *header) ExpandedByDefault(expandedByDefault bool) *header {
h.expandedByDefault = expandedByDefault
return h
}
func (h *header) IsSideNavOpen(isSideNavOpen bool) *header {
h.isSideNavOpen = isSideNavOpen
return h
}
func (h *header) UiShellAriaLabel(uiShellAriaLabel string) *header {
h.uiShellAriaLabel = uiShellAriaLabel
return h
}
func (h *header) Href(href string) *header {
h.href = href
return h
}
func (h *header) Company(company ...any) *header {
h.company = company
return h
}
func (h *header) PlatformName(platformName ...any) *header {
h.platformName = platformName
return h
}
func (h *header) PersistHamburgerMenu(persistHamburgerMenu bool) *header {
h.persistHamburgerMenu = persistHamburgerMenu
return h
}
func (h *header) ExpansionBreakpoint(expansionBreakpoint int16) *header {
h.expansionBreakpoint = expansionBreakpoint
return h
}
func (h *header) Render(w io.Writer) {
w.Write([]byte(`<header class="bx--header" aria-label="`))
io.WriteString(w, h.uiShellAriaLabel)
w.Write([]byte(`">`))
{
w.Write([]byte(`<a class="bx--header__name" href="`))
io.WriteString(w, h.href)
w.Write([]byte(`">`))
{
if h.company != nil {
w.Write([]byte(`<span class="bx--header__name--prefix">`))
renderAny(w, h.company)
w.Write([]byte(` </span>`))
}
renderAny(w, h.platformName)
}
w.Write([]byte(`</a>`))
}
w.Write([]byte(`</header>`))
}