Files
nebula/pkg/wa/card_templ.go

417 lines
14 KiB
Go

// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.960
// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-card
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"
)
// Cards can be used to group related subjects in a container.
//
// Web Awesome component: <wa-card>
// CardProps holds all properties for the wa-card component
type CardProps struct {
// The card's visual appearance.
// Valid values: "accent", "filled", "outlined", "filled-outlined", "plain"
Appearance string `attr:"appearance"`
// Renders the card with a header. Only needed for SSR, otherwise is automatically added.
WithHeader bool `attr:"with-header"`
// Renders the card with an image. Only needed for SSR, otherwise is automatically added.
WithMedia bool `attr:"with-media"`
// Renders the card with a footer. Only needed for SSR, otherwise is automatically added.
WithFooter bool `attr:"with-footer"`
// Renders the card's orientation *
// Valid values: "horizontal", "vertical"
Orientation string `attr:"orientation"`
// Events
// Slots contains named slot content
Slots CardSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// CardSlots holds named slot content for the component
type CardSlots struct {
// An optional header for the card.
Header templ.Component
// An optional footer for the card.
Footer templ.Component
// An optional media section to render at the start of the card.
Media templ.Component
// An optional actions section to render at the end for the horizontal card.
Actions templ.Component
// An optional actions section to render in the header of the vertical card.
HeaderActions templ.Component
// An optional actions section to render in the footer of the vertical card.
FooterActions templ.Component
}
// CardBuilder provides a fluent API for constructing CardProps
type CardBuilder struct {
props CardProps
}
// NewCard creates a new builder for wa-card
func NewCard() *CardBuilder {
return &CardBuilder{}
}
// Appearance sets the appearance attribute
// The card's visual appearance.
func (b *CardBuilder) Appearance(v string) *CardBuilder {
b.props.Appearance = v
return b
}
// WithHeader sets the with-header attribute
// Renders the card with a header. Only needed for SSR, otherwise is automatically added.
func (b *CardBuilder) WithHeader(v bool) *CardBuilder {
b.props.WithHeader = v
return b
}
// WithMedia sets the with-media attribute
// Renders the card with an image. Only needed for SSR, otherwise is automatically added.
func (b *CardBuilder) WithMedia(v bool) *CardBuilder {
b.props.WithMedia = v
return b
}
// WithFooter sets the with-footer attribute
// Renders the card with a footer. Only needed for SSR, otherwise is automatically added.
func (b *CardBuilder) WithFooter(v bool) *CardBuilder {
b.props.WithFooter = v
return b
}
// Orientation sets the orientation attribute
// Renders the card's orientation *
func (b *CardBuilder) Orientation(v string) *CardBuilder {
b.props.Orientation = v
return b
}
// HeaderSlot sets the header slot content
// An optional header for the card.
func (b *CardBuilder) HeaderSlot(c templ.Component) *CardBuilder {
b.props.Slots.Header = c
return b
}
// FooterSlot sets the footer slot content
// An optional footer for the card.
func (b *CardBuilder) FooterSlot(c templ.Component) *CardBuilder {
b.props.Slots.Footer = c
return b
}
// MediaSlot sets the media slot content
// An optional media section to render at the start of the card.
func (b *CardBuilder) MediaSlot(c templ.Component) *CardBuilder {
b.props.Slots.Media = c
return b
}
// ActionsSlot sets the actions slot content
// An optional actions section to render at the end for the horizontal card.
func (b *CardBuilder) ActionsSlot(c templ.Component) *CardBuilder {
b.props.Slots.Actions = c
return b
}
// HeaderActionsSlot sets the header-actions slot content
// An optional actions section to render in the header of the vertical card.
func (b *CardBuilder) HeaderActionsSlot(c templ.Component) *CardBuilder {
b.props.Slots.HeaderActions = c
return b
}
// FooterActionsSlot sets the footer-actions slot content
// An optional actions section to render in the footer of the vertical card.
func (b *CardBuilder) FooterActionsSlot(c templ.Component) *CardBuilder {
b.props.Slots.FooterActions = c
return b
}
// Attr adds a custom HTML attribute
func (b *CardBuilder) Attr(name, value string) *CardBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *CardBuilder) Attrs(attrs templ.Attributes) *CardBuilder {
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 *CardBuilder) Props() CardProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *CardBuilder) Build() CardProps {
return b.props
}
// Card renders the wa-card component
func Card(props CardProps) 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, "<wa-card")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Appearance != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " appearance=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.Appearance)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/card.templ`, Line: 175, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.WithHeader {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " with-header")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.WithMedia {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, " with-media")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.WithFooter {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " with-footer")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Orientation != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " orientation=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.Orientation)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/card.templ`, Line: 187, Col: 34}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templ.RenderAttributes(ctx, templ_7745c5c3_Buffer, props.Attrs)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, ">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Slots.Header != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<div slot=\"header\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.Header.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.Footer != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<div slot=\"footer\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.Footer.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.Media != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<div slot=\"media\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.Media.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.Actions != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<div slot=\"actions\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.Actions.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.HeaderActions != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<div slot=\"header-actions\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.HeaderActions.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.FooterActions != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<div slot=\"footer-actions\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.FooterActions.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</div>")
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, 22, "</wa-card>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// CardFunc renders with a builder function for inline configuration
func CardFunc(fn func(*CardBuilder)) 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_Var4 := templ.GetChildren(ctx)
if templ_7745c5c3_Var4 == nil {
templ_7745c5c3_Var4 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
b := NewCard()
fn(b)
templ_7745c5c3_Var5 := 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_Var4.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = Card(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate