Class: CCS::Components::GovUK::Accordion::Section::Header
- Inherits:
-
Object
- Object
- CCS::Components::GovUK::Accordion::Section::Header
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/ccs/components/govuk/accordion/section/header.rb
Overview
GOV.UK Accordion Section Header
The individual accordion section header
Instance Method Summary collapse
-
#initialize(section:, accordion_id:, index:, heading_level:) ⇒ Header
constructor
A new instance of Header.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Accordion Section Header.
Constructor Details
#initialize(section:, accordion_id:, index:, heading_level:) ⇒ Header
Returns a new instance of Header.
33 34 35 36 37 38 |
# File 'lib/ccs/components/govuk/accordion/section/header.rb', line 33 def initialize(section:, accordion_id:, index:, heading_level:) @section = section @accordion_id = accordion_id @index = index @heading_level = heading_level end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Accordion Section Header
44 45 46 47 48 49 50 51 |
# File 'lib/ccs/components/govuk/accordion/section/header.rb', line 44 def render tag.div(class: 'govuk-accordion__section-header') do concat(tag.send("h#{heading_level}", class: 'govuk-accordion__section-heading') do tag.span(section[:heading], class: 'govuk-accordion__section-button', id: "#{accordion_id}-heading-#{index}") end) concat(tag.div(section[:summary], class: 'govuk-accordion__section-summary govuk-body', id: "#{accordion_id}-summary-#{index}")) if section[:summary] end end |