govuk_publishing_components 35.14.0 → 35.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +15 -5
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +4 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +1 -1
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +30 -2
- data/app/views/govuk_publishing_components/components/_devolved_nations.html.erb +15 -1
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/docs/cards.yml +2 -2
- data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +5 -0
- data/app/views/govuk_publishing_components/components/docs/devolved_nations.yml +16 -0
- data/config/locales/en.yml +2 -2
- data/lib/govuk_publishing_components/presenters/devolved_nations_helper.rb +16 -4
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 999c5822c246101234a2c8d42828e3ee8b17df824b0472c12b55df5c2d81c4be
|
4
|
+
data.tar.gz: e6d08b1e863e2ded1152342176e3e7c506f3a89baf06a1c3b2b45c7c73c46ce0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fe723d3ea44de844e2228dbbbcfa815148df3b96b94edb58acba736815ab6f92142bf5f3853d0da0d2bca8f730f765414ea7d1c05db738d18c830bfadc88235
|
7
|
+
data.tar.gz: c06d8fbd16d112658797943def5f8b817f5c2c7e0424381cf16e8fb5c920d47a4ed8e88411be7509793da277f0f2d2f609765b6eb37d49550352b19be310d10b
|
@@ -17,7 +17,7 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
|
|
17
17
|
location: this.getLocation(),
|
18
18
|
/* If the init() function receives a referrer parameter, this indicates that it has been called as a part of an AJAX request and
|
19
19
|
this.getReferrer() will not return the correct value. Therefore we need to rely on the referrer parameter. */
|
20
|
-
referrer:
|
20
|
+
referrer: this.getReferrer(referrer),
|
21
21
|
title: this.getTitle(),
|
22
22
|
status_code: this.getStatusCode(),
|
23
23
|
|
@@ -55,7 +55,9 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
|
|
55
55
|
between fresh page loads and dynamic page updates. */
|
56
56
|
dynamic: referrer ? 'true' : 'false',
|
57
57
|
emergency_banner: document.querySelector('[data-ga4-emergency-banner]') ? 'true' : undefined,
|
58
|
-
phase_banner: this.getElementAttribute('data-ga4-phase-banner') || undefined
|
58
|
+
phase_banner: this.getElementAttribute('data-ga4-phase-banner') || undefined,
|
59
|
+
devolved_nations_banner: this.getElementAttribute('data-ga4-devolved-nations-banner') || undefined,
|
60
|
+
cookie_banner: document.querySelector('[data-ga4-cookie-banner]') ? 'true' : undefined
|
59
61
|
}
|
60
62
|
}
|
61
63
|
window.GOVUK.analyticsGa4.core.sendData(data)
|
@@ -63,11 +65,19 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
|
|
63
65
|
},
|
64
66
|
|
65
67
|
getLocation: function () {
|
66
|
-
return this.PIIRemover.stripPII(document.location.href)
|
68
|
+
return this.PIIRemover.stripPII(this.stripGaParam(document.location.href))
|
67
69
|
},
|
68
70
|
|
69
|
-
getReferrer: function () {
|
70
|
-
|
71
|
+
getReferrer: function (referrer) {
|
72
|
+
referrer = this.stripGaParam(referrer || document.referrer)
|
73
|
+
return this.PIIRemover.stripPIIWithOverride(referrer, true, true)
|
74
|
+
},
|
75
|
+
|
76
|
+
// remove GA parameters of the form _ga=2320.021-012302 or _gl=02.10320.01230-123
|
77
|
+
stripGaParam: function (str) {
|
78
|
+
str = str.replace(/(_ga=[0-9.-]+)/g, '_ga=[id]')
|
79
|
+
str = str.replace(/(_gl=[0-9.-]+)/g, '_gl=[id]')
|
80
|
+
return str
|
71
81
|
},
|
72
82
|
|
73
83
|
getTitle: function () {
|
@@ -4,7 +4,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
4
4
|
(function (Modules) {
|
5
5
|
function CookieBanner ($module) {
|
6
6
|
this.$module = $module
|
7
|
-
this.$module.cookieBanner = document.querySelector('.gem-c-cookie-banner')
|
8
7
|
this.$module.cookieBannerConfirmationMessage = this.$module.querySelector('.gem-c-cookie-banner__confirmation')
|
9
8
|
this.$module.cookieBannerConfirmationMessageText = this.$module.querySelector('.gem-c-cookie-banner__confirmation-message')
|
10
9
|
}
|
@@ -100,16 +99,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
100
99
|
}
|
101
100
|
|
102
101
|
CookieBanner.prototype.showConfirmationMessage = function () {
|
103
|
-
this.$cookieBannerHeader =
|
102
|
+
this.$cookieBannerHeader = this.$module.querySelector('.govuk-cookie-banner__heading')
|
104
103
|
this.$cookieBannerHeader.hidden = true
|
105
104
|
|
106
|
-
this.$cookieBannerMainContent =
|
105
|
+
this.$cookieBannerMainContent = this.$module.querySelector('.gem-c-cookie-banner__content')
|
107
106
|
this.$cookieBannerMainContent.hidden = true
|
108
107
|
|
109
|
-
this.$cookieBannerConfirmationButtons =
|
108
|
+
this.$cookieBannerConfirmationButtons = this.$module.querySelector('.js-confirmation-buttons')
|
110
109
|
this.$cookieBannerConfirmationButtons.hidden = true
|
111
110
|
|
112
|
-
this.$cookieBannerHideButton =
|
111
|
+
this.$cookieBannerHideButton = this.$module.querySelector('.js-hide-button')
|
113
112
|
this.$cookieBannerHideButton.hidden = false
|
114
113
|
}
|
115
114
|
|
@@ -693,7 +693,7 @@ $after-button-padding-left: govuk-spacing(4);
|
|
693
693
|
}
|
694
694
|
}
|
695
695
|
|
696
|
-
.gem-c-layout-super-navigation-header__navigation-second-items--
|
696
|
+
.gem-c-layout-super-navigation-header__navigation-second-items--services-and-information {
|
697
697
|
@include govuk-media-query($until: "desktop") {
|
698
698
|
border-bottom: 1px solid govuk-colour("mid-grey");
|
699
699
|
}
|
@@ -30,6 +30,8 @@
|
|
30
30
|
services_cookies ||= nil
|
31
31
|
css_classes = %w(gem-c-cookie-banner govuk-clearfix govuk-cookie-banner js-banner-wrapper)
|
32
32
|
css_classes << "gem-c-cookie-banner--services" if services_cookies
|
33
|
+
|
34
|
+
ga4_tracking ||= false
|
33
35
|
%>
|
34
36
|
|
35
37
|
<div id="<%= id %>" class="<%= css_classes.join(' ') %>" data-module="cookie-banner" data-nosnippet role="region" aria-label="<%= title %>">
|
@@ -39,7 +41,14 @@
|
|
39
41
|
<h2 class="govuk-cookie-banner__heading govuk-heading-m"><%= title %></h2>
|
40
42
|
<div tabindex="-1" class="govuk-cookie-banner__content gem-c-cookie-banner__confirmation">
|
41
43
|
<span class="gem-c-cookie-banner__content"><%= text %></span>
|
42
|
-
<p class="gem-c-cookie-banner__confirmation-message--accepted govuk-body" hidden
|
44
|
+
<p class="gem-c-cookie-banner__confirmation-message--accepted govuk-body" hidden
|
45
|
+
<% if ga4_tracking %>
|
46
|
+
data-ga4-cookie-banner <%# GA4 pageview JS looks for data-ga4-cookie-banner %>
|
47
|
+
data-module="ga4-link-tracker"
|
48
|
+
data-ga4-track-links-only
|
49
|
+
data-ga4-set-indexes
|
50
|
+
data-ga4-link="<%= { event_name: "navigation", type: "cookie banner", section: t("components.cookie_banner.confirmation_message.accepted", locale: :en) }.to_json %>"
|
51
|
+
<% end %>><%= t("components.cookie_banner.confirmation_message.accepted") %>. <span class="gem-c-cookie-banner__confirmation-message"><%= confirmation_message %></span></p>
|
43
52
|
<p class="gem-c-cookie-banner__confirmation-message--rejected govuk-body" hidden><%= t("components.cookie_banner.confirmation_message.rejected") %>. <span class="gem-c-cookie-banner__confirmation-message"><%= confirmation_message %></span></p>
|
44
53
|
</div>
|
45
54
|
</div>
|
@@ -85,7 +94,26 @@
|
|
85
94
|
<% end %>
|
86
95
|
</div>
|
87
96
|
<div hidden class="js-hide-button govuk-button-group">
|
88
|
-
|
97
|
+
<%
|
98
|
+
button_data_module = "gem-track-click"
|
99
|
+
button_data_module << " ga4-event-tracker" if ga4_tracking
|
100
|
+
|
101
|
+
ga4_event = {
|
102
|
+
event_name: "select_content",
|
103
|
+
type: "cookie banner",
|
104
|
+
action: "closed",
|
105
|
+
section: t("components.cookie_banner.confirmation_message.accepted", locale: :en)
|
106
|
+
}.to_json if ga4_tracking
|
107
|
+
%>
|
108
|
+
<button
|
109
|
+
class="gem-c-cookie-banner__hide-button govuk-button"
|
110
|
+
data-hide-cookie-banner="true"
|
111
|
+
data-module="<%= button_data_module %>"
|
112
|
+
data-track-category="cookieBanner"
|
113
|
+
data-track-action="Hide cookie banner"
|
114
|
+
<% if ga4_tracking %> data-ga4-event="<%= ga4_event %>" <% end %>>
|
115
|
+
<%= t("components.cookie_banner.hide") %>
|
116
|
+
</button>
|
89
117
|
</div>
|
90
118
|
</div>
|
91
119
|
</div>
|
@@ -6,10 +6,24 @@
|
|
6
6
|
|
7
7
|
applies_to ||= t("components.devolved_nations.applies_to")
|
8
8
|
heading_level ||= 2
|
9
|
+
ga4_tracking ||= false
|
10
|
+
data_attributes = {}
|
11
|
+
|
12
|
+
if ga4_tracking
|
13
|
+
data_attributes[:ga4_devolved_nations_banner] = devolved_nations_helper.ga4_applicable_nations_title_text(true)
|
14
|
+
data_attributes[:module] = "ga4-link-tracker"
|
15
|
+
data_attributes[:ga4_track_links_only] = ""
|
16
|
+
data_attributes[:ga4_set_indexes] = ""
|
17
|
+
data_attributes[:ga4_link] = {
|
18
|
+
event_name: "navigation",
|
19
|
+
type: "devolved nations banner",
|
20
|
+
section: t("components.devolved_nations.applies_to", locale: :en) + " " + devolved_nations_helper.ga4_applicable_nations_title_text,
|
21
|
+
}.to_json
|
22
|
+
end
|
9
23
|
%>
|
10
24
|
|
11
25
|
<% if national_applicability.any? { |k,v| v[:applicable] == true } %>
|
12
|
-
<%= tag.section class: "gem-c-devolved-nations" do %>
|
26
|
+
<%= tag.section class: "gem-c-devolved-nations", data: data_attributes do %>
|
13
27
|
<%= content_tag(shared_helper.get_heading_level, class: "govuk-heading-s govuk-!-margin-bottom-0") do %>
|
14
28
|
<%= applies_to %> <%= devolved_nations_helper.applicable_nations_title_text %>
|
15
29
|
<% end %>
|
data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb
CHANGED
@@ -217,11 +217,11 @@
|
|
217
217
|
end
|
218
218
|
%>
|
219
219
|
|
220
|
-
<div class="<%= width_class %> gem-c-layout-super-navigation-header__column--<%= column[:label].downcase.
|
220
|
+
<div class="<%= width_class %> gem-c-layout-super-navigation-header__column--<%= column[:label].downcase.gsub(" ", "-") %>">
|
221
221
|
<h3 class="govuk-heading-m gem-c-layout-super-navigation-header__column-header">
|
222
222
|
<%= column[:label] %>
|
223
223
|
</h3>
|
224
|
-
<ul class="gem-c-layout-super-navigation-header__navigation-second-items gem-c-layout-super-navigation-header__navigation-second-items--<%= column[:label].downcase.
|
224
|
+
<ul class="gem-c-layout-super-navigation-header__navigation-second-items gem-c-layout-super-navigation-header__navigation-second-items--<%= column[:label].downcase.gsub(" ", "-") %>">
|
225
225
|
<% index_total = column[:menu_contents].length %>
|
226
226
|
<% column[:menu_contents].each_with_index do | item, index | %>
|
227
227
|
<%
|
@@ -20,7 +20,7 @@ uses_component_wrapper_helper: true
|
|
20
20
|
examples:
|
21
21
|
default:
|
22
22
|
data:
|
23
|
-
heading:
|
23
|
+
heading: Services and information
|
24
24
|
items:
|
25
25
|
- link:
|
26
26
|
text: Benefits
|
@@ -109,7 +109,7 @@ examples:
|
|
109
109
|
|
110
110
|
Override default subheading level by passing through `sub_heading_level` parameter (defaults to `<h3>`)
|
111
111
|
data:
|
112
|
-
heading:
|
112
|
+
heading: Services and information
|
113
113
|
heading_level: 3
|
114
114
|
sub_heading_level: 4
|
115
115
|
items:
|
@@ -49,3 +49,8 @@ examples:
|
|
49
49
|
cookie_preferences:
|
50
50
|
text: How we use cookies
|
51
51
|
href: "/cookies"
|
52
|
+
with_ga4_tracking:
|
53
|
+
description: |
|
54
|
+
Enables GA4 tracking on the banner. This includes link tracking on the "You have accepted cookies" section, and allows the pageview event that is sent when GA4 initialises to record the presence of the cookie acceptance message.
|
55
|
+
data:
|
56
|
+
ga4_tracking: true
|
@@ -89,3 +89,19 @@ examples:
|
|
89
89
|
national_applicability:
|
90
90
|
england:
|
91
91
|
applicable: true
|
92
|
+
with_ga4_tracking:
|
93
|
+
description: |
|
94
|
+
Enables GA4 tracking on the banner. This includes link tracking on the component itself, and allows pageviews to record the presence of the banner on page load.
|
95
|
+
data:
|
96
|
+
national_applicability:
|
97
|
+
england:
|
98
|
+
applicable: true
|
99
|
+
scotland:
|
100
|
+
applicable: true
|
101
|
+
wales:
|
102
|
+
applicable: true
|
103
|
+
northern_ireland:
|
104
|
+
applicable: false
|
105
|
+
alternative_url: /
|
106
|
+
type: detailed_guide
|
107
|
+
ga4_tracking: true
|
data/config/locales/en.yml
CHANGED
@@ -91,7 +91,7 @@ en:
|
|
91
91
|
copyright_html: <a class="govuk-footer__link govuk-footer__copyright-logo" href="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/">© Crown copyright</a>
|
92
92
|
licence_html: All content is available under the <a class="govuk-footer__link" href="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" rel="license">Open Government Licence v3.0</a>, except where otherwise stated
|
93
93
|
navigation_links:
|
94
|
-
- title:
|
94
|
+
- title: Services and information
|
95
95
|
menu_contents:
|
96
96
|
- text: Benefits
|
97
97
|
href: "/browse/benefits"
|
@@ -171,7 +171,7 @@ en:
|
|
171
171
|
href: "/browse"
|
172
172
|
label: Menu
|
173
173
|
navigation_links_columns:
|
174
|
-
- label:
|
174
|
+
- label: Services and information
|
175
175
|
size: 2
|
176
176
|
menu_contents:
|
177
177
|
- label: Benefits
|
@@ -8,17 +8,29 @@ module GovukPublishingComponents
|
|
8
8
|
@type = local_assigns[:type] || "publication"
|
9
9
|
end
|
10
10
|
|
11
|
-
def applicable_nations_title_text
|
11
|
+
def applicable_nations_title_text(use_english_translation = nil)
|
12
12
|
@national_applicability
|
13
13
|
.select { |_, v| v[:applicable] == true }
|
14
|
-
.map { |k, _|
|
14
|
+
.map { |k, _| get_translation("components.devolved_nations.#{k}", use_english_translation) }
|
15
15
|
.sort
|
16
16
|
.to_sentence(
|
17
|
-
two_words_connector:
|
18
|
-
last_word_connector:
|
17
|
+
two_words_connector: get_translation("components.devolved_nations.connectors.two_words", use_english_translation),
|
18
|
+
last_word_connector: get_translation("components.devolved_nations.connectors.last_word", use_english_translation),
|
19
19
|
)
|
20
20
|
end
|
21
21
|
|
22
|
+
def get_translation(key, use_english_translation = nil)
|
23
|
+
return I18n.t(key, locale: :en) if use_english_translation
|
24
|
+
|
25
|
+
I18n.t(key)
|
26
|
+
end
|
27
|
+
|
28
|
+
def ga4_applicable_nations_title_text(remove_connector_word = nil)
|
29
|
+
return applicable_nations_title_text(true).gsub(" and", ",") if remove_connector_word
|
30
|
+
|
31
|
+
applicable_nations_title_text(true)
|
32
|
+
end
|
33
|
+
|
22
34
|
def nations_with_urls
|
23
35
|
@national_applicability
|
24
36
|
.select do |_, v|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_publishing_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 35.
|
4
|
+
version: 35.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|
@@ -1468,7 +1468,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1468
1468
|
- !ruby/object:Gem::Version
|
1469
1469
|
version: '0'
|
1470
1470
|
requirements: []
|
1471
|
-
rubygems_version: 3.4.
|
1471
|
+
rubygems_version: 3.4.19
|
1472
1472
|
signing_key:
|
1473
1473
|
specification_version: 4
|
1474
1474
|
summary: A gem to document components in GOV.UK frontend applications
|