165 lines
4.6 KiB
Plaintext
165 lines
4.6 KiB
Plaintext
// Code generated by wa-generator. DO NOT EDIT.
|
|
// Source: Web Awesome wa-breadcrumb-item
|
|
|
|
package wa
|
|
|
|
import (
|
|
"github.com/a-h/templ"
|
|
)
|
|
|
|
// Breadcrumb Items are used inside breadcrumbs to represent different links.
|
|
//
|
|
// Web Awesome component: <wa-breadcrumb-item>
|
|
|
|
// BreadcrumbItemProps holds all properties for the wa-breadcrumb-item component
|
|
type BreadcrumbItemProps struct {
|
|
// Optional URL to direct the user to when the breadcrumb item is activated. When set, a link will be rendered
|
|
Href string `attr:"href"`
|
|
// Tells the browser where to open the link. Only used when href is set.
|
|
// Valid values: "_blank", "_parent", "_self", "_top"
|
|
Target string `attr:"target"`
|
|
// The rel attribute to use on the link. Only used when href is set.
|
|
Rel string `attr:"rel"`
|
|
|
|
// Events
|
|
|
|
// Slots contains named slot content
|
|
Slots BreadcrumbItemSlots
|
|
|
|
// Attrs contains additional HTML attributes
|
|
Attrs templ.Attributes
|
|
}
|
|
|
|
// BreadcrumbItemSlots holds named slot content for the component
|
|
type BreadcrumbItemSlots struct {
|
|
// An element, such as <wa-icon>, placed before the label.
|
|
Start templ.Component
|
|
// An element, such as <wa-icon>, placed after the label.
|
|
End templ.Component
|
|
// The separator to use for the breadcrumb item. This will only change the separator for this item. If you want to chang...
|
|
Separator templ.Component
|
|
}
|
|
|
|
// BreadcrumbItemBuilder provides a fluent API for constructing BreadcrumbItemProps
|
|
type BreadcrumbItemBuilder struct {
|
|
props BreadcrumbItemProps
|
|
}
|
|
|
|
// NewBreadcrumbItem creates a new builder for wa-breadcrumb-item
|
|
func NewBreadcrumbItem() *BreadcrumbItemBuilder {
|
|
return &BreadcrumbItemBuilder{}
|
|
}
|
|
|
|
// Href sets the href attribute
|
|
// Optional URL to direct the user to when the breadcrumb item is activated. When set, a link will be rendered
|
|
func (b *BreadcrumbItemBuilder) Href(v string) *BreadcrumbItemBuilder {
|
|
b.props.Href = v
|
|
return b
|
|
}
|
|
|
|
// Target sets the target attribute
|
|
// Tells the browser where to open the link. Only used when href is set.
|
|
func (b *BreadcrumbItemBuilder) Target(v string) *BreadcrumbItemBuilder {
|
|
b.props.Target = v
|
|
return b
|
|
}
|
|
|
|
// Rel sets the rel attribute
|
|
// The rel attribute to use on the link. Only used when href is set.
|
|
func (b *BreadcrumbItemBuilder) Rel(v string) *BreadcrumbItemBuilder {
|
|
b.props.Rel = v
|
|
return b
|
|
}
|
|
|
|
// StartSlot sets the start slot content
|
|
// An element, such as <wa-icon>, placed before the label.
|
|
func (b *BreadcrumbItemBuilder) StartSlot(c templ.Component) *BreadcrumbItemBuilder {
|
|
b.props.Slots.Start = c
|
|
return b
|
|
}
|
|
|
|
// EndSlot sets the end slot content
|
|
// An element, such as <wa-icon>, placed after the label.
|
|
func (b *BreadcrumbItemBuilder) EndSlot(c templ.Component) *BreadcrumbItemBuilder {
|
|
b.props.Slots.End = c
|
|
return b
|
|
}
|
|
|
|
// SeparatorSlot sets the separator slot content
|
|
// The separator to use for the breadcrumb item. This will only change the separator for this item. If you want to chang...
|
|
func (b *BreadcrumbItemBuilder) SeparatorSlot(c templ.Component) *BreadcrumbItemBuilder {
|
|
b.props.Slots.Separator = c
|
|
return b
|
|
}
|
|
|
|
// Attr adds a custom HTML attribute
|
|
func (b *BreadcrumbItemBuilder) Attr(name, value string) *BreadcrumbItemBuilder {
|
|
if b.props.Attrs == nil {
|
|
b.props.Attrs = templ.Attributes{}
|
|
}
|
|
b.props.Attrs[name] = value
|
|
return b
|
|
}
|
|
|
|
// Attrs merges multiple attributes
|
|
func (b *BreadcrumbItemBuilder) Attrs(attrs templ.Attributes) *BreadcrumbItemBuilder {
|
|
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 *BreadcrumbItemBuilder) Props() BreadcrumbItemProps {
|
|
return b.props
|
|
}
|
|
|
|
// Build returns the props (alias for Props for semantic clarity)
|
|
func (b *BreadcrumbItemBuilder) Build() BreadcrumbItemProps {
|
|
return b.props
|
|
}
|
|
|
|
// BreadcrumbItem renders the wa-breadcrumb-item component
|
|
templ BreadcrumbItem(props BreadcrumbItemProps) {
|
|
<wa-breadcrumb-item
|
|
if props.Href != "" {
|
|
href={ props.Href }
|
|
}
|
|
if props.Target != "" {
|
|
target={ props.Target }
|
|
}
|
|
if props.Rel != "" {
|
|
rel={ props.Rel }
|
|
}
|
|
{ props.Attrs... }
|
|
>
|
|
if props.Slots.Start != nil {
|
|
<div slot="start">
|
|
@props.Slots.Start
|
|
</div>
|
|
}
|
|
if props.Slots.End != nil {
|
|
<div slot="end">
|
|
@props.Slots.End
|
|
</div>
|
|
}
|
|
if props.Slots.Separator != nil {
|
|
<div slot="separator">
|
|
@props.Slots.Separator
|
|
</div>
|
|
}
|
|
{ children... }
|
|
</wa-breadcrumb-item>
|
|
}
|
|
|
|
// BreadcrumbItemFunc renders with a builder function for inline configuration
|
|
templ BreadcrumbItemFunc(fn func(*BreadcrumbItemBuilder)) {
|
|
{{ b := NewBreadcrumbItem(); fn(b) }}
|
|
@BreadcrumbItem(b.Props()) {
|
|
{ children... }
|
|
}
|
|
}
|