style(dsfr/callout): more theming for callout component

This commit is contained in:
Colin Darie 2022-09-16 00:07:16 +02:00
parent c4f6305b3a
commit 46b69da396
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
3 changed files with 39 additions and 4 deletions

View file

@ -2,11 +2,28 @@
class Dsfr::CalloutComponent < ApplicationComponent
renders_one :body
private
attr_reader :title, :theme, :icon
def initialize(title:)
def initialize(title:, theme: :info, icon: nil)
@title = title
@theme = theme
@icon = icon
end
attr_reader :title
def callout_class
["fr-callout", theme_class, icon]
end
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
end

View file

@ -1,3 +1,3 @@
%div.fr-callout
%div{ class: callout_class }
%h3.fr-callout__title= title
%p.fr-callout__text= body