demarches-normaliennes/app/components/dsfr/alert_component.rb

26 lines
575 B
Ruby
Raw Normal View History

# see: https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/alerte
class Dsfr::AlertComponent < ApplicationComponent
renders_one :body
def prefix_for_state
case state
when :error then "Erreur : "
when :info then "Information : "
when :warning then "Attention : "
when :success then ""
else ""
end
end
private
2022-12-02 17:16:29 +01:00
def initialize(state:, title:, heading_level: 'h3')
@state = state
@title = title
@block = block
2022-12-02 17:16:29 +01:00
@heading_level = heading_level
end
2022-12-02 17:16:29 +01:00
attr_reader :state, :title, :block, :heading_level
end