Class: DsfrComponent::AlertComponent
- Includes:
- Traits::HeaderSizeable
- Defined in:
- app/components/dsfr_component/alert_component.rb
Constant Summary collapse
- TYPES =
i[error success info warning].freeze
- SIZES =
i[sm md].freeze
Constants included from Traits::HeaderSizeable
Traits::HeaderSizeable::DEFAULT_HEADER_LEVEL
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(type: nil, title: nil, size: :md, close_button: false, icon_name: nil, header_level: nil, html_attributes: {}) ⇒ AlertComponent
constructor
optionel ; la taille ‘sm` requiert un contenu, mais pas de titre.
Methods included from Traits::HeaderSizeable
#default_header_level, #header_level, #header_level=, #header_tag
Constructor Details
#initialize(type: nil, title: nil, size: :md, close_button: false, icon_name: nil, header_level: nil, html_attributes: {}) ⇒ AlertComponent
Note:
La taille ‘:md` requiert un titre mais le contenu est
optionel ; la taille ‘sm` requiert un contenu, mais pas de titre.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/components/dsfr_component/alert_component.rb', line 15 def initialize( type: nil, title: nil, size: :md, close_button: false, icon_name: nil, header_level: nil, html_attributes: {} ) @title = title @type = type @size = size = @icon_name = icon_name self.header_level = header_level super(html_attributes: html_attributes) end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/components/dsfr_component/alert_component.rb', line 34 def call check_main_content! check_icon_allowed! tag.div(**html_attributes) do safe_join([title_tag, content_tag, ]) end end |