// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-icon 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" ) // Icons are symbols that can be used to represent various options within an application. // // Web Awesome component: // IconProps holds all properties for the wa-icon component type IconProps struct { // The name of the icon to draw. Available names depend on the icon library being used. Name string `attr:"name"` // The family of icons to choose from. For Font Awesome Free, valid options include classic and brands. For Family string `attr:"family"` // The name of the icon's variant. For Font Awesome, valid options include thin, light, regular, and solid for Variant string `attr:"variant"` // Sets the width of the icon to match the cropped SVG viewBox. This operates like the Font fa-width-auto class. AutoWidth bool `attr:"auto-width"` // Swaps the opacity of duotone icons. SwapOpacity bool `attr:"swap-opacity"` // An external URL of an SVG file. Be sure you trust the content you are including, as it will be executed as code and Src string `attr:"src"` // An alternate description to use for assistive devices. If omitted, the icon will be considered presentational and Label string `attr:"label"` // The name of a registered custom icon library. Library string `attr:"library"` // Events // Emitted when the icon has loaded. When using spriteSheet: true this will not emit. OnLoad string `attr:"x-on:wa-load"` // Emitted when the icon fails to load due to an error. When using spriteSheet: true this will not emit. OnError string `attr:"x-on:wa-error"` // Slots contains named slot content Slots IconSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // IconBuilder provides a fluent API for constructing IconProps type IconBuilder struct { props IconProps } // NewIcon creates a new builder for wa-icon func NewIcon() *IconBuilder { return &IconBuilder{} } // Name sets the name attribute // The name of the icon to draw. Available names depend on the icon library being used. func (b *IconBuilder) Name(v string) *IconBuilder { b.props.Name = v return b } // Family sets the family attribute // The family of icons to choose from. For Font Awesome Free, valid options include classic and brands. For func (b *IconBuilder) Family(v string) *IconBuilder { b.props.Family = v return b } // Variant sets the variant attribute // The name of the icon's variant. For Font Awesome, valid options include thin, light, regular, and solid for func (b *IconBuilder) Variant(v string) *IconBuilder { b.props.Variant = v return b } // AutoWidth sets the auto-width attribute // Sets the width of the icon to match the cropped SVG viewBox. This operates like the Font fa-width-auto class. func (b *IconBuilder) AutoWidth(v bool) *IconBuilder { b.props.AutoWidth = v return b } // SwapOpacity sets the swap-opacity attribute // Swaps the opacity of duotone icons. func (b *IconBuilder) SwapOpacity(v bool) *IconBuilder { b.props.SwapOpacity = v return b } // Src sets the src attribute // An external URL of an SVG file. Be sure you trust the content you are including, as it will be executed as code and func (b *IconBuilder) Src(v string) *IconBuilder { b.props.Src = v return b } // Label sets the label attribute // An alternate description to use for assistive devices. If omitted, the icon will be considered presentational and func (b *IconBuilder) Label(v string) *IconBuilder { b.props.Label = v return b } // Library sets the library attribute // The name of a registered custom icon library. func (b *IconBuilder) Library(v string) *IconBuilder { b.props.Library = v return b } // OnLoad sets the handler for wa-load event // Emitted when the icon has loaded. When using spriteSheet: true this will not emit. func (b *IconBuilder) OnLoad(handler string) *IconBuilder { b.props.OnLoad = handler return b } // OnError sets the handler for wa-error event // Emitted when the icon fails to load due to an error. When using spriteSheet: true this will not emit. func (b *IconBuilder) OnError(handler string) *IconBuilder { b.props.OnError = handler return b } // Attr adds a custom HTML attribute func (b *IconBuilder) Attr(name, value string) *IconBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *IconBuilder) Attrs(attrs templ.Attributes) *IconBuilder { 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 *IconBuilder) Props() IconProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *IconBuilder) Build() IconProps { return b.props } // Icon renders the wa-icon component func Icon(props IconProps) 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, 21, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // IconFunc renders with a builder function for inline configuration func IconFunc(fn func(*IconBuilder)) 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_Var10 := templ.GetChildren(ctx) if templ_7745c5c3_Var10 == nil { templ_7745c5c3_Var10 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewIcon() fn(b) templ_7745c5c3_Var11 := 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_Var10.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = Icon(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate