feat: add info for screen reader

This commit is contained in:
simon lehericey 2023-05-12 10:03:54 +02:00
parent 36331f71a4
commit 7b17bfe0a1
4 changed files with 9 additions and 5 deletions

View file

@ -1,3 +1,4 @@
en:
remaining_characters: You have %{remaining_words} characters remaining.
excess_characters: You have %{excess_words} characters too many.
recommended_size: The recommended maximum size is %{size} characters.

View file

@ -1,3 +1,4 @@
fr:
remaining_characters: Il vous reste %{remaining_words} caractères.
excess_characters: Vous avez dépassé la taille conseillée de %{excess_words} caractères.
excess_characters: Vous avez dépassé la taille conseillée de %{excess_words} caractères. Réduire le nombre de caractère.
recommended_size: La taille maximale conseillée est de %{size} caractères.

View file

@ -1,3 +1,5 @@
%span.sr-only= t('.recommended_size', size: @champ.character_limit_base)
~ @form.text_area :value,
id: @champ.input_id,
aria: { describedby: @champ.describedby_id },

View file

@ -41,16 +41,16 @@ class Champs::TextareaChamp < Champs::TextChamp
analyze_character_count == :warning
end
def character_limit_base
character_limit&.to_i
end
private
def character_count
return value&.bytesize
end
def character_limit_base
character_limit&.to_i
end
def character_limit_threshold_75
character_limit_base * 0.75
end