From e50d61fdd074b845ed3760293c9cb508d67c9cdb Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Mon, 30 Apr 2018 08:30:03 +0000 Subject: [PATCH] Remove heading component - update to use component from gem --- .../stylesheets/components/_heading.scss | 10 ------ app/views/components/_heading.html.erb | 11 ------- app/views/components/docs/heading.yml | 32 ------------------- .../_publication_inline_body.html.erb | 4 +-- app/views/content_items/consultation.html.erb | 16 +++++----- test/components/heading_test.rb | 28 ---------------- 6 files changed, 10 insertions(+), 91 deletions(-) delete mode 100644 app/assets/stylesheets/components/_heading.scss delete mode 100644 app/views/components/_heading.html.erb delete mode 100644 app/views/components/docs/heading.yml delete mode 100644 test/components/heading_test.rb diff --git a/app/assets/stylesheets/components/_heading.scss b/app/assets/stylesheets/components/_heading.scss deleted file mode 100644 index cb8b774ee..000000000 --- a/app/assets/stylesheets/components/_heading.scss +++ /dev/null @@ -1,10 +0,0 @@ -.app-c-heading { - @include bold-27; - margin-top: $gutter; - margin-bottom: $gutter-half; - - @include media(tablet) { - margin-top: 0; - margin-bottom: $gutter; - } -} diff --git a/app/views/components/_heading.html.erb b/app/views/components/_heading.html.erb deleted file mode 100644 index f2ecf3010..000000000 --- a/app/views/components/_heading.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<% - id = "id=#{id}" if id - heading_level ||= 1 - heading_level_tag = "h#{heading_level}" if [1,2,3,4,5,6].include? heading_level -%> -<<%= heading_level_tag %> - <%= id %> - class="app-c-heading" -> - <%= text %> -> diff --git a/app/views/components/docs/heading.yml b/app/views/components/docs/heading.yml deleted file mode 100644 index 3eda66d14..000000000 --- a/app/views/components/docs/heading.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Heading -description: A text heading -body: | - A heading tag with an optional id attribute, used predominantly to the left of content on consultations and publications. - - Real world examples: - - - [Publication](/government/publications/recognising-the-terrorist-threat) - - [Consultation](/government/consultations/proposal-for-the-future-of-rotherham-goldthorpe-jobcentre) -accessibility_criteria: | - The heading must: - - - be part of a correct heading structure for a page - - be semantically represented as a heading - - convey the heading level -examples: - default: - data: - text: 'Download the full outcome' - right_to_left: - data: - text: 'مستندات' - context: - right_to_left: true - with_id_attribute: - data: - text: 'Detail of outcome' - id: 'detail_of_outcome' - specific_heading_level: - data: - text: 'Original consultation' - heading_level: 3 diff --git a/app/views/content_items/_publication_inline_body.html.erb b/app/views/content_items/_publication_inline_body.html.erb index 9810331d7..768489455 100644 --- a/app/views/content_items/_publication_inline_body.html.erb +++ b/app/views/content_items/_publication_inline_body.html.erb @@ -1,4 +1,4 @@ -<%= render 'components/heading', +<%= render 'govuk_publishing_components/components/heading', text: t("publication.documents", count: 5), # This should always be pluralised. id: "documents-title" %> @@ -8,7 +8,7 @@ direction: page_text_direction %> -<%= render 'components/heading', text: t("publication.details"), id: "details-title" %> +<%= render 'govuk_publishing_components/components/heading', text: t("publication.details"), id: "details-title" %>
<%= render 'govuk_component/govspeak', diff --git a/app/views/content_items/consultation.html.erb b/app/views/content_items/consultation.html.erb index cadfcae21..8a872fc0a 100644 --- a/app/views/content_items/consultation.html.erb +++ b/app/views/content_items/consultation.html.erb @@ -31,7 +31,7 @@ <%= render 'components/notice', title: 'This consultation has concluded' %> <% if @content_item.final_outcome_documents? %> - <%= render 'components/heading', text: "Download the full outcome" %> + <%= render 'govuk_publishing_components/components/heading', text: "Download the full outcome" %>
<%= render 'govuk_component/govspeak', content: @content_item.final_outcome_documents, @@ -39,7 +39,7 @@
<% end %> - <%= render 'components/heading', text: "Detail of outcome" %> + <%= render 'govuk_publishing_components/components/heading', text: "Detail of outcome" %>
<%= render 'govuk_component/govspeak', content: @content_item.final_outcome_detail, @@ -48,7 +48,7 @@ <% end %> <% if @content_item.public_feedback_documents? %> - <%= render 'components/heading', text: "Feedback received" %> + <%= render 'govuk_publishing_components/components/heading', text: "Feedback received" %>
<%= render 'govuk_component/govspeak', content: @content_item.public_feedback_documents, @@ -57,7 +57,7 @@ <% end %> <% if @content_item.public_feedback_detail %> - <%= render 'components/heading', text: "Detail of feedback received" %> + <%= render 'govuk_publishing_components/components/heading', text: "Detail of feedback received" %>
<%= render 'govuk_component/govspeak', content: @content_item.public_feedback_detail, @@ -68,7 +68,7 @@ <% if @content_item.final_outcome? %>
- <%= render 'components/heading', text: "Original consultation", id: "original-consultation-title", heading_level: 2 %> + <%= render 'govuk_publishing_components/components/heading', text: "Original consultation", id: "original-consultation-title", heading_level: 2 %>
<% end %> @@ -102,11 +102,11 @@
- <%= render 'components/heading', text: "Consultation description" %> + <%= render 'govuk_publishing_components/components/heading', text: "Consultation description" %> <%= render 'govuk_component/govspeak', @content_item.govspeak_body %> <% if @content_item.documents? %> - <%= render 'components/heading', text: "Documents" %> + <%= render 'govuk_publishing_components/components/heading', text: "Documents" %>
<%= render 'govuk_component/govspeak', content: @content_item.documents, @@ -117,7 +117,7 @@ <% if @content_item.ways_to_respond? %>
- <%= render 'components/heading', text: "Ways to respond" %> + <%= render 'govuk_publishing_components/components/heading', text: "Ways to respond" %> <% @ways_to_respond_body = capture do %> <% if @content_item.respond_online_url %>
diff --git a/test/components/heading_test.rb b/test/components/heading_test.rb deleted file mode 100644 index ad68e1512..000000000 --- a/test/components/heading_test.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'component_test_helper' - -class HeadingTest < ComponentTestCase - def component_name - "heading" - end - - test "fails to render a heading when no title is given" do - assert_raise do - render_component({}) - end - end - - test "renders a heading correctly" do - render_component(text: 'Download documents') - assert_select "h1.app-c-heading", text: 'Download documents' - end - - test "renders a different heading level" do - render_component(text: 'Original consultation', heading_level: 3) - assert_select "h3.app-c-heading", text: 'Original consultation' - end - - test "has a specified id attribute" do - render_component(text: 'Consultation description', id: 'custom-id') - assert_select ".app-c-heading[id='custom-id']", text: 'Consultation description' - end -end