From 62b059e804273fb1cbbe6e52f6232a55f6d0a742 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Thu, 19 Dec 2024 16:02:06 +0000 Subject: [PATCH] Remove title component margin_top option - our spacing model is to apply margin bottom, so this is an anomaly - replace margin_top with default padding on the component, so no visual changes - margin_top option isn't widely used and can be replaced with alternatives, separate PRs will be raised --- .../components/_title.scss | 6 ++++++ .../components/_title.html.erb | 3 --- spec/components/title_spec.rb | 20 ------------------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/app/assets/stylesheets/govuk_publishing_components/components/_title.scss b/app/assets/stylesheets/govuk_publishing_components/components/_title.scss index 9f31d7d1ea..f37877bef9 100644 --- a/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +++ b/app/assets/stylesheets/govuk_publishing_components/components/_title.scss @@ -1,5 +1,11 @@ @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"); diff --git a/app/views/govuk_publishing_components/components/_title.html.erb b/app/views/govuk_publishing_components/components/_title.html.erb index 265cccceb7..9d8f06de90 100644 --- a/app/views/govuk_publishing_components/components/_title.html.erb +++ b/app/views/govuk_publishing_components/components/_title.html.erb @@ -8,20 +8,17 @@ context_inside ||= false inverse ||= false - local_assigns[:margin_top] ||= 8 local_assigns[:margin_bottom] ||= 8 shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) classes = %w[gem-c-title] classes << "gem-c-title--inverse" if inverse - classes << shared_helper.get_margin_top classes << shared_helper.get_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 %> diff --git a/spec/components/title_spec.rb b/spec/components/title_spec.rb index 685b2ba230..176d925122 100644 --- a/spec/components/title_spec.rb +++ b/spec/components/title_spec.rb @@ -71,26 +71,6 @@ def component_name assert_select "[class^='govuk-\!-margin-bottom-']", false end - it "has a default margin top of 8" do - render_component(title: "Margin default") - assert_select '.gem-c-title.govuk-\!-margin-top-8' - end - - it "applies a margin top of 0" do - render_component(title: "Margin 0", margin_top: 0) - assert_select '.gem-c-title.govuk-\!-margin-top-0' - end - - it "applies a valid margin top" do - render_component(title: "Margin 4", margin_top: 4) - assert_select '.gem-c-title.govuk-\!-margin-top-4' - end - - it "ignores an invalid margin top" do - render_component(title: "Margin wat", margin_top: 17) - assert_select "[class^='govuk-\!-margin-top-']", false - end - it "applies context language if supplied to a context link" do render_component(title: "Bonjour", context: "Format", context_locale: "en") assert_select ".govuk-caption-xl[lang='en']"