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

118 lines
3.0 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-bar
package wa
import (
"github.com/a-h/templ"
)
// Progress bars are used to show the status of an ongoing operation.
//
// Web Awesome component: <wa-progress-bar>
// ProgressBarProps holds all properties for the wa-progress-bar component
type ProgressBarProps struct {
// The current progress as a percentage, 0 to 100.
Value float64 `attr:"value"`
// When true, percentage is ignored, the label is hidden, and the progress bar is drawn in an indeterminate state.
Indeterminate bool `attr:"indeterminate"`
// A custom label for assistive devices.
Label string `attr:"label"`
// Events
// Slots contains named slot content
Slots ProgressBarSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// ProgressBarBuilder provides a fluent API for constructing ProgressBarProps
type ProgressBarBuilder struct {
props ProgressBarProps
}
// NewProgressBar creates a new builder for wa-progress-bar
func NewProgressBar() *ProgressBarBuilder {
return &ProgressBarBuilder{}
}
// Value sets the value attribute
// The current progress as a percentage, 0 to 100.
func (b *ProgressBarBuilder) Value(v float64) *ProgressBarBuilder {
b.props.Value = v
return b
}
// Indeterminate sets the indeterminate attribute
// When true, percentage is ignored, the label is hidden, and the progress bar is drawn in an indeterminate state.
func (b *ProgressBarBuilder) Indeterminate(v bool) *ProgressBarBuilder {
b.props.Indeterminate = v
return b
}
// Label sets the label attribute
// A custom label for assistive devices.
func (b *ProgressBarBuilder) Label(v string) *ProgressBarBuilder {
b.props.Label = v
return b
}
// Attr adds a custom HTML attribute
func (b *ProgressBarBuilder) Attr(name, value string) *ProgressBarBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *ProgressBarBuilder) Attrs(attrs templ.Attributes) *ProgressBarBuilder {
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 *ProgressBarBuilder) Props() ProgressBarProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *ProgressBarBuilder) Build() ProgressBarProps {
return b.props
}
// ProgressBar renders the wa-progress-bar component
templ ProgressBar(props ProgressBarProps) {
<wa-progress-bar
if props.Value != 0 {
value={ templ.Sprintf("%v", props.Value) }
}
if props.Indeterminate {
indeterminate
}
if props.Label != "" {
label={ props.Label }
}
{ props.Attrs... }
>
{ children... }
</wa-progress-bar>
}
// ProgressBarFunc renders with a builder function for inline configuration
templ ProgressBarFunc(fn func(*ProgressBarBuilder)) {
{{ b := NewProgressBar(); fn(b) }}
@ProgressBar(b.Props()) {
{ children... }
}
}