Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use component wrapper on step nav header component #4521

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Add option for organisation logos to hide the link underline until it's hovered ([PR #4509](https://github.com/alphagov/govuk_publishing_components/pull/4509))
* Remove chat entry component ([PR #4512](https://github.com/alphagov/govuk_publishing_components/pull/4512))
* Use component wrapper on skip link component ([PR #4520](https://github.com/alphagov/govuk_publishing_components/pull/4520))
* Use component wrapper on step nav header component ([PR #4521](https://github.com/alphagov/govuk_publishing_components/pull/4521))

## 46.4.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@
]
breadcrumb_presenter = GovukPublishingComponents::Presenters::Breadcrumbs.new(breadcrumbs)

data = {}
data[:module] = "ga4-link-tracker" unless disable_ga4
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-step-nav-header")

unless disable_ga4
component_helper.add_data_attribute({ module: "ga4-link-tracker" })
ga4_data = {
event_name: "navigation",
type: "super breadcrumb",
index_link: "1",
index_total: "1",
}.to_json
end

shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine but I was a bit confused by it being in two separate commits. Maybe worth either merging them or adding something to the commit message to clarify that the shared helper is no longer needed as the margin bottom is now provided by the component wrapper helper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - will do, thanks!

classes = %w[gem-c-step-nav-header]
classes << shared_helper.get_margin_bottom if local_assigns[:margin_bottom]
%>
<% if title %>
<script type="application/ld+json">
<%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
</script>

<%= tag.div(class: classes, data: data) do %>
<%= tag.div(**component_helper.all_attributes) do %>
<strong class="gem-c-step-nav-header__part-of">Part of</strong>
<% if path %>
<a href="<%= path %>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ accessibility_criteria: |
Always place the step by step navigation header at the top of a page, before the `<main>` element. Placing the component here means that the "Skip to main content" link allows the user to skip all navigation links, including the step by step navigation header.
shared_accessibility_criteria:
- link
uses_component_wrapper_helper: true
examples:
default:
data:
Expand Down
Loading