ds_fr: add toggle_component

This commit is contained in:
simon lehericey 2023-04-24 15:16:04 +02:00
parent 2135d3c4e7
commit cc04c4484d
2 changed files with 16 additions and 0 deletions

View file

@ -0,0 +1,9 @@
class Dsfr::ToggleComponent < ApplicationComponent
def initialize(form:, target:, title:, hint:, disabled:)
@form = form
@target = target
@title = title
@hint = hint
@disabled = disabled
end
end

View file

@ -0,0 +1,7 @@
.fr-toggle.fr-toggle--border-bottom.fr-toggle--label-left
= @form.check_box @target, class: 'fr-toggle__input', disabled: @disabled
= @form.label @target,
@title,
class: 'fr-toggle__label',
data: { 'fr-checked-label': 'Activé', 'fr-unchecked-label': 'Désactivé' }
%p.fr-hint-text= @hint