// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-animated-image 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" ) // A component for displaying animated GIFs and WEBPs that play and pause on interaction. // // Web Awesome component: // AnimatedImageProps holds all properties for the wa-animated-image component type AnimatedImageProps struct { // The path to the image to load. Src string `attr:"src"` // A description of the image used by assistive devices. Alt string `attr:"alt"` // Plays the animation. When this attribute is remove, the animation will pause. Play bool `attr:"play"` // Events // Emitted when the image loads successfully. OnLoad string `attr:"x-on:wa-load"` // Emitted when the image fails to load. OnError string `attr:"x-on:wa-error"` // Slots contains named slot content Slots AnimatedImageSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // AnimatedImageSlots holds named slot content for the component type AnimatedImageSlots struct { // Optional play icon to use instead of the default. Works best with . PlayIcon templ.Component // Optional pause icon to use instead of the default. Works best with . PauseIcon templ.Component } // AnimatedImageBuilder provides a fluent API for constructing AnimatedImageProps type AnimatedImageBuilder struct { props AnimatedImageProps } // NewAnimatedImage creates a new builder for wa-animated-image func NewAnimatedImage() *AnimatedImageBuilder { return &AnimatedImageBuilder{} } // Src sets the src attribute // The path to the image to load. func (b *AnimatedImageBuilder) Src(v string) *AnimatedImageBuilder { b.props.Src = v return b } // Alt sets the alt attribute // A description of the image used by assistive devices. func (b *AnimatedImageBuilder) Alt(v string) *AnimatedImageBuilder { b.props.Alt = v return b } // Play sets the play attribute // Plays the animation. When this attribute is remove, the animation will pause. func (b *AnimatedImageBuilder) Play(v bool) *AnimatedImageBuilder { b.props.Play = v return b } // OnLoad sets the handler for wa-load event // Emitted when the image loads successfully. func (b *AnimatedImageBuilder) OnLoad(handler string) *AnimatedImageBuilder { b.props.OnLoad = handler return b } // OnError sets the handler for wa-error event // Emitted when the image fails to load. func (b *AnimatedImageBuilder) OnError(handler string) *AnimatedImageBuilder { b.props.OnError = handler return b } // PlayIconSlot sets the play-icon slot content // Optional play icon to use instead of the default. Works best with . func (b *AnimatedImageBuilder) PlayIconSlot(c templ.Component) *AnimatedImageBuilder { b.props.Slots.PlayIcon = c return b } // PauseIconSlot sets the pause-icon slot content // Optional pause icon to use instead of the default. Works best with . func (b *AnimatedImageBuilder) PauseIconSlot(c templ.Component) *AnimatedImageBuilder { b.props.Slots.PauseIcon = c return b } // Attr adds a custom HTML attribute func (b *AnimatedImageBuilder) Attr(name, value string) *AnimatedImageBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *AnimatedImageBuilder) Attrs(attrs templ.Attributes) *AnimatedImageBuilder { 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 *AnimatedImageBuilder) Props() AnimatedImageProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *AnimatedImageBuilder) Build() AnimatedImageProps { return b.props } // AnimatedImage renders the wa-animated-image component func AnimatedImage(props AnimatedImageProps) 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.PlayIcon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.PlayIcon.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.PauseIcon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.PauseIcon.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
") 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, 16, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // AnimatedImageFunc renders with a builder function for inline configuration func AnimatedImageFunc(fn func(*AnimatedImageBuilder)) 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_Var6 := templ.GetChildren(ctx) if templ_7745c5c3_Var6 == nil { templ_7745c5c3_Var6 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewAnimatedImage() fn(b) templ_7745c5c3_Var7 := 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_Var6.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = AnimatedImage(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate