From c4988aeaf7c39592d403f2fecdc8b8f1e33435cc Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Thu, 31 May 2018 10:07:58 +0000 Subject: [PATCH 1/6] Remove notice component --- .../stylesheets/components/_notice.scss | 33 --------- app/views/components/_notice.html.erb | 22 ------ app/views/components/docs/notice.yml | 23 ------- test/components/notice_test.rb | 67 ------------------- 4 files changed, 145 deletions(-) delete mode 100644 app/assets/stylesheets/components/_notice.scss delete mode 100644 app/views/components/_notice.html.erb delete mode 100644 app/views/components/docs/notice.yml delete mode 100644 test/components/notice_test.rb diff --git a/app/assets/stylesheets/components/_notice.scss b/app/assets/stylesheets/components/_notice.scss deleted file mode 100644 index b52537c42..000000000 --- a/app/assets/stylesheets/components/_notice.scss +++ /dev/null @@ -1,33 +0,0 @@ -.app-c-notice { - clear: both; - padding: $gutter-two-thirds; - border: 2px solid $govuk-blue; - - @include media(mobile) { - padding: $gutter-half; - } - - .govuk-govspeak { - p:last-child { - margin-bottom: 0; - } - } -} - -.app-c-notice--bottom-margin { - @include responsive-bottom-margin; -} - -.app-c-notice__title { - @include bold-27; - margin-bottom: $gutter-one-third; - - &:last-child { - margin-bottom: 0; - } -} - -.app-c-notice__description { - @include core-19; - margin-bottom: 0; -} diff --git a/app/views/components/_notice.html.erb b/app/views/components/_notice.html.erb deleted file mode 100644 index 8a1e560a7..000000000 --- a/app/views/components/_notice.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -<% if defined?(title) %> - <% - description_text ||= false - description_govspeak ||= false - margin_bottom_class = " app-c-notice--bottom-margin" unless local_assigns[:margin_bottom] - %> -
- <% if description_text || description_govspeak %> -

<%= title %>

- <% else %> - <%= title %> - <% end %> - - <% if description_text %> -

<%= description_text %>

- <% end %> - - <% if description_govspeak %> - <%= render 'govuk_component/govspeak', content: description_govspeak %> - <% end %> -
-<% end %> diff --git a/app/views/components/docs/notice.yml b/app/views/components/docs/notice.yml deleted file mode 100644 index 1482887a0..000000000 --- a/app/views/components/docs/notice.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Notice -description: A notice to convey and highlight information -body: | - The notice component replaces the notice and withdrawal notice patterns on GOV.UK. - - The component accepts either a simple string description_text parameter that it wraps in a paragraph, or a description_govspeak parameter that is rendered through govspeak for more complex HTML layout. -accessibility_criteria: | - The notice must: - - - have a border colour contrast ratio of more than 4.5:1 with its background to be visually distinct. - - always render headings with associated description content, so there are no isolated heading elements inside the component -examples: - default: - data: - title: 'Statistics release cancelled' - with_description_text: - data: - title: 'Statistics release cancelled' - description_text: 'Duplicate, added in error' - with_description_govspeak: - data: - title: 'Statistics release update' - description_govspeak: '

The Oil & Gas Authority launched a new website on 3 October 2016 to reflect its new status as a government company.

This formalises the transfer of the Secretary of State’s regulatory powers in respect of oil and gas to the OGA, and grants it new powers. This website will no longer be updated. Visitors should refer to www.ogauthority.co.uk

' diff --git a/test/components/notice_test.rb b/test/components/notice_test.rb deleted file mode 100644 index ec79a6eb4..000000000 --- a/test/components/notice_test.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'component_test_helper' - -class NoticeTest < ComponentTestCase - def component_name - "notice" - end - - test "fails to render when no parameters are given" do - assert_empty render_component({}) - end -end - -# This component renders some content using govspeak, which cannot currently be tested using the approach above. -# To cover this gap, below is an integration test that loads the notice page in the component guide in order to test -# that the remaining aspects of the component are being rendered correctly. - -class NoticeGovspeakTest < ActionDispatch::IntegrationTest - test "renders a notice with only a title and no description" do - visit '/component-guide/notice/default' - - within '.component-guide-preview' do - assert page.has_selector?(".app-c-notice__title", text: "Statistics release cancelled") - assert page.has_no_selector?(".app-c-notice__description") - end - end - - test "renders a notice with an aria label and region" do - visit '/component-guide/notice/default' - assert page.has_selector?(".component-guide-preview section[aria-label][role=region]") - end - - test "renders a notice with a title and description text" do - visit '/component-guide/notice/with_description_text' - - within '.component-guide-preview' do - assert page.has_selector?(".app-c-notice__title", text: "Statistics release cancelled") - assert page.has_selector?(".app-c-notice__description", text: "Duplicate, added in error") - end - end - - test "renders a notice with a title and description govspeak" do - visit '/component-guide/notice/with_description_govspeak' - - within '.component-guide-preview' do - assert page.has_selector?(".app-c-notice__title", text: "Statistics release update") - assert_has_component_govspeak("

The Oil & Gas Authority launched a new website on 3 October 2016 to reflect its new status as a government company.

This formalises the transfer of the Secretary of State’s regulatory powers in respect of oil and gas to the OGA, and grants it new powers. This website will no longer be updated. Visitors should refer to www.ogauthority.co.uk

") - end - end - - test "renders title as heading only if description present" do - visit '/component-guide/notice/with_description_text' - - within '.component-guide-preview' do - assert page.has_selector?("h2.app-c-notice__title", text: "Statistics release cancelled") - assert page.has_selector?("p.app-c-notice__description", text: "Duplicate, added in error") - end - end - - test "render title as paragraph if no description present" do - visit '/component-guide/notice/default' - - within '.component-guide-preview' do - assert page.has_selector?("span.app-c-notice__title", text: "Statistics release cancelled") - assert page.has_no_selector?(".app-c-notice__description") - end - end -end From 7812977f55da2489a134046e4bd9de5b1f01f4a0 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Thu, 31 May 2018 10:08:14 +0000 Subject: [PATCH 2/6] Use notice component from gem --- app/views/content_items/case_study.html.erb | 2 +- app/views/content_items/consultation.html.erb | 8 ++++---- .../content_items/corporate_information_page.html.erb | 2 +- app/views/content_items/detailed_guide.html.erb | 2 +- app/views/content_items/document_collection.html.erb | 2 +- app/views/content_items/fatality_notice.html.erb | 2 +- app/views/content_items/html_publication.html.erb | 2 +- app/views/content_items/news_article.html.erb | 2 +- app/views/content_items/publication.html.erb | 2 +- app/views/content_items/speech.html.erb | 2 +- app/views/content_items/statistical_data_set.html.erb | 2 +- app/views/content_items/statistics_announcement.html.erb | 4 ++-- .../content_items/world_location_news_article.html.erb | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/views/content_items/case_study.html.erb b/app/views/content_items/case_study.html.erb index 13e1b8574..2ba6522a4 100644 --- a/app/views/content_items/case_study.html.erb +++ b/app/views/content_items/case_study.html.erb @@ -15,7 +15,7 @@ <%= render 'shared/publisher_metadata_with_logo' %> -<%= render 'components/notice', @content_item.withdrawal_notice_component %> +<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
diff --git a/app/views/content_items/consultation.html.erb b/app/views/content_items/consultation.html.erb index 69db3b150..f1575319b 100644 --- a/app/views/content_items/consultation.html.erb +++ b/app/views/content_items/consultation.html.erb @@ -13,7 +13,7 @@ <%= render 'shared/publisher_metadata_with_logo', content_item: @content_item %> <%= render 'shared/history_notice', content_item: @content_item %> -<%= render 'components/notice', @content_item.withdrawal_notice_component %> +<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
@@ -25,16 +25,16 @@ <% if @content_item.opening_date_midnight? %>on<% else %>at<% end %> <% end %> - <%= render 'components/notice', title: "This consultation isn't open yet", description_text: content_item_unopened %> + <%= render 'govuk_publishing_components/components/notice', title: "This consultation isn't open yet", description_text: content_item_unopened %> <% elsif @content_item.pending_final_outcome? %> <% content_item_final_outcome = capture do %> Visit this page again soon to download the outcome to this public feedback. <% end %> - <%= render 'components/notice', title: 'We are analysing your feedback', description_text: content_item_final_outcome, margin_bottom: 0 %> + <%= render 'govuk_publishing_components/components/notice', title: 'We are analysing your feedback', description_text: content_item_final_outcome, margin_bottom: 0 %> <% elsif @content_item.final_outcome? %> - <%= render 'components/notice', title: 'This consultation has concluded' %> + <%= render 'govuk_publishing_components/components/notice', title: 'This consultation has concluded' %> <% if @content_item.final_outcome_documents? %> <%= render 'govuk_publishing_components/components/heading', text: "Download the full outcome", mobile_top_margin: true %> diff --git a/app/views/content_items/corporate_information_page.html.erb b/app/views/content_items/corporate_information_page.html.erb index ee761c8d3..060f9dc15 100644 --- a/app/views/content_items/corporate_information_page.html.erb +++ b/app/views/content_items/corporate_information_page.html.erb @@ -39,7 +39,7 @@ <%= render 'shared/translations' %>
<%= render 'govuk_publishing_components/components/lead_paragraph', text: @content_item.description %> - <%= render 'components/notice', @content_item.withdrawal_notice_component %> + <%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
diff --git a/app/views/content_items/detailed_guide.html.erb b/app/views/content_items/detailed_guide.html.erb index 2c6662703..aef987861 100644 --- a/app/views/content_items/detailed_guide.html.erb +++ b/app/views/content_items/detailed_guide.html.erb @@ -16,7 +16,7 @@ <%= render 'shared/publisher_metadata_with_logo' %> <%= render 'shared/history_notice', content_item: @content_item %> -<%= render 'components/notice', @content_item.withdrawal_notice_component %> +<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
diff --git a/app/views/content_items/document_collection.html.erb b/app/views/content_items/document_collection.html.erb index e2b43039a..7ad2c6665 100644 --- a/app/views/content_items/document_collection.html.erb +++ b/app/views/content_items/document_collection.html.erb @@ -14,7 +14,7 @@ <%= render 'shared/translations', content_item: @content_item %>
<%= render 'govuk_publishing_components/components/lead_paragraph', text: @content_item.description %> - <%= render 'components/notice', @content_item.withdrawal_notice_component %> + <%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %> <%= render 'shared/history_notice', content_item: @content_item %>
diff --git a/app/views/content_items/fatality_notice.html.erb b/app/views/content_items/fatality_notice.html.erb index cf148090c..6c1233257 100644 --- a/app/views/content_items/fatality_notice.html.erb +++ b/app/views/content_items/fatality_notice.html.erb @@ -15,7 +15,7 @@
<%= render 'shared/publisher_metadata_with_logo' %> -<%= render 'components/notice', @content_item.withdrawal_notice_component %> +<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
diff --git a/app/views/content_items/html_publication.html.erb b/app/views/content_items/html_publication.html.erb index 0ea82908b..9bc5b5e34 100644 --- a/app/views/content_items/html_publication.html.erb +++ b/app/views/content_items/html_publication.html.erb @@ -28,7 +28,7 @@

<%= @content_item.last_changed %>

<% end %> -<%= render 'components/notice', @content_item.withdrawal_notice_component %> +<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>