govuk_publishing_components 37.9.0 → 37.9.1
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-specialist-link-tracker.js +16 -1
- data/app/views/govuk_publishing_components/components/_button.html.erb +1 -0
- data/app/views/govuk_publishing_components/components/_document_list.html.erb +10 -8
- data/app/views/govuk_publishing_components/components/docs/button.yml +8 -0
- data/app/views/govuk_publishing_components/components/docs/document_list.yml +1 -0
- data/lib/govuk_publishing_components/presenters/button_helper.rb +6 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5dd2b5e600cf344b23c52992b273a3af2ea102506584e06dfb001aa810e0491
|
4
|
+
data.tar.gz: 459ba0f50e42851c6ea04b0490aba7714cb221fb6b97e735cb48f4548f1e8237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dd79b5496db1fe55d085e18476983bcaf5abefa630e44544acfe795f40c68c3529556a8dcb02d8f0b25695bb4c0db223fb0e0038cfc6cdc1389db5fe48c86a2
|
7
|
+
data.tar.gz: e54878f904583f718889acc341ea00f8a7281f82783bb8141e358c29068c63c67f3c96dbd04820c5d09562cfe2aa31cb6b3008f3897ef7e113cefd792675ae62
|
data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js
CHANGED
@@ -72,7 +72,22 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
|
|
72
72
|
if (!href) {
|
73
73
|
return
|
74
74
|
}
|
75
|
+
|
75
76
|
var data = {}
|
77
|
+
var extraAttributes = element.getAttribute('data-ga4-attributes')
|
78
|
+
if (extraAttributes) {
|
79
|
+
try {
|
80
|
+
extraAttributes = JSON.parse(extraAttributes)
|
81
|
+
// make sure the data object remains an object - JSON.parse can return a string
|
82
|
+
for (var attrname in extraAttributes) {
|
83
|
+
data[attrname] = extraAttributes[attrname]
|
84
|
+
}
|
85
|
+
} catch (e) {
|
86
|
+
// fall back to the empty data object if something goes wrong
|
87
|
+
console.error('GA4 configuration error: ' + e.message, window.location)
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
76
91
|
var mailToLink = false
|
77
92
|
if (window.GOVUK.analyticsGa4.core.trackFunctions.isMailToLink(href)) {
|
78
93
|
data.event_name = 'navigation'
|
@@ -85,7 +100,7 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
|
|
85
100
|
data.external = window.GOVUK.analyticsGa4.core.trackFunctions.isExternalLink(href) ? 'true' : 'false'
|
86
101
|
} else if (window.GOVUK.analyticsGa4.core.trackFunctions.isExternalLink(href)) {
|
87
102
|
data.event_name = 'navigation'
|
88
|
-
data.type = 'generic link'
|
103
|
+
data.type = data.type || 'generic link'
|
89
104
|
data.external = 'true'
|
90
105
|
}
|
91
106
|
|
@@ -5,11 +5,13 @@
|
|
5
5
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
6
6
|
items ||= []
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
9
|
+
component_helper.add_class("gem-c-document-list")
|
10
|
+
component_helper.add_class("gem-c-document-list--no-underline") if local_assigns[:remove_underline]
|
11
|
+
component_helper.add_class("gem-c-document-list--no-top-border") if local_assigns[:remove_top_border]
|
12
|
+
component_helper.add_class("gem-c-document-list--no-top-border-first-child") if local_assigns[:remove_top_border_from_first_child]
|
13
|
+
component_helper.add_class(shared_helper.get_margin_bottom)
|
14
|
+
|
13
15
|
|
14
16
|
title_with_context_class = " gem-c-document-list__item-title--context"
|
15
17
|
|
@@ -19,18 +21,18 @@
|
|
19
21
|
disable_ga4 ||= false
|
20
22
|
unless disable_ga4
|
21
23
|
ga4_extra_data ||= {}
|
22
|
-
|
24
|
+
component_helper.add_data_attribute({
|
23
25
|
module: "ga4-link-tracker",
|
24
26
|
ga4_track_links_only: "",
|
25
27
|
ga4_link: {
|
26
28
|
"event_name": "navigation",
|
27
29
|
"type": "document list",
|
28
30
|
}.merge(ga4_extra_data)
|
29
|
-
}
|
31
|
+
})
|
30
32
|
end
|
31
33
|
%>
|
32
34
|
<% if items.any? %>
|
33
|
-
<%= tag.ul(
|
35
|
+
<%= tag.ul(**component_helper.all_attributes) do %>
|
34
36
|
<% items.each do |item| %>
|
35
37
|
<% highlight_class = " gem-c-document-list__item--highlight" if item[:highlight] %>
|
36
38
|
<li class="gem-c-document-list__item <%= brand_helper.brand_class %> <%= highlight_class %>">
|
@@ -44,6 +44,14 @@ examples:
|
|
44
44
|
href: '#'
|
45
45
|
start: true
|
46
46
|
rel: external
|
47
|
+
start_now_button_without_ga4_attributes:
|
48
|
+
description: By default the start now button version of this component includes a `data-ga4-attributes` attribute that is used by the specialist (external) link tracker to uniquely identify start now buttons. This attribute can be removed using the `disable_ga4` option.
|
49
|
+
data:
|
50
|
+
text: Start now
|
51
|
+
disable_ga4: true
|
52
|
+
href: '#'
|
53
|
+
start: true
|
54
|
+
rel: external
|
47
55
|
secondary_button:
|
48
56
|
data:
|
49
57
|
text: Secondary button
|
@@ -28,6 +28,7 @@ module GovukPublishingComponents
|
|
28
28
|
:aria_describedby
|
29
29
|
|
30
30
|
def initialize(local_assigns)
|
31
|
+
@disable_ga4 = local_assigns[:disable_ga4]
|
31
32
|
@href = local_assigns[:href]
|
32
33
|
@text = local_assigns[:text]
|
33
34
|
@title = local_assigns[:title]
|
@@ -45,6 +46,7 @@ module GovukPublishingComponents
|
|
45
46
|
@target = local_assigns[:target]
|
46
47
|
@type = local_assigns[:type]
|
47
48
|
@start = local_assigns[:start]
|
49
|
+
@data_attributes[:ga4_attributes] = ga4_attribute if start
|
48
50
|
@secondary = local_assigns[:secondary]
|
49
51
|
@secondary_quiet = local_assigns[:secondary_quiet]
|
50
52
|
@secondary_solid = local_assigns[:secondary_solid]
|
@@ -129,6 +131,10 @@ module GovukPublishingComponents
|
|
129
131
|
|
130
132
|
[*0..9].include?(margin) ? "govuk-!-margin-bottom-#{margin}" : legacy_class
|
131
133
|
end
|
134
|
+
|
135
|
+
def ga4_attribute
|
136
|
+
{ type: "start button" }.to_json unless @disable_ga4
|
137
|
+
end
|
132
138
|
end
|
133
139
|
end
|
134
140
|
end
|
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: 37.9.
|
4
|
+
version: 37.9.1
|
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: 2024-03-
|
11
|
+
date: 2024-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|