Files
nebula/pkg/wa/carousel.templ

257 lines
7.4 KiB
Plaintext
Raw Permalink Normal View History

2026-01-01 14:41:31 -05:00
// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-carousel
package wa
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
templ Carousel(props CarouselProps) {
<wa-carousel
if props.Loop {
loop
}
if props.Slides != 0 {
slides={ templ.Sprintf("%v", props.Slides) }
}
if props.CurrentSlide != 0 {
currentSlide={ templ.Sprintf("%v", props.CurrentSlide) }
}
if props.Navigation {
navigation
}
if props.Pagination {
pagination
}
if props.Autoplay {
autoplay
}
if props.AutoplayInterval != 0 {
autoplay-interval={ templ.Sprintf("%v", props.AutoplayInterval) }
}
if props.SlidesPerPage != 0 {
slides-per-page={ templ.Sprintf("%v", props.SlidesPerPage) }
}
if props.SlidesPerMove != 0 {
slides-per-move={ templ.Sprintf("%v", props.SlidesPerMove) }
}
if props.Orientation != "" {
orientation={ props.Orientation }
}
if props.MouseDragging {
mouse-dragging
}
if props.OnSlideChange != "" {
x-on:wa-slide-change={ props.OnSlideChange }
}
{ props.Attrs... }
>
if props.Slots.NextIcon != nil {
<div slot="next-icon">
@props.Slots.NextIcon
</div>
}
if props.Slots.PreviousIcon != nil {
<div slot="previous-icon">
@props.Slots.PreviousIcon
</div>
}
{ children... }
</wa-carousel>
}
// CarouselFunc renders with a builder function for inline configuration
templ CarouselFunc(fn func(*CarouselBuilder)) {
{{ b := NewCarousel(); fn(b) }}
@Carousel(b.Props()) {
{ children... }
}
}