diff --git a/app/components/dsfr/callout_component.rb b/app/components/dsfr/callout_component.rb index da0160990..6a4e83c57 100644 --- a/app/components/dsfr/callout_component.rb +++ b/app/components/dsfr/callout_component.rb @@ -3,16 +3,17 @@ class Dsfr::CalloutComponent < ApplicationComponent renders_one :body renders_one :bottom - attr_reader :title, :theme, :icon + attr_reader :title, :theme, :icon, :extra_class_names - def initialize(title:, theme: :info, icon: nil) + def initialize(title:, theme: :info, icon: nil, extra_class_names: nil) @title = title @theme = theme @icon = icon + @extra_class_names = extra_class_names end def callout_class - ["fr-callout", theme_class, icon] + ["fr-callout", theme_class, icon, extra_class_names].compact.flatten end private diff --git a/app/components/editable_champ/explication_component/explication_component.html.haml b/app/components/editable_champ/explication_component/explication_component.html.haml index 9fbc82439..2ed40f2be 100644 --- a/app/components/editable_champ/explication_component/explication_component.html.haml +++ b/app/components/editable_champ/explication_component/explication_component.html.haml @@ -1,3 +1,11 @@ -%h2.explication-libelle= @champ.libelle -.explication - = string_to_html(@champ.description) += render Dsfr::CalloutComponent.new(title: @champ.libelle, extra_class_names: ['fr-mb-2w', 'fr-callout--blue-cumulus']) do |c| + - c.with_body do + + = string_to_html(@champ.description) + + - if @champ.collapsible_explanation_enabled? && @champ.collapsible_explanation_text.present? + %div + %p.fr-my-2w + %button{type: "button", "aria-controls" => "champs-text-#{@champ.id}", "aria-expanded" => "false", href: "#champs-text-#{@champ.id}"} Lire plus + %p.fr-collapse{ id: "champs-text-#{@champ.id}"} + = @champ.collapsible_explanation_text diff --git a/app/models/champ.rb b/app/models/champ.rb index 5ee7948cf..a4a16dc09 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -42,8 +42,9 @@ class Champ < ApplicationRecord :drop_down_list_enabled_non_empty_options, :drop_down_secondary_libelle, :drop_down_secondary_description, - :collapsible_explanation_text, :collapsible_explanation_enabled, + :collapsible_explanation_enabled?, + :collapsible_explanation_text, :exclude_from_export?, :exclude_from_view?, :repetition?,