Class: DsfrComponent::CalloutComponent

Inherits:
Base
  • Object
show all
Includes:
Traits::HeaderSizeable
Defined in:
app/components/dsfr_component/callout_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:, icon_name: "information-line", header_level: nil, html_attributes: {}) ⇒ CalloutComponent

Returns a new instance of CalloutComponent.

Parameters:

  • title (String)

    Le titre de la mise en avant

  • icon_name (String) (defaults to: "information-line")

    Le nom de l’icône à afficher (exemple ‘arrow-right-line`), ou `:none` pour la désactiver (optionnel)

  • header_level (Integer) (defaults to: nil)

    Le niveau de titre (optionnel)



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/components/dsfr_component/callout_component.rb', line 12

def initialize(
  title:,
  icon_name: "information-line",
  header_level: nil,
  html_attributes: {}
)
  @title = title
  @icon_name = icon_name
  self.header_level = header_level

  super(html_attributes: html_attributes)
end

Instance Method Details

#callObject



25
26
27
28
29
30
31
32
33
# File 'app/components/dsfr_component/callout_component.rb', line 25

def call
  tag.div(**html_attributes) do
    concat (header_tag, @title, class: 'fr-callout__title')

    concat (:p, content, class: 'fr-callout__text')

    concat action_zone if action_zone?
  end
end