Files
nebula/pkg/wa/tab.templ

106 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

2026-01-01 14:41:31 -05:00
// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-tab
package wa
import (
"github.com/a-h/templ"
)
// Tabs are used inside tab groups to represent and activate tab panels.
//
// Web Awesome component: <wa-tab>
// TabProps holds all properties for the wa-tab component
type TabProps struct {
// The name of the tab panel this tab is associated with. The panel must be located in the same tab group.
Panel string `attr:"panel"`
// Disables the tab and prevents selection.
Disabled bool `attr:"disabled"`
// Events
// Slots contains named slot content
Slots TabSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// TabBuilder provides a fluent API for constructing TabProps
type TabBuilder struct {
props TabProps
}
// NewTab creates a new builder for wa-tab
func NewTab() *TabBuilder {
return &TabBuilder{}
}
// Panel sets the panel attribute
// The name of the tab panel this tab is associated with. The panel must be located in the same tab group.
func (b *TabBuilder) Panel(v string) *TabBuilder {
b.props.Panel = v
return b
}
// Disabled sets the disabled attribute
// Disables the tab and prevents selection.
func (b *TabBuilder) Disabled(v bool) *TabBuilder {
b.props.Disabled = v
return b
}
// Attr adds a custom HTML attribute
func (b *TabBuilder) Attr(name, value string) *TabBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *TabBuilder) Attrs(attrs templ.Attributes) *TabBuilder {
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 *TabBuilder) Props() TabProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *TabBuilder) Build() TabProps {
return b.props
}
// Tab renders the wa-tab component
templ Tab(props TabProps) {
<wa-tab
if props.Panel != "" {
panel={ props.Panel }
}
if props.Disabled {
disabled
}
{ props.Attrs... }
>
{ children... }
</wa-tab>
}
// TabFunc renders with a builder function for inline configuration
templ TabFunc(fn func(*TabBuilder)) {
{{ b := NewTab(); fn(b) }}
@Tab(b.Props()) {
{ children... }
}
}