Class: Railsboot::Accordion::ItemComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/accordion/item_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(id:, parent_id: "", expanded: false, **html_attributes) ⇒ ItemComponent

Returns a new instance of ItemComponent.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/components/railsboot/accordion/item_component.rb', line 5

def initialize(id:, parent_id: "", expanded: false, **html_attributes)
  @id = id
  @parent_id = parent_id
  @expanded = expanded
  @html_attributes = html_attributes

  @html_attributes[:tag] = "div"
  @html_attributes[:class] = class_names(
    "accordion-item",
    html_attributes.delete(:class)
  )
end

Instance Method Details

#parent_referenceObject



18
19
20
# File 'app/components/railsboot/accordion/item_component.rb', line 18

def parent_reference
  @parent_id.present? ? {bs_parent: "##{@parent_id}"} : {}
end