Files
nebula/pkg/wa/carousel_templ.go

492 lines
17 KiB
Go
Raw Permalink Normal View History

2026-01-01 14:41:31 -05:00
// Code generated by templ - DO NOT EDIT.
2026-01-01 20:49:44 -05:00
// templ: version: v0.3.960
2026-01-01 14:41:31 -05:00
// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-carousel
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"
)
// Carousels display an arbitrary number of content slides along a horizontal or vertical axis.
//
// Web Awesome component: <wa-carousel>
// CarouselProps holds all properties for the wa-carousel component
type CarouselProps struct {
// When set, allows the user to navigate the carousel in the same direction indefinitely.
Loop bool `attr:"loop"`
//
Slides float64 `attr:"slides"`
//
CurrentSlide float64 `attr:"currentSlide"`
// When set, show the carousel's navigation.
Navigation bool `attr:"navigation"`
// When set, show the carousel's pagination indicators.
Pagination bool `attr:"pagination"`
// When set, the slides will scroll automatically when the user is not interacting with them.
Autoplay bool `attr:"autoplay"`
// Specifies the amount of time, in milliseconds, between each automatic scroll.
AutoplayInterval float64 `attr:"autoplay-interval"`
// Specifies how many slides should be shown at a given time.
SlidesPerPage float64 `attr:"slides-per-page"`
// Specifies the number of slides the carousel will advance when scrolling, useful when specifying a slides-per-page
SlidesPerMove float64 `attr:"slides-per-move"`
// Specifies the orientation in which the carousel will lay out.
// Valid values: "horizontal", "vertical"
Orientation string `attr:"orientation"`
// When set, it is possible to scroll through the slides by dragging them with the mouse.
MouseDragging bool `attr:"mouse-dragging"`
// Events
// Emitted when the active slide changes.
OnSlideChange string `attr:"x-on:wa-slide-change"`
// Slots contains named slot content
Slots CarouselSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// CarouselSlots holds named slot content for the component
type CarouselSlots struct {
// Optional next icon to use instead of the default. Works best with <wa-icon>.
NextIcon templ.Component
// Optional previous icon to use instead of the default. Works best with <wa-icon>.
PreviousIcon templ.Component
}
// CarouselBuilder provides a fluent API for constructing CarouselProps
type CarouselBuilder struct {
props CarouselProps
}
// NewCarousel creates a new builder for wa-carousel
func NewCarousel() *CarouselBuilder {
return &CarouselBuilder{}
}
// Loop sets the loop attribute
// When set, allows the user to navigate the carousel in the same direction indefinitely.
func (b *CarouselBuilder) Loop(v bool) *CarouselBuilder {
b.props.Loop = v
return b
}
// Slides sets the slides attribute
func (b *CarouselBuilder) Slides(v float64) *CarouselBuilder {
b.props.Slides = v
return b
}
// CurrentSlide sets the currentSlide attribute
func (b *CarouselBuilder) CurrentSlide(v float64) *CarouselBuilder {
b.props.CurrentSlide = v
return b
}
// Navigation sets the navigation attribute
// When set, show the carousel's navigation.
func (b *CarouselBuilder) Navigation(v bool) *CarouselBuilder {
b.props.Navigation = v
return b
}
// Pagination sets the pagination attribute
// When set, show the carousel's pagination indicators.
func (b *CarouselBuilder) Pagination(v bool) *CarouselBuilder {
b.props.Pagination = v
return b
}
// Autoplay sets the autoplay attribute
// When set, the slides will scroll automatically when the user is not interacting with them.
func (b *CarouselBuilder) Autoplay(v bool) *CarouselBuilder {
b.props.Autoplay = v
return b
}
// AutoplayInterval sets the autoplay-interval attribute
// Specifies the amount of time, in milliseconds, between each automatic scroll.
func (b *CarouselBuilder) AutoplayInterval(v float64) *CarouselBuilder {
b.props.AutoplayInterval = v
return b
}
// SlidesPerPage sets the slides-per-page attribute
// Specifies how many slides should be shown at a given time.
func (b *CarouselBuilder) SlidesPerPage(v float64) *CarouselBuilder {
b.props.SlidesPerPage = v
return b
}
// SlidesPerMove sets the slides-per-move attribute
// Specifies the number of slides the carousel will advance when scrolling, useful when specifying a slides-per-page
func (b *CarouselBuilder) SlidesPerMove(v float64) *CarouselBuilder {
b.props.SlidesPerMove = v
return b
}
// Orientation sets the orientation attribute
// Specifies the orientation in which the carousel will lay out.
func (b *CarouselBuilder) Orientation(v string) *CarouselBuilder {
b.props.Orientation = v
return b
}
// MouseDragging sets the mouse-dragging attribute
// When set, it is possible to scroll through the slides by dragging them with the mouse.
func (b *CarouselBuilder) MouseDragging(v bool) *CarouselBuilder {
b.props.MouseDragging = v
return b
}
// OnSlideChange sets the handler for wa-slide-change event
// Emitted when the active slide changes.
func (b *CarouselBuilder) OnSlideChange(handler string) *CarouselBuilder {
b.props.OnSlideChange = handler
return b
}
// NextIconSlot sets the next-icon slot content
// Optional next icon to use instead of the default. Works best with <wa-icon>.
func (b *CarouselBuilder) NextIconSlot(c templ.Component) *CarouselBuilder {
b.props.Slots.NextIcon = c
return b
}
// PreviousIconSlot sets the previous-icon slot content
// Optional previous icon to use instead of the default. Works best with <wa-icon>.
func (b *CarouselBuilder) PreviousIconSlot(c templ.Component) *CarouselBuilder {
b.props.Slots.PreviousIcon = c
return b
}
// Attr adds a custom HTML attribute
func (b *CarouselBuilder) Attr(name, value string) *CarouselBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *CarouselBuilder) Attrs(attrs templ.Attributes) *CarouselBuilder {
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 *CarouselBuilder) Props() CarouselProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *CarouselBuilder) Build() CarouselProps {
return b.props
}
// Carousel renders the wa-carousel component
func Carousel(props CarouselProps) 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-carousel")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Loop {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " loop")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slides != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " slides=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.Slides))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/carousel.templ`, Line: 202, Col: 45}
}
_, 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, 4, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.CurrentSlide != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, " currentSlide=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.CurrentSlide))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/carousel.templ`, Line: 205, Col: 57}
}
_, 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, 6, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Navigation {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " navigation")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Pagination {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " pagination")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Autoplay {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " autoplay")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.AutoplayInterval != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " autoplay-interval=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.AutoplayInterval))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/carousel.templ`, Line: 217, Col: 66}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.SlidesPerPage != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " slides-per-page=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.SlidesPerPage))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/carousel.templ`, Line: 220, Col: 61}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
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.SlidesPerMove != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " slides-per-move=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.SlidesPerMove))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/carousel.templ`, Line: 223, Col: 61}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
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
}
}
if props.Orientation != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " orientation=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(props.Orientation)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/carousel.templ`, Line: 226, Col: 34}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
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
}
}
if props.MouseDragging {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " mouse-dragging")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnSlideChange != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, " x-on:wa-slide-change=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnSlideChange)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/carousel.templ`, Line: 232, Col: 45}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\"")
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, 21, ">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Slots.NextIcon != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<div slot=\"next-icon\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.NextIcon.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.PreviousIcon != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "<div slot=\"previous-icon\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.PreviousIcon.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</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, 26, "</wa-carousel>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// CarouselFunc renders with a builder function for inline configuration
func CarouselFunc(fn func(*CarouselBuilder)) 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 := NewCarousel()
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 = Carousel(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