// Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-card package wa import ( "github.com/a-h/templ" ) // Cards can be used to group related subjects in a container. // // Web Awesome component: // 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 templ Card(props CardProps) { if props.Slots.Header != nil {
@props.Slots.Header
} if props.Slots.Footer != nil {
@props.Slots.Footer
} if props.Slots.Media != nil {
@props.Slots.Media
} if props.Slots.Actions != nil {
@props.Slots.Actions
} if props.Slots.HeaderActions != nil {
@props.Slots.HeaderActions
} if props.Slots.FooterActions != nil {
@props.Slots.FooterActions
} { children... }
} // CardFunc renders with a builder function for inline configuration templ CardFunc(fn func(*CardBuilder)) { {{ b := NewCard(); fn(b) }} @Card(b.Props()) { { children... } } }