// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-qr-code 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" ) // Generates a QR code and renders it using the Canvas API. // // Web Awesome component: // QrCodeProps holds all properties for the wa-qr-code component type QrCodeProps struct { // The QR code's value. Value string `attr:"value"` // The label for assistive devices to announce. If unspecified, the value will be used instead. Label string `attr:"label"` // The size of the QR code, in pixels. Size float64 `attr:"size"` // The fill color. This can be any valid CSS color, but not a CSS custom property. Fill string `attr:"fill"` // The background color. This can be any valid CSS color or transparent. It cannot be a CSS custom property. Background string `attr:"background"` // The edge radius of each module. Must be between 0 and 0.5. Radius float64 `attr:"radius"` // The level of error correction to use. Learn more // Valid values: "L", "M", "Q", "H" ErrorCorrection string `attr:"error-correction"` // Events // Slots contains named slot content Slots QrCodeSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // QrCodeBuilder provides a fluent API for constructing QrCodeProps type QrCodeBuilder struct { props QrCodeProps } // NewQrCode creates a new builder for wa-qr-code func NewQrCode() *QrCodeBuilder { return &QrCodeBuilder{} } // Value sets the value attribute // The QR code's value. func (b *QrCodeBuilder) Value(v string) *QrCodeBuilder { b.props.Value = v return b } // Label sets the label attribute // The label for assistive devices to announce. If unspecified, the value will be used instead. func (b *QrCodeBuilder) Label(v string) *QrCodeBuilder { b.props.Label = v return b } // Size sets the size attribute // The size of the QR code, in pixels. func (b *QrCodeBuilder) Size(v float64) *QrCodeBuilder { b.props.Size = v return b } // Fill sets the fill attribute // The fill color. This can be any valid CSS color, but not a CSS custom property. func (b *QrCodeBuilder) Fill(v string) *QrCodeBuilder { b.props.Fill = v return b } // Background sets the background attribute // The background color. This can be any valid CSS color or transparent. It cannot be a CSS custom property. func (b *QrCodeBuilder) Background(v string) *QrCodeBuilder { b.props.Background = v return b } // Radius sets the radius attribute // The edge radius of each module. Must be between 0 and 0.5. func (b *QrCodeBuilder) Radius(v float64) *QrCodeBuilder { b.props.Radius = v return b } // ErrorCorrection sets the error-correction attribute // The level of error correction to use. Learn more func (b *QrCodeBuilder) ErrorCorrection(v string) *QrCodeBuilder { b.props.ErrorCorrection = v return b } // Attr adds a custom HTML attribute func (b *QrCodeBuilder) Attr(name, value string) *QrCodeBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *QrCodeBuilder) Attrs(attrs templ.Attributes) *QrCodeBuilder { 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 *QrCodeBuilder) Props() QrCodeProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *QrCodeBuilder) Build() QrCodeProps { return b.props } // QrCode renders the wa-qr-code component func QrCode(props QrCodeProps) 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, 17, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // QrCodeFunc renders with a builder function for inline configuration func QrCodeFunc(fn func(*QrCodeBuilder)) 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 := NewQrCode() 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 = QrCode(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