Skip to content

Commit

Permalink
Merge pull request #4508 from alphagov/title-margin
Browse files Browse the repository at this point in the history
Remove title component margin_top option
  • Loading branch information
andysellick authored Jan 28, 2025
2 parents c6cce4f + a6ea4c2 commit 15b1408
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

## Unreleased

* Remove title component margin_top option ([PR #4508](https://github.com/alphagov/govuk_publishing_components/pull/4508))
* **BREAKING** Add global bar component from static ([PR #4538](https://github.com/alphagov/govuk_publishing_components/pull/4538))
* Add custom padding to inverse header ([PR #4590](https://github.com/alphagov/govuk_publishing_components/pull/4590))
* Add another: fix problem in createRemoveButtons method ([PR #11719](https://github.com/alphagov/govuk_publishing_components/pull/4586))
Expand Down
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 15b1408

Please sign in to comment.