106 lines
2.3 KiB
Plaintext
106 lines
2.3 KiB
Plaintext
|
|
// Code generated by wa-generator. DO NOT EDIT.
|
||
|
|
// Source: Web Awesome wa-tab-panel
|
||
|
|
|
||
|
|
package wa
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/a-h/templ"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Tab panels are used inside tab groups to display tabbed content.
|
||
|
|
//
|
||
|
|
// Web Awesome component: <wa-tab-panel>
|
||
|
|
|
||
|
|
// TabPanelProps holds all properties for the wa-tab-panel component
|
||
|
|
type TabPanelProps struct {
|
||
|
|
// The tab panel's name.
|
||
|
|
Name string `attr:"name"`
|
||
|
|
// When true, the tab panel will be shown.
|
||
|
|
Active bool `attr:"active"`
|
||
|
|
|
||
|
|
// Events
|
||
|
|
|
||
|
|
// Slots contains named slot content
|
||
|
|
Slots TabPanelSlots
|
||
|
|
|
||
|
|
// Attrs contains additional HTML attributes
|
||
|
|
Attrs templ.Attributes
|
||
|
|
}
|
||
|
|
|
||
|
|
// TabPanelBuilder provides a fluent API for constructing TabPanelProps
|
||
|
|
type TabPanelBuilder struct {
|
||
|
|
props TabPanelProps
|
||
|
|
}
|
||
|
|
|
||
|
|
// NewTabPanel creates a new builder for wa-tab-panel
|
||
|
|
func NewTabPanel() *TabPanelBuilder {
|
||
|
|
return &TabPanelBuilder{}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Name sets the name attribute
|
||
|
|
// The tab panel's name.
|
||
|
|
func (b *TabPanelBuilder) Name(v string) *TabPanelBuilder {
|
||
|
|
b.props.Name = v
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Active sets the active attribute
|
||
|
|
// When true, the tab panel will be shown.
|
||
|
|
func (b *TabPanelBuilder) Active(v bool) *TabPanelBuilder {
|
||
|
|
b.props.Active = v
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Attr adds a custom HTML attribute
|
||
|
|
func (b *TabPanelBuilder) Attr(name, value string) *TabPanelBuilder {
|
||
|
|
if b.props.Attrs == nil {
|
||
|
|
b.props.Attrs = templ.Attributes{}
|
||
|
|
}
|
||
|
|
b.props.Attrs[name] = value
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Attrs merges multiple attributes
|
||
|
|
func (b *TabPanelBuilder) Attrs(attrs templ.Attributes) *TabPanelBuilder {
|
||
|
|
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 *TabPanelBuilder) Props() TabPanelProps {
|
||
|
|
return b.props
|
||
|
|
}
|
||
|
|
|
||
|
|
// Build returns the props (alias for Props for semantic clarity)
|
||
|
|
func (b *TabPanelBuilder) Build() TabPanelProps {
|
||
|
|
return b.props
|
||
|
|
}
|
||
|
|
|
||
|
|
// TabPanel renders the wa-tab-panel component
|
||
|
|
templ TabPanel(props TabPanelProps) {
|
||
|
|
<wa-tab-panel
|
||
|
|
if props.Name != "" {
|
||
|
|
name={ props.Name }
|
||
|
|
}
|
||
|
|
if props.Active {
|
||
|
|
active
|
||
|
|
}
|
||
|
|
{ props.Attrs... }
|
||
|
|
>
|
||
|
|
{ children... }
|
||
|
|
</wa-tab-panel>
|
||
|
|
}
|
||
|
|
|
||
|
|
// TabPanelFunc renders with a builder function for inline configuration
|
||
|
|
templ TabPanelFunc(fn func(*TabPanelBuilder)) {
|
||
|
|
{{ b := NewTabPanel(); fn(b) }}
|
||
|
|
@TabPanel(b.Props()) {
|
||
|
|
{ children... }
|
||
|
|
}
|
||
|
|
}
|