Class: Shadcn::Carousel::Item::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/carousel/item/component.rb

Overview

CarouselItem — one slide, full width until the caller says otherwise with a basis-* of its own, which is upstream's "Sizes" example.

Constant Summary

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary collapse

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from ApplicationViewComponent

#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name

Constructor Details

#initialize(orientation: :horizontal, **attributes) ⇒ Component

Returns a new instance of Component.



26
27
28
29
# File 'app/components/shadcn/carousel/item/component.rb', line 26

def initialize(orientation: :horizontal, **attributes)
  @orientation = orientation&.to_sym == :vertical ? :vertical : :horizontal
  super(**attributes)
end

Instance Attribute Details

#orientationObject (readonly)

Returns the value of attribute orientation.



24
25
26
# File 'app/components/shadcn/carousel/item/component.rb', line 24

def orientation
  @orientation
end

Instance Method Details

#element_attributes(**defaults) ⇒ Object



33
34
35
36
37
38
# File 'app/components/shadcn/carousel/item/component.rb', line 33

def element_attributes(**defaults)
  super(**{
    role: "group",
    "aria-roledescription" => "slide"
  }.merge(defaults))
end

#style_variantsObject



31
# File 'app/components/shadcn/carousel/item/component.rb', line 31

def style_variants = { orientation: }