From 3dfb20e1f9e6df0604c6f19c58ab82448c555859 Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Tue, 25 Feb 2025 14:55:22 +0000 Subject: [PATCH] BREAKING: Remove title component - Removes the title component, as we now use the heading component where titles are needed. - Also replaces gem-c-title references with gem-c-heading in the inverse_header and select component - Also replaces references to the title component in spec files so that tests pass --- CHANGELOG.md | 1 + .../_all_components.scss | 1 - .../components/_title.scss | 56 ------------- .../components/_select.html.erb | 7 +- .../components/_title.html.erb | 38 --------- .../components/docs/heading.yml | 4 + .../components/docs/inverse_header.yml | 22 ++++-- .../components/docs/title.yml | 64 --------------- .../audit_applications_spec.rb | 20 ++--- spec/component_guide/component_index_spec.rb | 4 +- spec/components/inverse_header_spec.rb | 8 +- spec/components/select_spec.rb | 2 +- spec/components/title_spec.rb | 78 ------------------- .../app/views/welcome/asset_helper.html.erb | 5 +- .../asset_helper_with_app_component.html.erb | 5 +- .../asset_helper_with_app_view.html.erb | 5 +- .../welcome/contextual_navigation.html.erb | 2 +- .../app/views/welcome/error_summary.html.erb | 5 +- spec/dummy/app/views/welcome/table.html.erb | 2 +- spec/features/asset_helper_spec.rb | 4 +- .../app_helpers/asset_helper_spec.rb | 2 +- 21 files changed, 58 insertions(+), 277 deletions(-) delete mode 100644 app/assets/stylesheets/govuk_publishing_components/components/_title.scss delete mode 100644 app/views/govuk_publishing_components/components/_title.html.erb delete mode 100644 app/views/govuk_publishing_components/components/docs/title.yml delete mode 100644 spec/components/title_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a7d39b8a4..292f7d5126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ## Unreleased +* **BREAKING:** Remove title component ([PR #4653](https://github.com/alphagov/govuk_publishing_components/pull/4653)) * Fix bottom border colour issue in the super nav search button ([PR #4642](https://github.com/alphagov/govuk_publishing_components/pull/4642)) * Use govuk-spacing instead of govuk-gutter ([PR #4650](https://github.com/alphagov/govuk_publishing_components/pull/4650)) * Ensure 'search with autocomplete' component uses its own margin bottom ([PR #4637](https://github.com/alphagov/govuk_publishing_components/pull/4637)) diff --git a/app/assets/stylesheets/govuk_publishing_components/_all_components.scss b/app/assets/stylesheets/govuk_publishing_components/_all_components.scss index 30c337b433..1d7979caab 100644 --- a/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +++ b/app/assets/stylesheets/govuk_publishing_components/_all_components.scss @@ -85,6 +85,5 @@ @import "components/tabs"; @import "components/table"; @import "components/textarea"; -@import "components/title"; @import "components/translation-nav"; @import "components/warning-text"; diff --git a/app/assets/stylesheets/govuk_publishing_components/components/_title.scss b/app/assets/stylesheets/govuk_publishing_components/components/_title.scss deleted file mode 100644 index f37877bef9..0000000000 --- a/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +++ /dev/null @@ -1,56 +0,0 @@ -@import "govuk_publishing_components/individual_component_support"; - -.gem-c-title { - @include govuk-media-query($from: tablet) { - padding-top: govuk-spacing(8); - } -} - -.gem-c-title--inverse { - color: govuk-colour("white"); - - .gem-c-title__text, - .gem-c-title__context { - color: inherit; - } -} - -.gem-c-title__context-link { - text-decoration: none; - - &:link, - &:visited { - color: inherit; - } - - &:hover { - text-decoration: underline; - } - - &:focus { - text-decoration: none; - color: $govuk-focus-text-colour; - } -} - -.gem-c-title__text { - margin: 0; -} - -@include govuk-media-query($media-type: print) { - .gem-c-title { - margin: 5mm 0 10mm !important; // stylelint-disable-line declaration-no-important - } - - .gem-c-title__context { - margin: 0; - } - - .gem-c-title__text { - margin-top: 0; - } - - .gem-c-title--inverse { - color: $govuk-print-text-colour; - } -} diff --git a/app/views/govuk_publishing_components/components/_select.html.erb b/app/views/govuk_publishing_components/components/_select.html.erb index 41faacb7cf..4fb11f01fd 100644 --- a/app/views/govuk_publishing_components/components/_select.html.erb +++ b/app/views/govuk_publishing_components/components/_select.html.erb @@ -16,8 +16,11 @@ <% if select_helper.options.any? && id && label %> <%= content_tag :div, class: select_helper.css_classes do %> <% if is_page_heading %> - <% add_gem_component_stylesheet("title") %> - <%= tag.h1 label_tag(id, label, class: select_helper.label_classes), class: "gem-c-title__text" %> + <% add_gem_component_stylesheet("heading") %> + <%= render "govuk_publishing_components/components/heading", { + text: label_tag(id, label, class: select_helper.label_classes), + heading_level: 1 + } %> <% else %> <%= label_tag(id, label, class: select_helper.label_classes) %> <% end %> diff --git a/app/views/govuk_publishing_components/components/_title.html.erb b/app/views/govuk_publishing_components/components/_title.html.erb deleted file mode 100644 index 5dd4cba454..0000000000 --- a/app/views/govuk_publishing_components/components/_title.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -<% - add_gem_component_stylesheet("title") - - average_title_length ||= false - - context ||= false - context_locale ||= false - context_inside ||= false - - inverse ||= false - local_assigns[:margin_bottom] ||= 8 - margin_bottom = [*0..9].include?(local_assigns[:margin_bottom]) ? "govuk-!-margin-bottom-#{local_assigns[:margin_bottom]}" : "govuk-!-margin-bottom-3" - - classes = %w[gem-c-title] - classes << "gem-c-title--inverse" if inverse - classes << margin_bottom - - heading_classes = %w[gem-c-title__text] - heading_classes << (average_title_length.present? ? 'govuk-heading-l' : 'govuk-heading-xl') -%> -<% @context_block = capture do %> - > - <%= context %> - -<% end %> - -<%= content_tag(:div, class: classes) do %> - <% if context && !context_inside %> - <%= @context_block %> - <% end %> - -
Published 22 April 2016
diff --git a/app/views/govuk_publishing_components/components/docs/title.yml b/app/views/govuk_publishing_components/components/docs/title.yml deleted file mode 100644 index 750f383d19..0000000000 --- a/app/views/govuk_publishing_components/components/docs/title.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Page title -description: A page title with optional context label -body: | - This contains an optional parameter for average title length. The two valid - values for this parameter are 'medium' or 'long'. Medium titles are titles - where the average is around 30 characters or less. Long titles would have - an average length of nearer 50 characters or more. - - On average the titles on government bits of content are 50 characters. The - average for bits of general guidance are nearer 27 characters long. -accessibility_criteria: | - The page title must: - - - be part of a correct heading structure for a page - - be semantically represented as a heading - - convey the heading level -shared_accessibility_criteria: - - link -examples: - default: - data: - title: My page title - with_context: - data: - context: Publication - title: My page title - with_context_inside: - description: | - If the context should be considered part of the page heading, you can nest the context within the
.
- data:
- context: Publication
- title: My page title
- context_inside: true
- with_context_language_labelled:
- description: |
- Sometimes this component appears on a page that has been translated. The title will naturally be supplied in the required language but the context string may fall back to the default. In these instances we need to label the language so the page remains semantic and screenreaders can handle the switch.
-
- The `lang` attribute **must** be set to a [valid BCP47 string](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang#Language_tag_syntax). A valid code can be the two or three letter language code - for example, English is `en` or `eng`, Korean is `ko` or `kor` - but if in doubt please check.
- data:
- context: Publication
- context_locale: en
- title: My page title
- long_title_with_context:
- data:
- context: Publication
- title: My page title which is often really long and verbose and has lots of extra words it doesn't need
- average_title_length: long
- with_margin_bottom:
- description: |
- The component accepts a number for margin bottom from `0` to `9` (`0px` to `60px`) using the [GOV.UK Frontend spacing scale](https://design-system.service.gov.uk/styles/spacing/#the-responsive-spacing-scale). It defaults to having a margin bottom of 50px.
-
- This margin is responsive at certain sizes, see the link above for more detail. Note also that the component has a (responsive) top margin set as well, which cannot be modified.
- data:
- title: 'Margin bottom of 10px'
- margin_bottom: 2
- in_html_publication:
- description: Page titles are used in HTML Publications ([see example](https://www.gov.uk/government/publications/fees-for-civil-and-family-courts/court-fees-for-the-high-court-county-court-and-family-court))
- data:
- context: Publication
- title: HTML publication page title
- inverse: true
- margin_bottom: 0
- context:
- dark_background: true
diff --git a/spec/component_guide/audit_applications_spec.rb b/spec/component_guide/audit_applications_spec.rb
index be180ab6ac..019f43fe28 100644
--- a/spec/component_guide/audit_applications_spec.rb
+++ b/spec/component_guide/audit_applications_spec.rb
@@ -13,7 +13,7 @@
components_found: [
{
location: "template",
- components: ["accordion", "back link", "contextual breadcrumbs", "contextual footer", "contextual sidebar", "details", "error summary", "feedback", "govspeak", "input", "layout footer", "layout for admin", "layout for public", "layout header", "notice", "skip link", "tabs", "title"],
+ components: ["accordion", "back link", "contextual breadcrumbs", "contextual footer", "contextual sidebar", "details", "error summary", "feedback", "govspeak", "heading", "input", "layout footer", "layout for admin", "layout for public", "layout header", "notice", "skip link", "tabs"],
},
{
location: "stylesheet",
@@ -47,6 +47,15 @@
feedback: ["app/views/layouts/application.html.erb"],
govspeak: ["app/views/welcome/contextual_navigation.html.erb", "lib/1_test_file_1.rb"],
input: ["app/views/welcome/error_summary.html.erb", "app/views/welcome/error_summary.html.erb"],
+ heading:
+ [
+ "app/views/welcome/asset_helper.html.erb",
+ "app/views/welcome/asset_helper_with_app_component.html.erb",
+ "app/views/welcome/asset_helper_with_app_view.html.erb",
+ "app/views/welcome/contextual_navigation.html.erb",
+ "app/views/welcome/error_summary.html.erb",
+ "app/views/welcome/table.html.erb",
+ ],
"layout footer": ["app/views/layouts/dummy_admin_layout.html.erb"],
"layout for admin": ["app/views/layouts/dummy_admin_layout.html.erb"],
"layout for public": ["app/views/layouts/dummy_public_layout.html.erb"],
@@ -60,15 +69,6 @@
"app/views/welcome/asset_helper_with_app_view.html.erb",
],
tabs: ["app/views/welcome/error_summary.html.erb", "app/views/welcome/tabs_example.html.erb"],
- title:
- [
- "app/views/welcome/asset_helper.html.erb",
- "app/views/welcome/asset_helper_with_app_component.html.erb",
- "app/views/welcome/asset_helper_with_app_view.html.erb",
- "app/views/welcome/contextual_navigation.html.erb",
- "app/views/welcome/error_summary.html.erb",
- "app/views/welcome/table.html.erb",
- ],
},
helper_references: {
BrandHelper: ["lib/test_file_3.rb"],
diff --git a/spec/component_guide/component_index_spec.rb b/spec/component_guide/component_index_spec.rb
index cab419a89a..123d696865 100644
--- a/spec/component_guide/component_index_spec.rb
+++ b/spec/component_guide/component_index_spec.rb
@@ -58,6 +58,7 @@
@import 'govuk_publishing_components/components/error-summary';
@import 'govuk_publishing_components/components/feedback';
@import 'govuk_publishing_components/components/govspeak';
+@import 'govuk_publishing_components/components/heading';
@import 'govuk_publishing_components/components/hint';
@import 'govuk_publishing_components/components/input';
@import 'govuk_publishing_components/components/label';
@@ -77,8 +78,7 @@
@import 'govuk_publishing_components/components/step-by-step-nav-header';
@import 'govuk_publishing_components/components/step-by-step-nav-related';
@import 'govuk_publishing_components/components/tabs';
-@import 'govuk_publishing_components/components/textarea';
-@import 'govuk_publishing_components/components/title';"
+@import 'govuk_publishing_components/components/textarea';"
expect(page).to have_selector(".component-doc-h2", text: "Gem components used by this app (20)")
expect(page).to have_selector(".govuk-details__summary-text", text: "Suggested imports for this application")
diff --git a/spec/components/inverse_header_spec.rb b/spec/components/inverse_header_spec.rb
index fcfbfb5464..c15543c7cd 100644
--- a/spec/components/inverse_header_spec.rb
+++ b/spec/components/inverse_header_spec.rb
@@ -1,11 +1,11 @@
require "rails_helper"
def block
- "+ "
Publication
-