Class: CCS::Components::GovUK::StepByStepNavigation::Section::Content

Inherits:
Object
  • Object
show all
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

Classes: List, Paragraph

Instance Method Summary collapse

Constructor Details

#initialize(content_items:, index:, id:) ⇒ Content

Returns a new instance of Content.

Parameters:

  • content_items (Array<Hash>)

    array of content items. If the type is :paragraph, see Paragraph#initialize. If the type is :list, see List#initialize.

  • index (String)

    the index of the section

  • id (String)

    the id of the section



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

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Step by step navigation section content

Returns:

  • (ActiveSupport::SafeBuffer)


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