Documentation
¶
Overview ¶
Package carousel is a row of slides in a scroll container with CSS scroll snap. The CarouselControls island adds the previous and next buttons.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CarouselFixtures = gx.Fixtures[CarouselProps]{ "Default": {Id: "carousel-default", Label: "Numbers", Children: gx.Frag(slide("1"), slide("2"), slide("3"))}, "Vertical": {Id: "carousel-vertical", Label: "Numbers", Orientation: Vertical, Children: gx.Frag(slide("1"), slide("2"), slide("3"))}, }
var CarouselItemFixtures = gx.Fixtures[CarouselItemProps]{ "Default": {Children: gx.El("div", gx.Attrs{{Key: "class", Value: "flex h-40 items-center justify-center rounded-md border border-border bg-card text-4xl font-semibold text-card-foreground"}}, gx.Text("1"))}, }
Functions ¶
func Carousel ¶
func Carousel(p CarouselProps) gx.Node
func CarouselControls ¶
func CarouselControls(p CarouselControlsProps, opts ...gx.IslandOption) gx.Node
CarouselControls renders the island of CarouselControls.ts (REQ-ISL-01). The browser mounts it with the props as JSON. An option sets the time of the load.
func CarouselItem ¶
func CarouselItem(p CarouselItemProps) gx.Node
Types ¶
type CarouselControlsProps ¶
type CarouselControlsProps struct {
// Viewport is the id of the scroll container.
Viewport string `json:"viewport"`
// Orientation is "horizontal" or "vertical".
Orientation string `json:"orientation"`
// PreviousLabel and NextLabel name the two buttons.
PreviousLabel string `json:"previousLabel"`
NextLabel string `json:"nextLabel"`
// StatusText is the text of the position, with {n} and {count}.
StatusText string `json:"statusText"`
// Classes holds the classes of the parts. They are Go constants, so
// the stylesheet build sees them.
Classes ControlClasses `json:"classes"`
}
CarouselControlsProps are the props of the island that draws the buttons. The island scrolls the element with the id Viewport.
type CarouselItemProps ¶
type CarouselProps ¶
type CarouselProps struct {
// Id is the id of the root element.
Id string
// Label is the accessible name of the carousel.
Label string
// Orientation sets the direction of the slides: Horizontal or Vertical.
Orientation Orientation
// Class adds classes to the root element.
Class string
// Children are the slides: one CarouselItem for each.
Children gx.Node
// Attrs adds HTML attributes to the root element.
Attrs gx.Attrs
}
type ControlClasses ¶
type ControlClasses struct {
Root string `json:"root"`
Button string `json:"button"`
Status string `json:"status"`
}
ControlClasses are the classes of the parts that the island draws.
type Orientation ¶
type Orientation string
Orientation is the direction of the slides of a carousel.
const ( Horizontal Orientation = "horizontal" Vertical Orientation = "vertical" )
The orientations of carousel.Carousel.