Skip to content

Commit

Permalink
Merge pull request #4634 from alphagov/inset-text-margin
Browse files Browse the repository at this point in the history
Swap inset text top margin with padding
  • Loading branch information
AshGDS authored Feb 20, 2025
2 parents 2869b4a + 6ad3f73 commit 4d7176b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Swap inset text top margin with padding ([PR #4634](https://github.com/alphagov/govuk_publishing_components/pull/4634))

## 52.0.0

* Make account layout respect `for_static` ([PR #4630](https://github.com/alphagov/govuk_publishing_components/pull/4630))
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 4d7176b

Please sign in to comment.