Class: ElementComponent::Components::CarouselItem

Inherits:
Element
  • Object
show all
Defined in:
lib/element_component/components/carousel/item.rb

Instance Attribute Summary

Attributes inherited from Element

#attributes, #contents, #element, #html

Instance Method Summary collapse

Methods inherited from Element

#add_attribute, #add_attribute!, #add_content, #add_content!, #new_element, #remove_attribute, #remove_attribute_value, #render, #reset_attributes!, #reset_contents!

Constructor Details

#initialize(active: false, interval: nil, **attributes, &block) ⇒ CarouselItem

Returns a new instance of CarouselItem.



6
7
8
9
10
11
12
13
# File 'lib/element_component/components/carousel/item.rb', line 6

def initialize(active: false, interval: nil, **attributes, &block)
  super("div", &block)

  add_attribute(class: "carousel-item")
  add_attribute(class: "active") if active
  add_attribute("data-bs-interval": interval.to_s) if interval
  add_attribute(attributes) unless attributes.empty?
end