2022-08-17 18:02:27 +02:00
|
|
|
# see: https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/mise-en-avant
|
|
|
|
class Dsfr::CalloutComponent < ApplicationComponent
|
|
|
|
renders_one :body
|
2022-10-18 13:59:50 +02:00
|
|
|
renders_one :bottom
|
2022-08-17 18:02:27 +02:00
|
|
|
|
2022-09-16 00:07:16 +02:00
|
|
|
attr_reader :title, :theme, :icon
|
2022-08-17 18:02:27 +02:00
|
|
|
|
2022-09-16 00:07:16 +02:00
|
|
|
def initialize(title:, theme: :info, icon: nil)
|
2022-08-17 18:02:27 +02:00
|
|
|
@title = title
|
2022-09-16 00:07:16 +02:00
|
|
|
@theme = theme
|
|
|
|
@icon = icon
|
|
|
|
end
|
|
|
|
|
|
|
|
def callout_class
|
|
|
|
["fr-callout", theme_class, icon]
|
2022-08-17 18:02:27 +02:00
|
|
|
end
|
|
|
|
|
2022-09-16 00:07:16 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def theme_class
|
|
|
|
case theme
|
|
|
|
when :warning
|
|
|
|
"fr-callout--brown-caramel"
|
|
|
|
when :success
|
|
|
|
"fr-callout--green-emeraude"
|
|
|
|
else
|
|
|
|
# info is default theme
|
|
|
|
end
|
|
|
|
end
|
2022-08-17 18:02:27 +02:00
|
|
|
end
|