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
|
2023-02-22 09:09:07 +01:00
|
|
|
renders_one :html_body
|
2022-10-18 13:59:50 +02:00
|
|
|
renders_one :bottom
|
2022-08-17 18:02:27 +02:00
|
|
|
|
2022-11-07 10:05:27 +01:00
|
|
|
attr_reader :title, :theme, :icon, :extra_class_names
|
2022-08-17 18:02:27 +02:00
|
|
|
|
2022-11-07 10:05:27 +01:00
|
|
|
def initialize(title:, theme: :info, icon: nil, extra_class_names: nil)
|
2022-08-17 18:02:27 +02:00
|
|
|
@title = title
|
2022-09-16 00:07:16 +02:00
|
|
|
@theme = theme
|
|
|
|
@icon = icon
|
2022-11-07 10:05:27 +01:00
|
|
|
@extra_class_names = extra_class_names
|
2022-09-16 00:07:16 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def callout_class
|
2022-11-07 10:05:27 +01:00
|
|
|
["fr-callout", theme_class, icon, extra_class_names].compact.flatten
|
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
|