Class: DsfrComponent::StepperComponent

Inherits:
Base
  • Object
show all
Includes:
Traits::HeaderSizeable
Defined in:
app/components/dsfr_component/stepper_component.rb

Constant Summary

Constants included from Traits::HeaderSizeable

Traits::HeaderSizeable::DEFAULT_HEADER_LEVEL

Constants inherited from Base

Base::HEADING_LEVELS, Base::SIZES

Instance Attribute Summary

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods included from Traits::HeaderSizeable

#default_header_level, #header_level, #header_level=, #header_tag

Constructor Details

#initialize(title:, value:, max:, next_title: nil, header_level: 2, html_attributes: {}) ⇒ StepperComponent

Returns a new instance of StepperComponent.

Parameters:

  • title (String)

    Titre de l’étape en cours

  • value (Integer)

    Numéro de l’étape en cours (commence à 1)

  • max (Integer)

    Nombre d’étapes total

  • next_title (String) (defaults to: nil)

    Titre de l’étape suivante (sauf pour la dernière étape)

  • header_level (Integer) (defaults to: 2)

    Niveau du titre

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
# File 'app/components/dsfr_component/stepper_component.rb', line 10

def initialize(title:, value:, max:, next_title: nil, header_level: 2, html_attributes: {})
  @title = title
  @value = value
  @max = max
  @next_title = next_title
  self.header_level = header_level

  raise ArgumentError, "Les étapes doivent aller de 1 jusqu´à 8 au maximum" if @value < 1 || @value > @max || @max > 8

  super(html_attributes: html_attributes)
end