govuk_publishing_components 35.8.0 → 35.9.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-link-tracker.js +1 -1
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +4 -3
- data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +21 -9
- data/app/views/govuk_publishing_components/components/docs/notice.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +13 -0
- data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +9 -1
- 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: 619cac6fc6ecb8078d66be77a50e1fe4d5f320b61a15e574fbd92a892d896d80
|
4
|
+
data.tar.gz: d339abcad29fe3e59dafe2157e3ba605c8817563797b30bead89650ebe5d278f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a163d27c8f13d7019869a16ac1f0c58c4c71e88be7c456e1639cb717bdf3f0da4c483ae7336824ed288d2888e5f0e671e1b1120fe910fa75d838aa85da998f98
|
7
|
+
data.tar.gz: 87d03d1a7c4f50d4065b501c8f415831f218f28e2dd28ebfe61d87d270162ae595899ba46387d5bed9cc3b9472fbc7d47255fd573354bcfcc8477262aa574427
|
@@ -82,7 +82,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
82
82
|
var text = data.text || event.target.textContent
|
83
83
|
data.text = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(text)
|
84
84
|
data.text = this.PIIRemover.stripPIIWithOverride(data.text, true, true)
|
85
|
-
if (!data.text && (element.querySelector('img') || element.querySelector('svg'))) {
|
85
|
+
if (!data.text && (element.querySelector('img') || element.querySelector('svg') || element.tagName === 'IMG' || element.closest('svg'))) {
|
86
86
|
data.text = 'image'
|
87
87
|
}
|
88
88
|
var url = data.url || this.findLink(event.target).getAttribute('href')
|
@@ -40,11 +40,12 @@
|
|
40
40
|
ga4_link_data_attributes ||= nil
|
41
41
|
|
42
42
|
if ga4_tracking
|
43
|
+
heading_text = Nokogiri::HTML(item[:heading][:text]).text
|
43
44
|
item[:data_attributes] ||= {}
|
44
45
|
item[:data_attributes][:ga4_event] = {
|
45
46
|
event_name: "select_content",
|
46
47
|
type: "accordion",
|
47
|
-
text:
|
48
|
+
text: heading_text,
|
48
49
|
index: {
|
49
50
|
index_section: index,
|
50
51
|
index_section_count: items.length,
|
@@ -56,12 +57,12 @@
|
|
56
57
|
# tracking attributes
|
57
58
|
ga4_link_data_attributes = {}
|
58
59
|
ga4_link_data_attributes[:module] = "ga4-link-tracker"
|
59
|
-
ga4_link_data_attributes[:
|
60
|
+
ga4_link_data_attributes[:ga4_track_links_only] = ""
|
60
61
|
ga4_link_data_attributes[:ga4_set_indexes] = ""
|
61
62
|
ga4_link_data_attributes[:ga4_link] = {
|
62
63
|
event_name: "navigation",
|
63
64
|
type: "accordion",
|
64
|
-
section:
|
65
|
+
section: heading_text,
|
65
66
|
index: {
|
66
67
|
index_section: index,
|
67
68
|
index_section_count: (items.length),
|
data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb
CHANGED
@@ -1,25 +1,37 @@
|
|
1
1
|
<%
|
2
2
|
add_gem_component_stylesheet("single-page-notification-button")
|
3
3
|
|
4
|
-
|
4
|
+
spnb_helper = GovukPublishingComponents::Presenters::SinglePageNotificationButtonHelper.new(local_assigns)
|
5
5
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
6
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
6
7
|
|
7
8
|
wrapper_classes = %w(govuk-!-display-none-print)
|
8
9
|
wrapper_classes << shared_helper.get_margin_bottom
|
10
|
+
|
11
|
+
ga4_data_attributes = ga4_data_attributes ||= nil
|
12
|
+
ga4_link_data_attributes = ga4_data_attributes[:ga4_link] if ga4_data_attributes
|
13
|
+
ga4_link_data_attributes[:url] = spnb_helper.form_action if ga4_link_data_attributes
|
14
|
+
|
15
|
+
component_helper.add_class(wrapper_classes.join(" "))
|
16
|
+
component_helper.add_data_attribute({ module: "gem-track-click" })
|
17
|
+
component_helper.add_data_attribute({ module: ga4_data_attributes[:module] }) if ga4_data_attributes
|
9
18
|
%>
|
10
19
|
<% button_text = capture do %>
|
11
|
-
<svg class="gem-c-single-page-notification-button__icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 0 459.334 459.334"><path fill="currentColor" d="M177.216 404.514c-.001.12-.009.239-.009.359 0 30.078 24.383 54.461 54.461 54.461s54.461-24.383 54.461-54.461c0-.12-.008-.239-.009-.359H175.216zM403.549 336.438l-49.015-72.002v-89.83c0-60.581-43.144-111.079-100.381-122.459V24.485C254.152 10.963 243.19 0 229.667 0s-24.485 10.963-24.485 24.485v27.663c-57.237 11.381-100.381 61.879-100.381 122.459v89.83l-49.015 72.002a24.76 24.76 0 0 0 20.468 38.693H383.08a24.761 24.761 0 0 0 20.469-38.694z"/></svg><span class="gem-c-single-page-notication-button__text"><%=
|
20
|
+
<svg class="gem-c-single-page-notification-button__icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 0 459.334 459.334"><path fill="currentColor" d="M177.216 404.514c-.001.12-.009.239-.009.359 0 30.078 24.383 54.461 54.461 54.461s54.461-24.383 54.461-54.461c0-.12-.008-.239-.009-.359H175.216zM403.549 336.438l-49.015-72.002v-89.83c0-60.581-43.144-111.079-100.381-122.459V24.485C254.152 10.963 243.19 0 229.667 0s-24.485 10.963-24.485 24.485v27.663c-57.237 11.381-100.381 61.879-100.381 122.459v89.83l-49.015 72.002a24.76 24.76 0 0 0 20.468 38.693H383.08a24.761 24.761 0 0 0 20.469-38.694z"/></svg><span class="gem-c-single-page-notication-button__text"><%= spnb_helper.button_text %></span>
|
12
21
|
<% end %>
|
13
|
-
<%= tag.div
|
14
|
-
<%= tag.form class:
|
15
|
-
<input type="hidden" name="base_path" value="<%=
|
16
|
-
<% if
|
17
|
-
<input type="hidden" name="<%=
|
18
|
-
<input type="hidden" name="link" value="<%=
|
22
|
+
<%= tag.div(**component_helper.all_attributes) do %>
|
23
|
+
<%= tag.form class: spnb_helper.classes, action: spnb_helper.form_action, method: "POST", data: spnb_helper.data do %>
|
24
|
+
<input type="hidden" name="base_path" value="<%= spnb_helper.base_path %>">
|
25
|
+
<% if spnb_helper.skip_the_gov_uk_account? %>
|
26
|
+
<input type="hidden" name="<%= spnb_helper.skip_account_param %>" value="true">
|
27
|
+
<input type="hidden" name="link" value="<%= spnb_helper.base_path %>">
|
19
28
|
<% end %>
|
20
29
|
<%= content_tag(:button, button_text, {
|
21
30
|
class: "govuk-body-s gem-c-single-page-notification-button__submit",
|
22
31
|
type: "submit",
|
32
|
+
data: {
|
33
|
+
ga4_link: ga4_link_data_attributes
|
34
|
+
}
|
23
35
|
}) %>
|
24
36
|
<% end %>
|
25
|
-
<% end if
|
37
|
+
<% end if spnb_helper.base_path %>
|
@@ -35,7 +35,7 @@ examples:
|
|
35
35
|
title: 'Advisory Committee on Novel Foods and Processes has a <a href="http://www.food.gov.uk/acnfp">separate website</a>'
|
36
36
|
without_title:
|
37
37
|
data:
|
38
|
-
description_govspeak: '<p>Scheduled to publish at 8am on 25 April 2019
|
38
|
+
description_govspeak: '<p>Scheduled to publish at 8am on 25 April 2019</p><ul><li><a href="change-date">Change date</a></li><li><a href="stop-scheduled-publishing">Stop scheduled publishing</a></li></ul>'
|
39
39
|
with_aria_live:
|
40
40
|
description: Passing the aria live flag to the notice component will read the notice out to users if the notice changes, e.g on form submission the notice may go from hidden to visible.
|
41
41
|
data:
|
data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml
CHANGED
@@ -25,6 +25,19 @@ examples:
|
|
25
25
|
base_path: '/current-page-path'
|
26
26
|
data_attributes:
|
27
27
|
test_attribute: "testing"
|
28
|
+
with_ga4_tracking:
|
29
|
+
description: To add GA4 tracking, pass a `ga4_data_attributes` object with the necessary properties to the component. For example:-
|
30
|
+
data:
|
31
|
+
base_path: '/current-page-path'
|
32
|
+
ga4_data_attributes:
|
33
|
+
module: "ga4-link-tracker"
|
34
|
+
ga4_link:
|
35
|
+
event_name: "navigation"
|
36
|
+
type: "subscribe"
|
37
|
+
index:
|
38
|
+
index_link: 1
|
39
|
+
index_total: 1
|
40
|
+
section: "Top"
|
28
41
|
with_margin_bottom:
|
29
42
|
description: |
|
30
43
|
The component accepts a number for margin bottom from `0` to `9` (`0px` to `60px`) using the [GOV.UK Frontend spacing scale](https://design-system.service.gov.uk/styles/spacing/#the-responsive-spacing-scale). It defaults to having a margin bottom of 15px.
|
@@ -61,7 +61,11 @@ module GovukPublishingComponents
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def form_action
|
64
|
-
|
64
|
+
if skip_the_gov_uk_account?
|
65
|
+
email_alert_frontend_endpoint_no_account
|
66
|
+
else
|
67
|
+
email_alert_frontend_endpoint_enforce_account
|
68
|
+
end
|
65
69
|
end
|
66
70
|
|
67
71
|
def email_alert_frontend_endpoint_enforce_account
|
@@ -75,6 +79,10 @@ module GovukPublishingComponents
|
|
75
79
|
def skip_account_param
|
76
80
|
"single_page_subscription"
|
77
81
|
end
|
82
|
+
|
83
|
+
def skip_the_gov_uk_account?
|
84
|
+
@skip_account == "true"
|
85
|
+
end
|
78
86
|
end
|
79
87
|
end
|
80
88
|
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: 35.
|
4
|
+
version: 35.9.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-
|
11
|
+
date: 2023-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|
@@ -1455,7 +1455,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1455
1455
|
- !ruby/object:Gem::Version
|
1456
1456
|
version: '0'
|
1457
1457
|
requirements: []
|
1458
|
-
rubygems_version: 3.4.
|
1458
|
+
rubygems_version: 3.4.15
|
1459
1459
|
signing_key:
|
1460
1460
|
specification_version: 4
|
1461
1461
|
summary: A gem to document components in GOV.UK frontend applications
|