Skip to content

Commit

Permalink
Remove title component margin_top option
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
andysellick committed Dec 19, 2024
1 parent 074e6ab commit 62b059e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<span class="govuk-caption-xl gem-c-title__context" <%= "lang=#{context_locale}" if context_locale.present? %>>
<%= context %>
Expand Down
20 changes: 0 additions & 20 deletions spec/components/title_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']"
Expand Down

0 comments on commit 62b059e

Please sign in to comment.