From 67176291105067eb0bc3dfd7d2ffbbb88ecb341a Mon Sep 17 00:00:00 2001 From: Jon Kirwan <87758239+jon-kirwan@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:12:27 +0000 Subject: [PATCH 1/4] Use error message property to replace error component --- .../service_sign_in/_choose_sign_in.html.erb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/views/content_items/service_sign_in/_choose_sign_in.html.erb b/app/views/content_items/service_sign_in/_choose_sign_in.html.erb index 1489f365e..b4148c85c 100644 --- a/app/views/content_items/service_sign_in/_choose_sign_in.html.erb +++ b/app/views/content_items/service_sign_in/_choose_sign_in.html.erb @@ -23,16 +23,19 @@ method: "post", data: data_attrs) do %> <% legend_text = render 'govuk_publishing_components/components/title', title: @content_item.title %> + <% description_text = render 'govuk_publishing_components/components/govspeak' do %> + <% raw(@content_item.description) %> + <% end %> + <%= render "govuk_publishing_components/components/fieldset", legend_text: legend_text do %>
- <%= render 'govuk_publishing_components/components/govspeak', {} do %> - <%= raw(@content_item.description) %> - <% end %> - <% if @error %> - <%= render "components/error_message", text: t('service_sign_in.error.option') %> - <% end %> - <%= render "govuk_publishing_components/components/radio", id_prefix: @content_item.options_id, name: "option", items: @content_item.options %> + <%= render "govuk_publishing_components/components/radio", + id_prefix: @content_item.options_id, + name: "option", + error_message: (t('service_sign_in.error.option') if @error), + description: description_text, + items: @content_item.options %>
<% end %> From eb2d2fa159df8cc828237e81711f78322db28f78 Mon Sep 17 00:00:00 2001 From: Jon Kirwan <87758239+jon-kirwan@users.noreply.github.com> Date: Tue, 6 Feb 2024 09:59:14 +0000 Subject: [PATCH 2/4] Update tests --- test/components/error_message_test.rb | 23 ------------------- .../service_sign_in/choose_sign_in_test.rb | 2 +- 2 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 test/components/error_message_test.rb diff --git a/test/components/error_message_test.rb b/test/components/error_message_test.rb deleted file mode 100644 index 15704288e..000000000 --- a/test/components/error_message_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "component_test_helper" - -class ErrorMessageTest < ComponentTestCase - def component_name - "error_message" - end - - test "fails to render no data is given" do - assert_raise do - render_component({}) - end - end - - test "renders an error message correctly" do - render_component(text: "Descriptive error message") - assert_select ".app-c-error-message", text: "Descriptive error message" - end - - test "renders an error message with an id" do - render_component(text: "Descriptive error message with id", id: "unique-error-id") - assert_select ".app-c-error-message[id='unique-error-id']", text: "Descriptive error message with id" - end -end diff --git a/test/integration/service_sign_in/choose_sign_in_test.rb b/test/integration/service_sign_in/choose_sign_in_test.rb index c308f76f9..d92a3563a 100644 --- a/test/integration/service_sign_in/choose_sign_in_test.rb +++ b/test/integration/service_sign_in/choose_sign_in_test.rb @@ -61,7 +61,7 @@ class ChooseSignInTest < ActionDispatch::IntegrationTest # Make sure the id is the same as the link href so that they'll link together properly. assert page.has_css?(".gem-c-radio input[id='option-0'][value='use-government-gateway']", visible: false) - assert page.has_css?(".app-c-error-message", text: "Please select an option") + assert page.has_css?(".gem-c-error-message", text: "Please select an option") end test "page less options without an or divider" do From 5fb7b7d00008dd5775692de9973de53511022b67 Mon Sep 17 00:00:00 2001 From: Jon Kirwan <87758239+jon-kirwan@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:11:37 +0000 Subject: [PATCH 3/4] Remove unused error component --- .../stylesheets/components/_error-message.scss | 10 ---------- app/views/components/_error_message.html.erb | 10 ---------- app/views/components/docs/error_message.yml | 13 ------------- config/initializers/dartsass.rb | 1 - 4 files changed, 34 deletions(-) delete mode 100644 app/assets/stylesheets/components/_error-message.scss delete mode 100644 app/views/components/_error_message.html.erb delete mode 100644 app/views/components/docs/error_message.yml diff --git a/app/assets/stylesheets/components/_error-message.scss b/app/assets/stylesheets/components/_error-message.scss deleted file mode 100644 index ea7263917..000000000 --- a/app/assets/stylesheets/components/_error-message.scss +++ /dev/null @@ -1,10 +0,0 @@ -@import "govuk_publishing_components/individual_component_support"; -@import "helpers/variables"; - -.app-c-error-message { - display: block; - margin-bottom: govuk-spacing(3); - clear: both; - color: $govuk-error-colour; - @include govuk-font(19, $weight: bold); -} diff --git a/app/views/components/_error_message.html.erb b/app/views/components/_error_message.html.erb deleted file mode 100644 index afa8b7614..000000000 --- a/app/views/components/_error_message.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% add_app_component_stylesheet("error-message") %> -<% id ||= false %> - - id="<%= id %>" - <% end %> -> - <%= text %> - diff --git a/app/views/components/docs/error_message.yml b/app/views/components/docs/error_message.yml deleted file mode 100644 index 7b0bc9a58..000000000 --- a/app/views/components/docs/error_message.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Form error message -description: Component to show a red error message - used for form validation. Use inside a label or legend. -accessibility_criteria: | - - have a text contrast ratio higher than 4.5:1 against the background colour to meet [WCAG AA](https://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast) -examples: - default: - data: - text: 'Descriptive error message' - outside_label_or_legend: - description: 'Used if the error message is not inside a label or legend, for example with `aria-describedby`' - data: - id: 'unique-error-id' - text: 'Descriptive error message' diff --git a/config/initializers/dartsass.rb b/config/initializers/dartsass.rb index 16ee521ff..8dfe080c6 100644 --- a/config/initializers/dartsass.rb +++ b/config/initializers/dartsass.rb @@ -4,7 +4,6 @@ "components/_banner.scss" => "components/_banner.css", "components/_contents-list-with-body.scss" => "components/_contents-list-with-body.css", "components/_download-link.scss" => "components/_download-link.css", - "components/_error-message.scss" => "components/_error-message.css", "components/_figure.scss" => "components/_figure.css", "components/_important-metadata.scss" => "components/_important-metadata.css", "components/_published-dates.scss" => "components/_published-dates.css", From 4e4f628376c9d107560ca9771f2a754684a058de Mon Sep 17 00:00:00 2001 From: Jon Kirwan <87758239+jon-kirwan@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:17:26 +0000 Subject: [PATCH 4/4] Remove unused 'helpers/variables' Only used by the error component (now removed) --- .../stylesheets/components/helpers/_variables.scss | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 app/assets/stylesheets/components/helpers/_variables.scss diff --git a/app/assets/stylesheets/components/helpers/_variables.scss b/app/assets/stylesheets/components/helpers/_variables.scss deleted file mode 100644 index 4933f358f..000000000 --- a/app/assets/stylesheets/components/helpers/_variables.scss +++ /dev/null @@ -1,10 +0,0 @@ -$app-text-colour: $govuk-text-colour; -$app-secondary-text-colour: govuk-colour("dark-grey", $legacy: "grey-1"); - -// Border widths -$app-border-width-mobile: 4px; -$app-border-width-tablet: 5px; -$app-border-width-form-element: 2px; - -// Focus -$app-focus-width: 3px;