// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.977 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-avatar 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" ) // Avatars are used to represent a person or object. // // Web Awesome component: // AvatarProps holds all properties for the wa-avatar component type AvatarProps struct { // The image source to use for the avatar. Image string `attr:"image"` // A label to use to describe the avatar to assistive devices. Label string `attr:"label"` // Initials to use as a fallback when no image is available (1-2 characters max recommended). Initials string `attr:"initials"` // Indicates how the browser should load the image. // Valid values: "eager", "lazy" Loading string `attr:"loading"` // The shape of the avatar. // Valid values: "circle", "square", "rounded" Shape string `attr:"shape"` // Events // The image could not be loaded. This may because of an invalid URL, a temporary network condition, or some unknown cause. OnError string `attr:"x-on:wa-error"` // Slots contains named slot content Slots AvatarSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // AvatarSlots holds named slot content for the component type AvatarSlots struct { // The default icon to use when no image or initials are present. Works best with . Icon templ.Component } // AvatarBuilder provides a fluent API for constructing AvatarProps type AvatarBuilder struct { props AvatarProps } // NewAvatar creates a new builder for wa-avatar func NewAvatar() *AvatarBuilder { return &AvatarBuilder{} } // Image sets the image attribute // The image source to use for the avatar. func (b *AvatarBuilder) Image(v string) *AvatarBuilder { b.props.Image = v return b } // Label sets the label attribute // A label to use to describe the avatar to assistive devices. func (b *AvatarBuilder) Label(v string) *AvatarBuilder { b.props.Label = v return b } // Initials sets the initials attribute // Initials to use as a fallback when no image is available (1-2 characters max recommended). func (b *AvatarBuilder) Initials(v string) *AvatarBuilder { b.props.Initials = v return b } // Loading sets the loading attribute // Indicates how the browser should load the image. func (b *AvatarBuilder) Loading(v string) *AvatarBuilder { b.props.Loading = v return b } // Shape sets the shape attribute // The shape of the avatar. func (b *AvatarBuilder) Shape(v string) *AvatarBuilder { b.props.Shape = v return b } // OnError sets the handler for wa-error event // The image could not be loaded. This may because of an invalid URL, a temporary network condition, or some unknown cause. func (b *AvatarBuilder) OnError(handler string) *AvatarBuilder { b.props.OnError = handler return b } // IconSlot sets the icon slot content // The default icon to use when no image or initials are present. Works best with . func (b *AvatarBuilder) IconSlot(c templ.Component) *AvatarBuilder { b.props.Slots.Icon = c return b } // Attr adds a custom HTML attribute func (b *AvatarBuilder) Attr(name, value string) *AvatarBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *AvatarBuilder) Attrs(attrs templ.Attributes) *AvatarBuilder { 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 *AvatarBuilder) Props() AvatarProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *AvatarBuilder) Build() AvatarProps { return b.props } // Avatar renders the wa-avatar component func Avatar(props AvatarProps) 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 } if props.Slots.Icon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.Icon.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "
") 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, 17, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // AvatarFunc renders with a builder function for inline configuration func AvatarFunc(fn func(*AvatarBuilder)) 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_Var8 := templ.GetChildren(ctx) if templ_7745c5c3_Var8 == nil { templ_7745c5c3_Var8 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewAvatar() fn(b) templ_7745c5c3_Var9 := 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_Var8.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = Avatar(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate