139 lines
3.3 KiB
Plaintext
139 lines
3.3 KiB
Plaintext
// Code generated by wa-generator. DO NOT EDIT.
|
|
// Source: Web Awesome wa-callout
|
|
|
|
package wa
|
|
|
|
import (
|
|
"github.com/a-h/templ"
|
|
)
|
|
|
|
// Callouts are used to display important messages inline.
|
|
//
|
|
// Web Awesome component: <wa-callout>
|
|
|
|
// CalloutProps holds all properties for the wa-callout component
|
|
type CalloutProps struct {
|
|
// The callout's theme variant. Defaults to brand if not within another element with a variant.
|
|
// Valid values: "brand", "neutral", "success", "warning", "danger"
|
|
Variant string `attr:"variant"`
|
|
// The callout's visual appearance.
|
|
// Valid values: "accent", "filled", "outlined", "plain", "filled-outlined"
|
|
Appearance string `attr:"appearance"`
|
|
// The callout's size.
|
|
// Valid values: "small", "medium", "large"
|
|
Size string `attr:"size"`
|
|
|
|
// Events
|
|
|
|
// Slots contains named slot content
|
|
Slots CalloutSlots
|
|
|
|
// Attrs contains additional HTML attributes
|
|
Attrs templ.Attributes
|
|
}
|
|
|
|
// CalloutSlots holds named slot content for the component
|
|
type CalloutSlots struct {
|
|
// An icon to show in the callout. Works best with <wa-icon>.
|
|
Icon templ.Component
|
|
}
|
|
|
|
// CalloutBuilder provides a fluent API for constructing CalloutProps
|
|
type CalloutBuilder struct {
|
|
props CalloutProps
|
|
}
|
|
|
|
// NewCallout creates a new builder for wa-callout
|
|
func NewCallout() *CalloutBuilder {
|
|
return &CalloutBuilder{}
|
|
}
|
|
|
|
// Variant sets the variant attribute
|
|
// The callout's theme variant. Defaults to brand if not within another element with a variant.
|
|
func (b *CalloutBuilder) Variant(v string) *CalloutBuilder {
|
|
b.props.Variant = v
|
|
return b
|
|
}
|
|
|
|
// Appearance sets the appearance attribute
|
|
// The callout's visual appearance.
|
|
func (b *CalloutBuilder) Appearance(v string) *CalloutBuilder {
|
|
b.props.Appearance = v
|
|
return b
|
|
}
|
|
|
|
// Size sets the size attribute
|
|
// The callout's size.
|
|
func (b *CalloutBuilder) Size(v string) *CalloutBuilder {
|
|
b.props.Size = v
|
|
return b
|
|
}
|
|
|
|
// IconSlot sets the icon slot content
|
|
// An icon to show in the callout. Works best with <wa-icon>.
|
|
func (b *CalloutBuilder) IconSlot(c templ.Component) *CalloutBuilder {
|
|
b.props.Slots.Icon = c
|
|
return b
|
|
}
|
|
|
|
// Attr adds a custom HTML attribute
|
|
func (b *CalloutBuilder) Attr(name, value string) *CalloutBuilder {
|
|
if b.props.Attrs == nil {
|
|
b.props.Attrs = templ.Attributes{}
|
|
}
|
|
b.props.Attrs[name] = value
|
|
return b
|
|
}
|
|
|
|
// Attrs merges multiple attributes
|
|
func (b *CalloutBuilder) Attrs(attrs templ.Attributes) *CalloutBuilder {
|
|
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 *CalloutBuilder) Props() CalloutProps {
|
|
return b.props
|
|
}
|
|
|
|
// Build returns the props (alias for Props for semantic clarity)
|
|
func (b *CalloutBuilder) Build() CalloutProps {
|
|
return b.props
|
|
}
|
|
|
|
// Callout renders the wa-callout component
|
|
templ Callout(props CalloutProps) {
|
|
<wa-callout
|
|
if props.Variant != "" {
|
|
variant={ props.Variant }
|
|
}
|
|
if props.Appearance != "" {
|
|
appearance={ props.Appearance }
|
|
}
|
|
if props.Size != "" {
|
|
size={ props.Size }
|
|
}
|
|
{ props.Attrs... }
|
|
>
|
|
if props.Slots.Icon != nil {
|
|
<div slot="icon">
|
|
@props.Slots.Icon
|
|
</div>
|
|
}
|
|
{ children... }
|
|
</wa-callout>
|
|
}
|
|
|
|
// CalloutFunc renders with a builder function for inline configuration
|
|
templ CalloutFunc(fn func(*CalloutBuilder)) {
|
|
{{ b := NewCallout(); fn(b) }}
|
|
@Callout(b.Props()) {
|
|
{ children... }
|
|
}
|
|
}
|