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')