Class: CCS::Components::GovUK::Accordion::Section
- Inherits:
-
Object
- Object
- CCS::Components::GovUK::Accordion::Section
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/ccs/components/govuk/accordion/section.rb,
lib/ccs/components/govuk/accordion/section/header.rb,
lib/ccs/components/govuk/accordion/section/content.rb
Overview
GOV.UK Accordion Section
The individual accordion section
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(section:, accordion_id:, index:, heading_level:) ⇒ Section
constructor
A new instance of Section.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Accordion Section.
Constructor Details
#initialize(section:, accordion_id:, index:, heading_level:) ⇒ Section
Returns a new instance of Section.
41 42 43 44 45 |
# File 'lib/ccs/components/govuk/accordion/section.rb', line 41 def initialize(section:, accordion_id:, index:, heading_level:) @section_is_expanded = section[:expanded] @header = Header.new(section: section, accordion_id: accordion_id, index: index, heading_level: heading_level) @content = Content.new(section: section, accordion_id: accordion_id, index: index) end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Accordion Section
51 52 53 54 55 56 |
# File 'lib/ccs/components/govuk/accordion/section.rb', line 51 def render tag.div(class: "govuk-accordion__section #{'govuk-accordion__section--expanded' if }".rstrip) do concat(header.render) concat(content.render) end end |