Class: CCS::Components::GovUK::StepByStepNavigation::Section::Content
- Inherits:
-
Object
- Object
- CCS::Components::GovUK::StepByStepNavigation::Section::Content
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/ccs/components/govuk/step_by_step_navigation/section/content.rb,
lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb,
lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb,
lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb
Overview
GOV.UK Step by step navigation section content
The content for a navigation section
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(content_items:, index:, id:) ⇒ Content
constructor
A new instance of Content.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Step by step navigation section content.
Constructor Details
#initialize(content_items:, index:, id:) ⇒ Content
Returns a new instance of Content.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ccs/components/govuk/step_by_step_navigation/section/content.rb', line 36 def initialize(content_items:, index:, id:) @section_id = "step-panel-#{id}-#{index}" @content_items = content_items.map do |content_item| case content_item[:type] when :paragraph Paragraph.new(text: content_item[:text]) when :list List.new(items: content_item[:items]) end end end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Step by step navigation section content
53 54 55 56 57 |
# File 'lib/ccs/components/govuk/step_by_step_navigation/section/content.rb', line 53 def render tag.div(class: 'gem-c-step-nav__panel js-panel', id: section_id) do content_items.each { |content_item| concat(content_item.render) } end end |