Class: CCS::Components::GovUK::StepByStepNavigation::Section::Heading

Inherits:
Object
  • Object
show all
Includes:
ActionView::Context, ActionView::Helpers
Defined in:
lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb

Overview

GOV.UK Step by step navigation section heading

The heading for a navigation section

Instance Method Summary collapse

Constructor Details

#initialize(text:, index:, logic: nil) ⇒ Heading

Returns a new instance of Heading.

Parameters:

  • text (String)

    text for the section heading

  • index (String)

    the index of the section

  • logic (String) (defaults to: nil)

    text to show instead of a number in the sidebar



33
34
35
36
37
# File 'lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb', line 33

def initialize(text:, index:, logic: nil)
  @text = text
  @index = index
  @logic = logic
end

Instance Method Details

#renderActiveSupport::SafeBuffer

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

Returns:

  • (ActiveSupport::SafeBuffer)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb', line 45

def render
  tag.div(class: 'gem-c-step-nav__header js-toggle-panel', data: { position: index }) do
    tag.h2(class: 'gem-c-step-nav__title') do
      concat(tag.span(class: "gem-c-step-nav__circle gem-c-step-nav__circle--#{logic ? 'logic' : 'number'}") do
        tag.span(class: 'gem-c-step-nav__circle-inner') do
          tag.span(class: 'gem-c-step-nav__circle-background') do
            concat(tag.span('Step', class: 'govuk-visually-hidden'))
            concat(logic || index)
          end
        end
      end)
      concat(tag.span(class: 'js-step-title') do
        tag.span(text, class: 'js-step-title-text')
      end)
    end
  end
end