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: nil, icon_name: "information-line", accent: nil, header_level: nil, html_attributes: {}) ⇒ CalloutComponent

Returns a new instance of CalloutComponent.

Parameters:

  • title (String) (defaults to: nil)

    Le titre de la mise en avant (optionnel)

  • 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)

  • accent (String) (defaults to: nil)

    La couleur d’accent (exemple green-tilleul-verveine) (optionnel)

  • header_level (Integer) (defaults to: nil)

    Le niveau de titre (optionnel)



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

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

  super(html_attributes: html_attributes)
end

Instance Method Details

#callObject



28
29
30
31
32
33
34
35
36
# File 'app/components/dsfr_component/callout_component.rb', line 28

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

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

    concat action_zone if action_zone?
  end
end