112 lines
2.8 KiB
Plaintext
112 lines
2.8 KiB
Plaintext
|
|
// Code generated by wa-generator. DO NOT EDIT.
|
||
|
|
// Source: Web Awesome wa-breadcrumb
|
||
|
|
|
||
|
|
package wa
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/a-h/templ"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Breadcrumbs provide a group of links so users can easily navigate a website's hierarchy.
|
||
|
|
//
|
||
|
|
// Web Awesome component: <wa-breadcrumb>
|
||
|
|
|
||
|
|
// BreadcrumbProps holds all properties for the wa-breadcrumb component
|
||
|
|
type BreadcrumbProps struct {
|
||
|
|
// The label to use for the breadcrumb control. This will not be shown on the screen, but it will be announced by
|
||
|
|
Label string `attr:"label"`
|
||
|
|
|
||
|
|
// Events
|
||
|
|
|
||
|
|
// Slots contains named slot content
|
||
|
|
Slots BreadcrumbSlots
|
||
|
|
|
||
|
|
// Attrs contains additional HTML attributes
|
||
|
|
Attrs templ.Attributes
|
||
|
|
}
|
||
|
|
|
||
|
|
// BreadcrumbSlots holds named slot content for the component
|
||
|
|
type BreadcrumbSlots struct {
|
||
|
|
// The separator to use between breadcrumb items. Works best with <wa-icon>.
|
||
|
|
Separator templ.Component
|
||
|
|
}
|
||
|
|
|
||
|
|
// BreadcrumbBuilder provides a fluent API for constructing BreadcrumbProps
|
||
|
|
type BreadcrumbBuilder struct {
|
||
|
|
props BreadcrumbProps
|
||
|
|
}
|
||
|
|
|
||
|
|
// NewBreadcrumb creates a new builder for wa-breadcrumb
|
||
|
|
func NewBreadcrumb() *BreadcrumbBuilder {
|
||
|
|
return &BreadcrumbBuilder{}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Label sets the label attribute
|
||
|
|
// The label to use for the breadcrumb control. This will not be shown on the screen, but it will be announced by
|
||
|
|
func (b *BreadcrumbBuilder) Label(v string) *BreadcrumbBuilder {
|
||
|
|
b.props.Label = v
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// SeparatorSlot sets the separator slot content
|
||
|
|
// The separator to use between breadcrumb items. Works best with <wa-icon>.
|
||
|
|
func (b *BreadcrumbBuilder) SeparatorSlot(c templ.Component) *BreadcrumbBuilder {
|
||
|
|
b.props.Slots.Separator = c
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Attr adds a custom HTML attribute
|
||
|
|
func (b *BreadcrumbBuilder) Attr(name, value string) *BreadcrumbBuilder {
|
||
|
|
if b.props.Attrs == nil {
|
||
|
|
b.props.Attrs = templ.Attributes{}
|
||
|
|
}
|
||
|
|
b.props.Attrs[name] = value
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Attrs merges multiple attributes
|
||
|
|
func (b *BreadcrumbBuilder) Attrs(attrs templ.Attributes) *BreadcrumbBuilder {
|
||
|
|
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 *BreadcrumbBuilder) Props() BreadcrumbProps {
|
||
|
|
return b.props
|
||
|
|
}
|
||
|
|
|
||
|
|
// Build returns the props (alias for Props for semantic clarity)
|
||
|
|
func (b *BreadcrumbBuilder) Build() BreadcrumbProps {
|
||
|
|
return b.props
|
||
|
|
}
|
||
|
|
|
||
|
|
// Breadcrumb renders the wa-breadcrumb component
|
||
|
|
templ Breadcrumb(props BreadcrumbProps) {
|
||
|
|
<wa-breadcrumb
|
||
|
|
if props.Label != "" {
|
||
|
|
label={ props.Label }
|
||
|
|
}
|
||
|
|
{ props.Attrs... }
|
||
|
|
>
|
||
|
|
if props.Slots.Separator != nil {
|
||
|
|
<div slot="separator">
|
||
|
|
@props.Slots.Separator
|
||
|
|
</div>
|
||
|
|
}
|
||
|
|
{ children... }
|
||
|
|
</wa-breadcrumb>
|
||
|
|
}
|
||
|
|
|
||
|
|
// BreadcrumbFunc renders with a builder function for inline configuration
|
||
|
|
templ BreadcrumbFunc(fn func(*BreadcrumbBuilder)) {
|
||
|
|
{{ b := NewBreadcrumb(); fn(b) }}
|
||
|
|
@Breadcrumb(b.Props()) {
|
||
|
|
{ children... }
|
||
|
|
}
|
||
|
|
}
|