Class: LightningUiKit::CarouselComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/lightning_ui_kit/carousel_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(loop: false, show_dots: true, show_arrows: true, **options) ⇒ CarouselComponent

Returns a new instance of CarouselComponent.



4
5
6
7
8
9
# File 'app/components/lightning_ui_kit/carousel_component.rb', line 4

def initialize(loop: false, show_dots: true, show_arrows: true, **options)
  @loop = loop
  @show_dots = show_dots
  @show_arrows = show_arrows
  @options = options
end

Instance Attribute Details

#show_arrowsObject (readonly)

Returns the value of attribute show_arrows.



11
12
13
# File 'app/components/lightning_ui_kit/carousel_component.rb', line 11

def show_arrows
  @show_arrows
end

#show_dotsObject (readonly)

Returns the value of attribute show_dots.



11
12
13
# File 'app/components/lightning_ui_kit/carousel_component.rb', line 11

def show_dots
  @show_dots
end

Instance Method Details

#arrow_classes(side) ⇒ Object



20
21
22
23
# File 'app/components/lightning_ui_kit/carousel_component.rb', line 20

def arrow_classes(side)
  position = (side == :prev) ? "lui:left-2" : "lui:right-2"
  "lui:absolute #{position} lui:top-1/2 lui:z-10 lui:inline-flex lui:size-8 lui:-translate-y-1/2 lui:items-center lui:justify-center lui:rounded-full lui:border lui:border-border lui:bg-surface lui:text-foreground lui:shadow-sm lui:transition-colors lui:hover:bg-surface-hover lui:disabled:pointer-events-none lui:disabled:opacity-40 lui:cursor-pointer"
end

#classesObject



13
14
15
16
17
18
# File 'app/components/lightning_ui_kit/carousel_component.rb', line 13

def classes
  merge_classes([
    "lui:relative lui:w-full",
    @options[:class]
  ].compact.join(" "))
end

#dataObject



25
26
27
28
29
30
# File 'app/components/lightning_ui_kit/carousel_component.rb', line 25

def data
  {
    controller: "lui-carousel",
    lui_carousel_loop_value: @loop
  }.merge(@options[:data] || {})
end