Class: LightningUiKit::CarouselComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- LightningUiKit::CarouselComponent
- Defined in:
- app/components/lightning_ui_kit/carousel_component.rb
Instance Attribute Summary collapse
-
#show_arrows ⇒ Object
readonly
Returns the value of attribute show_arrows.
-
#show_dots ⇒ Object
readonly
Returns the value of attribute show_dots.
Instance Method Summary collapse
- #arrow_classes(side) ⇒ Object
- #classes ⇒ Object
- #data ⇒ Object
-
#initialize(loop: false, show_dots: true, show_arrows: true, **options) ⇒ CarouselComponent
constructor
A new instance of CarouselComponent.
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, **) @loop = loop @show_dots = show_dots @show_arrows = show_arrows @options = end |
Instance Attribute Details
#show_arrows ⇒ Object (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_dots ⇒ Object (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 |
#classes ⇒ Object
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 |
#data ⇒ Object
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 |