Skip to content

Commit

Permalink
Add component wrapper to emergency banner component
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Oct 22, 2024
1 parent ce06c4e commit 587ef47
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 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 @@

* Add new chart component options ([PR #4318](https://github.com/alphagov/govuk_publishing_components/pull/4318))
* Add shared helper and component wrapper helper to govspeak component ([PR #4325](https://github.com/alphagov/govuk_publishing_components/pull/4325))
* Add component wrapper to emergency banner component ([PR #4283](https://github.com/alphagov/govuk_publishing_components/pull/4283))

## 44.4.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,33 @@
raise ArgumentError, "Emergency type #{campaign_class} is not in list of valid emergency types (#{emergency_banner_helper.emergency_types.join(', ')})"
end

banner_classes = %w[gem-c-emergency-banner]
banner_classes << "gem-c-emergency-banner--#{campaign_class}"
banner_classes << "gem-c-emergency-banner--homepage" if homepage

heading_classes = %w[gem-c-emergency-banner__heading]
heading_classes << "gem-c-emergency-banner__heading--homepage" if homepage

description_classes = %w[gem-c-emergency-banner__description]
description_classes << "gem-c-emergency-banner__description--homepage" if homepage

data_attributes = {
"nosnippet": true,
}
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-emergency-banner gem-c-emergency-banner--#{campaign_class}")
component_helper.add_class("gem-c-emergency-banner--homepage") if homepage
component_helper.add_data_attribute({nosnippet: true})
component_helper.add_aria_attribute({labelledby: "emergency-banner-heading"})

unless disable_ga4
data_attributes[:ga4_emergency_banner] = ""
data_attributes[:module] = "ga4-link-tracker"
data_attributes[:ga4_track_links_only] = ""
data_attributes[:ga4_set_indexes] = ""
data_attributes[:ga4_link] = {
event_name: "navigation",
type: "emergency banner",
section: heading,
}.to_json
component_helper.add_data_attribute({
ga4_emergency_banner: "",
module: "ga4-link-tracker",
ga4_track_links_only: "",
ga4_set_indexes: "",
ga4_link: {
event_name: "navigation",
type: "emergency banner",
section: heading,
}.to_json
})
end
%>
<%= content_tag('section', class: banner_classes, "aria-labelledby": "emergency-banner-heading", data: data_attributes) do %>
<%= tag.section(**component_helper.all_attributes) do %>
<div class="govuk-width-container">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ body: |
See the [opsmanual](https://docs.publishing.service.gov.uk/manual/emergency-publishing.html#adding-emergency-publishing-banners) for information about what the Emergency Banner is and when it should be deployed.
uses_component_wrapper_helper: true
shared_accessibility_criteria:
- link
accessibility_excluded_rules:
Expand Down

0 comments on commit 587ef47

Please sign in to comment.