95 lines
2.1 KiB
Plaintext
95 lines
2.1 KiB
Plaintext
|
|
// Code generated by wa-generator. DO NOT EDIT.
|
||
|
|
// Source: Web Awesome wa-skeleton
|
||
|
|
|
||
|
|
package wa
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/a-h/templ"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Skeletons are used to provide a visual representation of where content will eventually be drawn.
|
||
|
|
//
|
||
|
|
// Web Awesome component: <wa-skeleton>
|
||
|
|
|
||
|
|
// SkeletonProps holds all properties for the wa-skeleton component
|
||
|
|
type SkeletonProps struct {
|
||
|
|
// Determines which effect the skeleton will use.
|
||
|
|
// Valid values: "pulse", "sheen", "none"
|
||
|
|
Effect string `attr:"effect"`
|
||
|
|
|
||
|
|
// Events
|
||
|
|
|
||
|
|
// Slots contains named slot content
|
||
|
|
Slots SkeletonSlots
|
||
|
|
|
||
|
|
// Attrs contains additional HTML attributes
|
||
|
|
Attrs templ.Attributes
|
||
|
|
}
|
||
|
|
|
||
|
|
// SkeletonBuilder provides a fluent API for constructing SkeletonProps
|
||
|
|
type SkeletonBuilder struct {
|
||
|
|
props SkeletonProps
|
||
|
|
}
|
||
|
|
|
||
|
|
// NewSkeleton creates a new builder for wa-skeleton
|
||
|
|
func NewSkeleton() *SkeletonBuilder {
|
||
|
|
return &SkeletonBuilder{}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Effect sets the effect attribute
|
||
|
|
// Determines which effect the skeleton will use.
|
||
|
|
func (b *SkeletonBuilder) Effect(v string) *SkeletonBuilder {
|
||
|
|
b.props.Effect = v
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Attr adds a custom HTML attribute
|
||
|
|
func (b *SkeletonBuilder) Attr(name, value string) *SkeletonBuilder {
|
||
|
|
if b.props.Attrs == nil {
|
||
|
|
b.props.Attrs = templ.Attributes{}
|
||
|
|
}
|
||
|
|
b.props.Attrs[name] = value
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// Attrs merges multiple attributes
|
||
|
|
func (b *SkeletonBuilder) Attrs(attrs templ.Attributes) *SkeletonBuilder {
|
||
|
|
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 *SkeletonBuilder) Props() SkeletonProps {
|
||
|
|
return b.props
|
||
|
|
}
|
||
|
|
|
||
|
|
// Build returns the props (alias for Props for semantic clarity)
|
||
|
|
func (b *SkeletonBuilder) Build() SkeletonProps {
|
||
|
|
return b.props
|
||
|
|
}
|
||
|
|
|
||
|
|
// Skeleton renders the wa-skeleton component
|
||
|
|
templ Skeleton(props SkeletonProps) {
|
||
|
|
<wa-skeleton
|
||
|
|
if props.Effect != "" {
|
||
|
|
effect={ props.Effect }
|
||
|
|
}
|
||
|
|
{ props.Attrs... }
|
||
|
|
>
|
||
|
|
{ children... }
|
||
|
|
</wa-skeleton>
|
||
|
|
}
|
||
|
|
|
||
|
|
// SkeletonFunc renders with a builder function for inline configuration
|
||
|
|
templ SkeletonFunc(fn func(*SkeletonBuilder)) {
|
||
|
|
{{ b := NewSkeleton(); fn(b) }}
|
||
|
|
@Skeleton(b.Props()) {
|
||
|
|
{ children... }
|
||
|
|
}
|
||
|
|
}
|