Files
nebula/pkg/wa/progress-ring.templ

106 lines
2.6 KiB
Plaintext
Raw Normal View History

2026-01-01 14:41:31 -05:00
// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-progress-ring
package wa
import (
"github.com/a-h/templ"
)
// Progress rings are used to show the progress of a determinate operation in a circular fashion.
//
// Web Awesome component: <wa-progress-ring>
// ProgressRingProps holds all properties for the wa-progress-ring component
type ProgressRingProps struct {
// The current progress as a percentage, 0 to 100.
Value float64 `attr:"value"`
// A custom label for assistive devices.
Label string `attr:"label"`
// Events
// Slots contains named slot content
Slots ProgressRingSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// ProgressRingBuilder provides a fluent API for constructing ProgressRingProps
type ProgressRingBuilder struct {
props ProgressRingProps
}
// NewProgressRing creates a new builder for wa-progress-ring
func NewProgressRing() *ProgressRingBuilder {
return &ProgressRingBuilder{}
}
// Value sets the value attribute
// The current progress as a percentage, 0 to 100.
func (b *ProgressRingBuilder) Value(v float64) *ProgressRingBuilder {
b.props.Value = v
return b
}
// Label sets the label attribute
// A custom label for assistive devices.
func (b *ProgressRingBuilder) Label(v string) *ProgressRingBuilder {
b.props.Label = v
return b
}
// Attr adds a custom HTML attribute
func (b *ProgressRingBuilder) Attr(name, value string) *ProgressRingBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *ProgressRingBuilder) Attrs(attrs templ.Attributes) *ProgressRingBuilder {
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 *ProgressRingBuilder) Props() ProgressRingProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *ProgressRingBuilder) Build() ProgressRingProps {
return b.props
}
// ProgressRing renders the wa-progress-ring component
templ ProgressRing(props ProgressRingProps) {
<wa-progress-ring
if props.Value != 0 {
value={ templ.Sprintf("%v", props.Value) }
}
if props.Label != "" {
label={ props.Label }
}
{ props.Attrs... }
>
{ children... }
</wa-progress-ring>
}
// ProgressRingFunc renders with a builder function for inline configuration
templ ProgressRingFunc(fn func(*ProgressRingBuilder)) {
{{ b := NewProgressRing(); fn(b) }}
@ProgressRing(b.Props()) {
{ children... }
}
}