dsfr(toggle): add attributes to toggle component
This commit is contained in:
parent
74903d79bf
commit
1bbf35a6ba
3 changed files with 14 additions and 6 deletions
|
@ -1,9 +1,13 @@
|
|||
class Dsfr::ToggleComponent < ApplicationComponent
|
||||
def initialize(form:, target:, title:, hint:, disabled:)
|
||||
def initialize(form:, target:, title:, disabled: nil, hint: nil, toggle_labels: { checked: 'Activé', unchecked: 'Désactivé' }, opt: nil)
|
||||
@form = form
|
||||
@target = target
|
||||
@title = title
|
||||
@hint = hint
|
||||
@disabled = disabled
|
||||
@toggle_labels = toggle_labels
|
||||
@opt = opt
|
||||
end
|
||||
|
||||
attr_reader :toggle_labels
|
||||
end
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
.fr-toggle.fr-toggle--border-bottom.fr-toggle--label-left
|
||||
= @form.check_box @target, class: 'fr-toggle__input', disabled: @disabled
|
||||
.fr-toggle.fr-toggle--label-left
|
||||
= @form.check_box @target, class: 'fr-toggle__input', disabled: @disabled,
|
||||
data: @opt
|
||||
= @form.label @target,
|
||||
@title,
|
||||
class: 'fr-toggle__label',
|
||||
data: { 'fr-checked-label': 'Activé', 'fr-unchecked-label': 'Désactivé' }
|
||||
%p.fr-hint-text= @hint
|
||||
data: { 'fr-checked-label': toggle_labels[:checked], 'fr-unchecked-label': toggle_labels[:unchecked] },
|
||||
class: 'fr-toggle__label'
|
||||
- if @hint
|
||||
%p.fr-hint-text= @hint
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
title: 'Autogestion des instructeurs',
|
||||
hint: "L’autogestion des instructeurs permet aux instructeurs de gérer eux-mêmes la liste des instructeurs de la démarche.#{ 'Nous recommandons de laisser l’autogestion des instructeurs activée.' if @procedure.routing_enabled? }",
|
||||
disabled: false)
|
||||
|
||||
%hr
|
||||
%p.fr-mt-2w Routage
|
||||
%p.fr-mt-2w= t('.routing_configuration_notice_1')
|
||||
%p.fr-icon-info-line.fr-hint-text{ aria: { hidden: true } }
|
||||
|
|
Loading…
Reference in a new issue