style(dsfr/radio): error for input radios group

This commit is contained in:
Colin Darie 2023-05-25 19:10:23 +02:00
parent 8c210e6fc7
commit c2c57b0c7e
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
2 changed files with 14 additions and 3 deletions

View file

@ -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

View file

@ -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