Skip to content

Commit

Permalink
Merge pull request #4466 from alphagov/related-navigation-component-w…
Browse files Browse the repository at this point in the history
…rapper

Use component wrapper on related nav component
  • Loading branch information
AshGDS authored Dec 3, 2024
2 parents bf587d3 + 01f36b1 commit 5956854
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

* Support Welsh devolved nations component ([PR #4440](https://github.com/alphagov/govuk_publishing_components/pull/4440))
* Use component wrapper on previous and next component ([PR #4463](https://github.com/alphagov/govuk_publishing_components/pull/4463))
* Use component wrapper on related nav component ([PR #4466](https://github.com/alphagov/govuk_publishing_components/pull/4466))

## 46.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
disable_ga4 ||= false
ga4_type = local_assigns[:context] == :footer ? "contextual footer" : "related content"
data = {}
data[:module] = "ga4-link-tracker" unless disable_ga4
ga4_tracking_counts ||= OpenStruct.new(index_section_count: 0)
ga4_tracking_counts.index_section_count += related_nav_helper.index_section_count

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-related-navigation govuk-!-display-none-print")
component_helper.add_data_attribute({ module: "ga4-link-tracker" }) unless disable_ga4

add_gem_component_stylesheet("related-navigation")
%>
<% if related_nav_helper.related_navigation? %>
<% random = SecureRandom.hex(4) %>
<%= tag.div(class: "gem-c-related-navigation govuk-!-display-none-print", data: data) do %>
<%= tag.div(**component_helper.all_attributes) do %>
<% if local_assigns[:context] != :footer %>
<h2 id="related-nav-related_items-<%= random %>"
class="gem-c-related-navigation__main-heading"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ description: Component showing related content, including topics, guidance and c
accessibility_criteria: |
- Should have a role of 'navigation' on any navigation elements inside the component
- Should be marked up as navigation and not as tangential content
uses_component_wrapper_helper: true
shared_accessibility_criteria:
- link
accessibility_excluded_rules:
Expand Down

0 comments on commit 5956854

Please sign in to comment.