107 lines
2.7 KiB
Plaintext
107 lines
2.7 KiB
Plaintext
|
|
// Code generated by wa-generator. DO NOT EDIT.
|
||
|
|
// Source: Web Awesome wa-button-group
|
||
|
|
|
||
|
|
package wa
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/a-h/templ"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Button groups can be used to group related buttons into sections.
|
||
|
|
//
|
||
|
|
// Web Awesome component: <wa-button-group>
|
||
|
|
|
||
|
|
// ButtonGroupProps holds all properties for the wa-button-group component
|
||
|
|
type ButtonGroupProps struct {
|
||
|
|
// A label to use for the button group. This won't be displayed on the screen, but it will be announced by assistive
|
||
|
|
Label string `attr:"label"`
|
||
|
|
// The button group's orientation.
|
||
|
|
// Valid values: "horizontal", "vertical"
|
||
|
|
Orientation string `attr:"orientation"`
|
||
|
|
|
||
|
|
// Events
|
||
|
|
|
||
|
|
// Slots contains named slot content
|
||
|
|
Slots ButtonGroupSlots
|
||
|
|
|
||
|
|
// Attrs contains additional HTML attributes
|
||
|
|
Attrs templ.Attributes
|
||
|
|
}
|
||
|
|
|
||
|
|
// ButtonGroupBuilder provides a fluent API for constructing ButtonGroupProps
|
||
|
|
type ButtonGroupBuilder struct {
|
||
|
|
props ButtonGroupProps
|
||
|
|
}
|
||
|
|
|
||
|
|
// NewButtonGroup creates a new builder for wa-button-group
|
||
|
|
func NewButtonGroup() *ButtonGroupBuilder {
|
||
|
|
return &ButtonGroupBuilder{}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Label sets the label attribute
|
||
|
|
// A label to use for the button group. This won't be displayed on the screen, but it will be announced by assistive
|
||
|
|
func (b *ButtonGroupBuilder) Label(v string) *ButtonGroupBuilder {
|
||
|
|
b.props.Label = v
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Orientation sets the orientation attribute
|
||
|
|
// The button group's orientation.
|
||
|
|
func (b *ButtonGroupBuilder) Orientation(v string) *ButtonGroupBuilder {
|
||
|
|
b.props.Orientation = v
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Attr adds a custom HTML attribute
|
||
|
|
func (b *ButtonGroupBuilder) Attr(name, value string) *ButtonGroupBuilder {
|
||
|
|
if b.props.Attrs == nil {
|
||
|
|
b.props.Attrs = templ.Attributes{}
|
||
|
|
}
|
||
|
|
b.props.Attrs[name] = value
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Attrs merges multiple attributes
|
||
|
|
func (b *ButtonGroupBuilder) Attrs(attrs templ.Attributes) *ButtonGroupBuilder {
|
||
|
|
if b.props.Attrs == nil {
|
||
|
|
b.props.Attrs = templ.Attributes{}
|
||
|
|
}
|
||
|
|
for k, v := range attrs {
|
||
|
|
b.props.Attrs[k] = v
|
||
|
|
}
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Props returns the built properties
|
||
|
|
func (b *ButtonGroupBuilder) Props() ButtonGroupProps {
|
||
|
|
return b.props
|
||
|
|
}
|
||
|
|
|
||
|
|
// Build returns the props (alias for Props for semantic clarity)
|
||
|
|
func (b *ButtonGroupBuilder) Build() ButtonGroupProps {
|
||
|
|
return b.props
|
||
|
|
}
|
||
|
|
|
||
|
|
// ButtonGroup renders the wa-button-group component
|
||
|
|
templ ButtonGroup(props ButtonGroupProps) {
|
||
|
|
<wa-button-group
|
||
|
|
if props.Label != "" {
|
||
|
|
label={ props.Label }
|
||
|
|
}
|
||
|
|
if props.Orientation != "" {
|
||
|
|
orientation={ props.Orientation }
|
||
|
|
}
|
||
|
|
{ props.Attrs... }
|
||
|
|
>
|
||
|
|
{ children... }
|
||
|
|
</wa-button-group>
|
||
|
|
}
|
||
|
|
|
||
|
|
// ButtonGroupFunc renders with a builder function for inline configuration
|
||
|
|
templ ButtonGroupFunc(fn func(*ButtonGroupBuilder)) {
|
||
|
|
{{ b := NewButtonGroup(); fn(b) }}
|
||
|
|
@ButtonGroup(b.Props()) {
|
||
|
|
{ children... }
|
||
|
|
}
|
||
|
|
}
|