Skip to content

Commit

Permalink
Swap inset text top margin with padding
Browse files Browse the repository at this point in the history
We're trying to standardise the margins at the parent level of components
  • Loading branch information
AshGDS committed Feb 20, 2025
1 parent 58c9e43 commit 13311ad
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Use component wrapper on 'add another' component ([PR #4632](https://github.com/alphagov/govuk_publishing_components/pull/4632))
* Use component wrapper on 'copy to clipboard' component ([PR #4633](https://github.com/alphagov/govuk_publishing_components/pull/4633))
* **BREAKING** Remove custom_header and custom_layout options ([PR #4635](https://github.com/alphagov/govuk_publishing_components/pull/4635))
* Swap inset text top margin with padding ([PR #4634](https://github.com/alphagov/govuk_publishing_components/pull/4634))

## 51.2.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,15 @@
break-inside: avoid;
}
}

.gem-c-inset-text {
padding-top: govuk-spacing(4);

.govuk-inset-text {
margin-top: 0;
}

@include govuk-media-query($from: tablet) {
padding-top: govuk-spacing(6);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
local_assigns[:margin_bottom] ||= 6

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-inset-text govuk-inset-text gem-c-force-print-link-styles-within")
component_helper.add_class("gem-c-inset-text gem-c-force-print-link-styles-within")
component_helper.set_id(id)
%>
<%= tag.div(**component_helper.all_attributes) do %>
<% if defined? text %>
<%= text %>
<% elsif block_given? %>
<%= yield %>
<% end %>
<div class="govuk-inset-text">
<% if defined? text %>
<%= text %>
<% elsif block_given? %>
<%= yield %>
<% end %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions spec/components/inset_text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def component_name
it "renders inset text" do
render_component(text: "It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application.")

assert_select(".govuk-inset-text.govuk-\\!-margin-bottom-6", text: "It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application.")
assert_select(".gem-c-inset-text.govuk-\\!-margin-bottom-6", text: "It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application.")
end

it "renders a block" do
Expand Down Expand Up @@ -36,6 +36,6 @@ def component_name
margin_bottom: 9,
)

assert_select(".govuk-inset-text.govuk-\\!-margin-bottom-9", text: "margin!")
assert_select(".gem-c-inset-text.govuk-\\!-margin-bottom-9", text: "margin!")
end
end

0 comments on commit 13311ad

Please sign in to comment.