// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.977 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-rating package wa //lint:file-ignore SA4006 This context is only used if a nested component is present. import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" import ( "github.com/a-h/templ" ) // Ratings give users a way to quickly view and provide feedback. // // Web Awesome component: // RatingProps holds all properties for the wa-rating component type RatingProps struct { // A label that describes the rating to assistive devices. Label string `attr:"label"` // The current rating. Value float64 `attr:"value"` // The highest rating to show. Max float64 `attr:"max"` // The precision at which the rating will increase and decrease. For example, to allow half-star ratings, set this Precision float64 `attr:"precision"` // Makes the rating readonly. Readonly bool `attr:"readonly"` // Disables the rating. Disabled bool `attr:"disabled"` // A function that customizes the symbol to be rendered. The first and only argument is the rating's current value. GetSymbol string `attr:"getSymbol"` // The component's size. // Valid values: "small", "medium", "large" Size string `attr:"size"` // Events // Emitted when the rating's value changes. OnChange string `attr:"x-on:change"` // Emitted when the user hovers over a value. The phase property indicates when hovering starts, moves to a new value, o... OnHover string `attr:"x-on:wa-hover"` // Slots contains named slot content Slots RatingSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // RatingBuilder provides a fluent API for constructing RatingProps type RatingBuilder struct { props RatingProps } // NewRating creates a new builder for wa-rating func NewRating() *RatingBuilder { return &RatingBuilder{} } // Label sets the label attribute // A label that describes the rating to assistive devices. func (b *RatingBuilder) Label(v string) *RatingBuilder { b.props.Label = v return b } // Value sets the value attribute // The current rating. func (b *RatingBuilder) Value(v float64) *RatingBuilder { b.props.Value = v return b } // Max sets the max attribute // The highest rating to show. func (b *RatingBuilder) Max(v float64) *RatingBuilder { b.props.Max = v return b } // Precision sets the precision attribute // The precision at which the rating will increase and decrease. For example, to allow half-star ratings, set this func (b *RatingBuilder) Precision(v float64) *RatingBuilder { b.props.Precision = v return b } // Readonly sets the readonly attribute // Makes the rating readonly. func (b *RatingBuilder) Readonly(v bool) *RatingBuilder { b.props.Readonly = v return b } // Disabled sets the disabled attribute // Disables the rating. func (b *RatingBuilder) Disabled(v bool) *RatingBuilder { b.props.Disabled = v return b } // GetSymbol sets the getSymbol attribute // A function that customizes the symbol to be rendered. The first and only argument is the rating's current value. func (b *RatingBuilder) GetSymbol(v string) *RatingBuilder { b.props.GetSymbol = v return b } // Size sets the size attribute // The component's size. func (b *RatingBuilder) Size(v string) *RatingBuilder { b.props.Size = v return b } // OnChange sets the handler for change event // Emitted when the rating's value changes. func (b *RatingBuilder) OnChange(handler string) *RatingBuilder { b.props.OnChange = handler return b } // OnHover sets the handler for wa-hover event // Emitted when the user hovers over a value. The phase property indicates when hovering starts, moves to a new value, o... func (b *RatingBuilder) OnHover(handler string) *RatingBuilder { b.props.OnHover = handler return b } // Attr adds a custom HTML attribute func (b *RatingBuilder) Attr(name, value string) *RatingBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *RatingBuilder) Attrs(attrs templ.Attributes) *RatingBuilder { 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 *RatingBuilder) Props() RatingProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *RatingBuilder) Build() RatingProps { return b.props } // Rating renders the wa-rating component func Rating(props RatingProps) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var1 := templ.GetChildren(ctx) if templ_7745c5c3_Var1 == nil { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // RatingFunc renders with a builder function for inline configuration func RatingFunc(fn func(*RatingBuilder)) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var9 := templ.GetChildren(ctx) if templ_7745c5c3_Var9 == nil { templ_7745c5c3_Var9 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewRating() fn(b) templ_7745c5c3_Var10 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Err = templ_7745c5c3_Var9.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = Rating(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var10), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate