Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions app/components/memorable_date_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<label class="usa-label">
<label class="usa-label">
<%= label %>
</label>
<div class="usa-hint" id="validated-field-hint-<%= unique_id %>">
<div id="validated-field-hint-<%= unique_id %>" class="usa-hint">
<%= hint %>
</div>
<%= content_tag :'lg-memorable-date', min: min, max: max, **tag_options do -%>
Expand All @@ -22,17 +22,21 @@
pattern: '(1[0-2])|(0?[1-9])',
wrapper_html: { class: 'usa-form-group usa-form-group--month margin-bottom-0' },
label: t('components.memorable_date.month'),
label_html: { class: 'usa-label' },
label_html: {
class: 'usa-label',
id: "memorable-date-month-label-#{unique_id}",
},
input_html: {
type: 'text',
class: 'validated-field__input memorable-date__month',
minLength: 1,
maxLength: 2,
aria: {
invalid: false,
describedby: [
"validated-field-error-#{unique_id}",
"validated-field-hint-#{unique_id}",
describedby: "validated-field-error-#{unique_id}",
labelledby: [
"memorable-date-month-label-#{unique_id}",
"memorable-date-month-hint-#{unique_id}",
],
},
value: month,
Expand All @@ -41,6 +45,9 @@
required: required,
) %>
<% end %>
<span id=<%= "memorable-date-month-hint-#{unique_id}" %> class="display-none">
<%= t('in_person_proofing.form.state_id.date_hint.month') %>
</span>
</lg-validated-field>
<lg-validated-field>
<%= f.simple_fields_for name do |p| %>
Expand All @@ -49,17 +56,21 @@
pattern: '(3[01])|([12][0-9])|(0?[1-9])',
wrapper_html: { class: 'usa-form-group usa-form-group--day margin-bottom-0' },
label: t('components.memorable_date.day'),
label_html: { class: 'usa-label' },
label_html: {
class: 'usa-label',
id: "memorable-date-day-label-#{unique_id}",
},
input_html: {
type: 'text',
class: 'validated-field__input memorable-date__day',
minLength: 1,
maxLength: 2,
aria: {
invalid: false,
describedby: [
"validated-field-error-#{unique_id}",
"validated-field-hint-#{unique_id}",
describedby: "validated-field-error-#{unique_id}",
labelledby: [
"memorable-date-day-label-#{unique_id}",
"memorable-date-day-hint-#{unique_id}",
],
},
value: day,
Expand All @@ -68,6 +79,9 @@
required: required,
) %>
<% end %>
<span id=<%= "memorable-date-day-hint-#{unique_id}" %> class="display-none">
<%= t('in_person_proofing.form.state_id.date_hint.day') %>
</span>
</lg-validated-field>
<lg-validated-field>
<%= f.simple_fields_for name do |p| %>
Expand All @@ -76,17 +90,21 @@
pattern: '\d{4}',
wrapper_html: { class: 'usa-form-group usa-form-group--year margin-bottom-0' },
label: t('components.memorable_date.year'),
label_html: { class: 'usa-label' },
label_html: {
class: 'usa-label',
id: "memorable-date-year-label-#{unique_id}",
},
input_html: {
type: 'text',
class: 'validated-field__input memorable-date__year',
minLength: 4,
maxLength: 4,
aria: {
invalid: false,
describedby: [
"validated-field-error-#{unique_id}",
"validated-field-hint-#{unique_id}",
describedby: "validated-field-error-#{unique_id}",
labelledby: [
"memorable-date-year-label-#{unique_id}",
"memorable-date-year-hint-#{unique_id}",
],
},
value: year,
Expand All @@ -95,6 +113,9 @@
required: required,
) %>
<% end %>
<span id=<%= "memorable-date-year-hint-#{unique_id}" %> class="display-none">
<%= t('in_person_proofing.form.state_id.date_hint.year') %>
</span>
</lg-validated-field>
</div>
<% end -%>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/in_person_proofing/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ en:
same_address_choice_yes: This address is on my state-issued ID
state_prompt: '- Select -'
state_id:
date_hint:
day: 'Example: 28'
month: 'Example: 4'
year: 'Example: 1986'
dob: Date of birth
dob_hint: 'Example: 4 28 1986'
first_name: First name
Expand Down
4 changes: 4 additions & 0 deletions config/locales/in_person_proofing/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ es:
same_address_choice_yes: Esta dirección aparece en mi cédula de identidad emitida por el estado
state_prompt: '- Seleccione -'
state_id:
date_hint:
day: 'Ejemplo: 28'
month: 'Ejemplo: 4'
year: 'Ejemplo: 1986'
dob: Fecha de nacimiento
dob_hint: 'Ejemplo: 4 28 1986'
first_name: Nombre
Expand Down
4 changes: 4 additions & 0 deletions config/locales/in_person_proofing/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ fr:
same_address_choice_yes: Cette adresse figure sur mon document d’identité nationale
state_prompt: '- Sélectionnez -'
state_id:
date_hint:
day: 'Exemple: 28'
month: 'Exemple: 4'
year: 'Exemple: 1986'
dob: Date de naissance
dob_hint: 'Exemple: 4 28 1986'
first_name: Prénom
Expand Down
6 changes: 6 additions & 0 deletions spec/components/memorable_date_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
expect(rendered).to have_css('lg-memorable-date lg-validated-field input.memorable-date__year')
end

it 'renders memorable date input fields with hints' do
expect(rendered).to have_css('input[aria-labelledby*="memorable-date-month-hint"]')
expect(rendered).to have_css('input[aria-labelledby*="memorable-date-day-hint"]')
expect(rendered).to have_css('input[aria-labelledby*="memorable-date-year-hint"]')
end

it 'sets the label' do
expect(rendered).to have_css('.usa-label', text: label)
end
Expand Down