Class: GovukComponent::AccordionComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/accordion_component.rb

Defined Under Namespace

Classes: SectionComponent

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods inherited from Base

#brand

Constructor Details

#initialize(heading_level: 2, classes: [], html_attributes: {}) ⇒ AccordionComponent

Returns a new instance of AccordionComponent.



17
18
19
20
21
22
# File 'app/components/govuk_component/accordion_component.rb', line 17

def initialize(heading_level: 2, classes: [], html_attributes: {})
  @heading_level = heading_tag(heading_level)
  @accordion_id  = html_attributes[:id]

  super(classes:, html_attributes:)
end

Instance Attribute Details

#accordion_idObject (readonly)

Returns the value of attribute accordion_id.



15
16
17
# File 'app/components/govuk_component/accordion_component.rb', line 15

def accordion_id
  @accordion_id
end

#heading_levelObject (readonly)

Returns the value of attribute heading_level.



15
16
17
# File 'app/components/govuk_component/accordion_component.rb', line 15

def heading_level
  @heading_level
end

Instance Method Details

#callObject



24
25
26
# File 'app/components/govuk_component/accordion_component.rb', line 24

def call
  tag.div(**html_attributes) { safe_join(sections) }
end