style(dsfr/radio): error for input radios group
This commit is contained in:
parent
8c210e6fc7
commit
c2c57b0c7e
2 changed files with 14 additions and 3 deletions
|
@ -1,7 +1,16 @@
|
|||
class Dsfr::RadioButtonListComponent < ApplicationComponent
|
||||
def initialize(form:, target:, buttons:)
|
||||
attr_reader :error
|
||||
|
||||
def initialize(form:, target:, buttons:, error: nil)
|
||||
@form = form
|
||||
@target = target
|
||||
@buttons = buttons
|
||||
@error = error
|
||||
end
|
||||
|
||||
def error?
|
||||
# TODO: mettre correctement le aria-labelled-by avec l'id du div qui contient les erreurs
|
||||
# https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/bouton-radio/
|
||||
@error.present?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
%fieldset.fr-fieldset{ 'aria-labelledby': 'radio-hint-element-legend radio-hint-element-messages' }
|
||||
%fieldset{ class: class_names("fr-fieldset": true, "fr-fieldset--error": error?), 'aria-labelledby': 'radio-hint-element-legend radio-hint-element-messages', role: error? ? :group : nil }
|
||||
%legend.fr-fieldset__legend--regular.fr-fieldset__legend
|
||||
= content
|
||||
|
||||
|
@ -10,4 +10,6 @@
|
|||
- capture do
|
||||
= label
|
||||
%span.fr-hint-text= hint
|
||||
.fr-messages-group{ 'aria-live': 'assertive' }
|
||||
.fr-messages-group{ 'aria-live': 'assertive' }
|
||||
- if error?
|
||||
%p.fr-message.fr-message--error= error
|
||||
|
|
Loading…
Reference in a new issue