Class: CCS::Components::GovUK::StepByStepNavigation
- Defined in:
- lib/ccs/components/govuk/step_by_step_navigation.rb,
lib/ccs/components/govuk/step_by_step_navigation/section.rb,
lib/ccs/components/govuk/step_by_step_navigation/section/content.rb,
lib/ccs/components/govuk/step_by_step_navigation/section/heading.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
This is used for generating the Step by step navigation component from the / GDS - Pages - Step by step navigation
Defined Under Namespace
Classes: Section
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the step byt step navigation
{ class: 'gem-c-step-nav gem-c-step-nav--large gem-c-step-nav--active', data: { module: 'govuk-step-by-step-navigation' } }.freeze
- DEFAULT_SHOW_HIDE_TEXT =
Default text for the show and hide buttons which are part of each section
{ 'show-text': 'Show', 'hide-text': 'Hide', 'show-all-text': 'Show all', 'hide-all-text': 'Hide all' }.freeze
Instance Method Summary collapse
-
#initialize(step_by_step_navigation_sections:, **options) ⇒ StepByStepNavigation
constructor
A new instance of StepByStepNavigation.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Step by step navigation component (experimental).
Constructor Details
#initialize(step_by_step_navigation_sections:, **options) ⇒ StepByStepNavigation
Returns a new instance of StepByStepNavigation.
29 30 31 32 33 34 35 |
# File 'lib/ccs/components/govuk/step_by_step_navigation.rb', line 29 def initialize(step_by_step_navigation_sections:, **) super(**) DEFAULT_SHOW_HIDE_TEXT.each { |key, value| @options[:attributes][:data][key] ||= value } @step_by_step_navigation_sections = .map.with_index(1) { |step_by_step_section, index| Section.new(index: index.to_s, context: @context, **step_by_step_section) } end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Step by step navigation component (experimental)
41 42 43 44 45 46 47 |
# File 'lib/ccs/components/govuk/step_by_step_navigation.rb', line 41 def render tag.div(**[:attributes]) do tag.ol(class: 'gem-c-step-nav__steps') do .each { || concat(.render) } end end end |