-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgropdown-button.templ
More file actions
33 lines (30 loc) · 891 Bytes
/
gropdown-button.templ
File metadata and controls
33 lines (30 loc) · 891 Bytes
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
package gropdown
const defaultButtonIcon = `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" width="16" height="16" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
</svg>
`
templ Button(label string, icons ...*ButtonIcon) {
@renderButton(label, getButtonIcon(icons))
}
templ renderButton(label string, icon *ButtonIcon) {
<button
id={ buttonId(label) }
class={ "gdd_button", templ.KV("gdd_button_icon_only", label == "") }
aria-label={ label }
aria-haspopup="true"
aria-expanded="false"
aria-controls={ menuId(label) }
>
if label != "" {
{ label }
}
<span class="gdd_sr_only">Open/Close icon</span>
<span class="gdd_button_icon">
if icon.value != "" {
@templ.Raw(icon.value)
} else {
@templ.Raw(defaultButtonIcon)
}
</span>
</button>
}