Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility audit changes #832

Closed
wants to merge 10 commits into from
Closed
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
7 changes: 7 additions & 0 deletions app/helpers/custom_form_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ def i18n_legend
)
end

def i18n_date_hint(lead_text = i18n_lead_text)
safe_join([
content_tag(:p, lead_text),
I18n.t("helpers/dictionary.date_hint_text").html_safe,
])
end

# Used to customise hints when reusing the same view
# Hints support markup so ensure locale keys ends with `_html`
def i18n_hint
Expand Down
6 changes: 0 additions & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
<%= render partial: 'layouts/gtm_noscript' if analytics_allowed? %>
<% end %>

<% content_for(:service_name) do %>
<%= link_to service_name, root_path,
class: 'govuk-header__link govuk-header__service-name ga-pageLink',
data: { ga_category: 'header', ga_label: 'service name' }, id: 'header-service-name' %>
<% end %>

<% content_for(:cookie_banner) do %>
<% unless analytics_consent_cookie.present? %>
<%= render partial: 'layouts/cookie_banner' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/govuk_template.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<%= content_for?(:skip_link_message) ? yield(:skip_link_message) : 'Skip to main content' %>
</a>

<%= govuk_header(homepage_url: "https://www.gov.uk", service_name: yield(:service_name), service_url: "#") %>
<%= govuk_header(homepage_url: "https://www.gov.uk", service_name:, service_url: "/") %>

<div class="govuk-width-container app-width-container--wide">
<%= yield(:phase_banner) %>
Expand Down
7 changes: 4 additions & 3 deletions app/views/steps/caution/conditional_end_date/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
<%= govuk_error_summary %>

<%= step_form @form_object do |f| %>
<%= f.govuk_date_field :conditional_end_date, maxlength_enabled: true, form_group: { class: 'app-util--compact-form-group' } do
tag.p t('.lead_text'), class: 'govuk-body-m'
end %>
<%= f.govuk_date_field :conditional_end_date, maxlength_enabled: true,
form_group: { class: 'app-util--compact-form-group' },
hint: { text: f.i18n_date_hint(t('.lead_text')) }
%>

<%= render partial: 'steps/shared/approx_date_checkbox', locals: {
form: f, attribute: :approximate_conditional_end_date
Expand Down
2 changes: 1 addition & 1 deletion app/views/steps/check/results/shared/_feedback.en.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</h3>

<p class="govuk-body">
This will help us to improve the service.
<%= link_to "Get in touch", about_contact_path %> to help us improve the service.
</p>

<!-- BEGIN survey monkey embedded satisfaction -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<%= step_form @form_object do |f| %>
<%= f.govuk_date_field :compensation_payment_date, maxlength_enabled: true,
form_group: { class: 'app-util--compact-form-group' },
caption: { text: f.i18n_caption } do
tag.p t('.lead_text'), class: 'govuk-body-m'
end %>
caption: { text: f.i18n_caption },
hint: { text: f.i18n_date_hint(t('.lead_text')) }
%>

<%= render partial: 'steps/shared/approx_date_checkbox', locals: {
form: f, attribute: :approximate_compensation_payment_date
Expand Down
7 changes: 4 additions & 3 deletions app/views/steps/conviction/conviction_date/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
<%= govuk_error_summary %>

<%= step_form @form_object do |f| %>
<%= f.govuk_date_field :conviction_date, maxlength_enabled: true, form_group: { class: 'app-util--compact-form-group' } do
tag.p t('.lead_text'), class: 'govuk-body-m'
end %>
<%= f.govuk_date_field :conviction_date, maxlength_enabled: true,
form_group: { class: 'app-util--compact-form-group' },
hint: { text: f.i18n_date_hint(t('.lead_text')) }
%>

<%= render partial: 'steps/shared/approx_date_checkbox', locals: {
form: f, attribute: :approximate_conviction_date
Expand Down
2 changes: 1 addition & 1 deletion app/views/steps/conviction/known_date/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<%= step_form @form_object do |f| %>
<%= f.govuk_date_field :known_date, maxlength_enabled: true,
form_group: { class: 'app-util--compact-form-group' },
hint: { text: f.i18n_date_hint },
legend: { text: f.i18n_legend },
caption: { text: f.i18n_caption } do
tag.p f.i18n_lead_text, class: 'govuk-body-m'
end %>

<%= render partial: 'steps/shared/approx_date_checkbox', locals: {
Expand Down
8 changes: 0 additions & 8 deletions config/locales/en/helpers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,6 @@ en:
steps_check_under_age_form:
caution_html: Select your age when you got the caution, not when you committed the offence
conviction_html: Select your age when you got convicted, not when you committed the offence
steps_caution_conditional_end_date_form:
conditional_end_date_html: *date_hint_text
steps_conviction_conviction_date_form:
conviction_date_html: *date_hint_text
steps_conviction_known_date_form:
known_date_html: *date_hint_text
steps_conviction_compensation_payment_date_form:
compensation_payment_date_html: *date_hint_text
steps_conviction_motoring_endorsement_form:
motoring_endorsement: An endorsement means that your conviction is recorded on your driving licence. Endorsements are usually given by courts.
steps_conviction_conviction_subtype_form:
Expand Down
9 changes: 4 additions & 5 deletions features/fixtures/files/steps_conviction_known_date.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<div class="govuk-form-group app-util--compact-form-group">
<fieldset class="govuk-fieldset" aria-describedby="steps-conviction-known-date-form-known-date-hint steps-conviction-known-date-form-known-date-supplemental">
<fieldset class="govuk-fieldset" aria-describedby="steps-conviction-known-date-form-known-date-hint">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--xl">
<h1 class="govuk-fieldset__heading"><span class="govuk-caption-xl">Bind over</span>When were you given the order?</h1>
</legend>

<div id="steps-conviction-known-date-form-known-date-supplemental"><p class="govuk-body-m">This is usually the day you were convicted in court.
</p></div>

<div class="govuk-hint" id="steps-conviction-known-date-form-known-date-hint">If you do not know the exact date, you can enter an approximate one. However, if you use an approximate date, your results will be approximate.
<div class="govuk-hint" id="steps-conviction-known-date-form-known-date-hint">
<p>This is usually the day you were convicted in court.
</p>If you do not know the exact date, you can enter an approximate one. However, if you use an approximate date, your results will be approximate.
<p>For example, 23 9 2018</p>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<div class="govuk-form-group govuk-form-group--error app-util--compact-form-group">
<fieldset class="govuk-fieldset" aria-describedby="steps-conviction-known-date-form-known-date-error steps-conviction-known-date-form-known-date-hint steps-conviction-known-date-form-known-date-supplemental">
<fieldset class="govuk-fieldset" aria-describedby="steps-conviction-known-date-form-known-date-error steps-conviction-known-date-form-known-date-hint">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--xl">
<h1 class="govuk-fieldset__heading"><span class="govuk-caption-xl">Bind over</span>When were you given the order?</h1>
</legend>

<div id="steps-conviction-known-date-form-known-date-supplemental"><p class="govuk-body-m">This is usually the day you were convicted in court.
</p></div>

<div class="govuk-hint" id="steps-conviction-known-date-form-known-date-hint">If you do not know the exact date, you can enter an approximate one. However, if you use an approximate date, your results will be approximate.
<div class="govuk-hint" id="steps-conviction-known-date-form-known-date-hint">
<p>This is usually the day you were convicted in court.
</p>If you do not know the exact date, you can enter an approximate one. However, if you use an approximate date, your results will be approximate.
<p>For example, 23 9 2018</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion features/multiples/cautions_and_convictions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Feature: A person with cautions and convictions
# And I should see "Check your answers"

# Check in progress warning quick smoke test
When I click the "header-service-name" link
When I click the "Check when to disclose cautions or convictions" link
Then I should see "This tool is being updated"
When I click "Continue" link
Then I should see "It looks like you already have a check in progress"
Expand Down
30 changes: 30 additions & 0 deletions spec/helpers/custom_form_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,36 @@
end
end

describe "#i18n_date_hint" do
let(:found_key) { "hint text about dates" }

before do
allow(I18n).to receive(:t).with(
"helpers/dictionary.date_hint_text",
).and_return(found_key)
end

describe "with lead_text argument" do
it "seeks the expected key" do
expect(found_key).to receive(:html_safe)

builder.i18n_date_hint("lead text")
end

it "wraps lead text in p tags" do
expect(builder.i18n_date_hint("lead text")).to include "<p>lead text</p>"
end
end

describe "without lead_text argument" do
it "gets lead text from i18n_lead_text" do
allow(builder).to receive(:i18n_lead_text).and_return "i18n_lead_text"

expect(builder.i18n_date_hint).to include "<p>i18n_lead_text</p>"
end
end
end

describe "#i18n_hint" do
let(:found_locale) { instance_double("locale") }

Expand Down
Loading