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
|
|
|
|
2023-04-11 16:32:57 +02:00
|
|
|
attr_reader :title, :theme, :icon, :extra_class_names, :heading_level
|
2022-08-17 18:02:27 +02:00
|
|
|
|
2023-04-11 16:32:57 +02:00
|
|
|
def initialize(title:, theme: :info, icon: nil, extra_class_names: nil, heading_level: 'h3')
|
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
|
2023-04-11 16:32:57 +02:00
|
|
|
@heading_level = heading_level
|
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"
|
2024-06-01 22:39:04 +02:00
|
|
|
when :neutral
|
|
|
|
# default
|
2022-09-16 00:07:16 +02:00
|
|
|
else
|
2023-04-23 20:44:35 +02:00
|
|
|
"fr-background-alt--blue-france"
|
2022-09-16 00:07:16 +02:00
|
|
|
end
|
|
|
|
end
|
2022-08-17 18:02:27 +02:00
|
|
|
end
|