feat(dsfr): new NoticeComponent

This commit is contained in:
Colin Darie 2022-09-14 15:32:56 +02:00
parent a5e1d8865b
commit ab82128585
5 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,12 @@
# see: https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/bandeau-d-information-importante/
class Dsfr::NoticeComponent < ApplicationComponent
renders_one :title
def initialize(closable: false)
@closable = closable
end
def closable?
!!@closable
end
end

View file

@ -0,0 +1,4 @@
---
en:
close_notice: Hide message

View file

@ -0,0 +1,4 @@
---
fr:
close_notice: Masquer le message

View file

@ -0,0 +1,9 @@
.fr-notice.fr-notice--info
.fr-container
.fr-notice__body
%p.fr-notice__title
= title
- if closable?
%button.fr-btn--close.fr-btn{ title: t('.close_notice'), onclick: 'const notice = this.parentNode.parentNode.parentNode; notice.parentNode.removeChild' }
= t('.close_notice')

View file

@ -335,3 +335,14 @@
= link_to "Button 1", "#", class: "fr-btn", **external_link_attributes
- c.with_footer_button do
= button_tag "Button 2", class: "fr-btn fr-btn--secondary"
%h1 Dsfr::NoticeComponent
= link_to "Documentation DSFR Bandeau d'information", "https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/bandeau-d-information-importante", **external_link_attributes
.my-3
= render Dsfr::NoticeComponent.new(closable: true) do |c|
- c.with_title do
Titre de cette notice
= link_to "avec un lien optionnel.", "#"
Des marges verticales ont ici été rajoutées.