ds_fr: add toggle_component
This commit is contained in:
parent
2135d3c4e7
commit
cc04c4484d
2 changed files with 16 additions and 0 deletions
9
app/components/dsfr/toggle_component.rb
Normal file
9
app/components/dsfr/toggle_component.rb
Normal 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
|
|
@ -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
|
Loading…
Reference in a new issue