govuk_publishing_components 30.0.0 → 30.2.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/{gtm-click-tracking.js → ga4-event-tracker.js} +20 -7
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +153 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/{gtm-page-views.js → ga4-page-views.js} +23 -7
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/{gtm-schemas.js → ga4-schemas.js} +3 -2
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +6 -4
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_emergency-banner.scss +76 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_emergency-banner.scss +3 -0
- data/app/models/govuk_publishing_components/audit_applications.rb +1 -1
- data/app/views/govuk_publishing_components/component_guide/example.html.erb +5 -1
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_emergency_banner.html.erb +51 -0
- data/app/views/govuk_publishing_components/components/_print_link.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +24 -11
- data/app/views/govuk_publishing_components/components/docs/emergency_banner.yml +45 -0
- data/app/views/govuk_publishing_components/components/docs/print_link.yml +5 -0
- data/config/locales/hr.yml +0 -1
- data/lib/govuk_publishing_components/presenters/emergency_banner_helper.rb +17 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +1 -0
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f402d935fbe75f4dde432aab1dd5f525388d478b99a960c57cedc2b73034ea0d
|
4
|
+
data.tar.gz: e6cf9788314e58be8a0f13158e7262a31dec5ff4adece4ee2daf117ebb5252f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76b3d647997d9248dc930d224037a2d31d54aebee66879668743e7a962b85a199aff66cfc95dcb200577de4292f8dcd769ea105497df3ea71206746d798e112e
|
7
|
+
data.tar.gz: c29eaaf88f004b23c2412b3db5667533e2ed76e69b9a59679875e1dd68c2522ab15f935f6ed66ee0df3bbfd8c619aa604359afebf4e2369ff481959d4f7f535f
|
@@ -5,16 +5,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
5
5
|
(function (Modules) {
|
6
6
|
'use strict'
|
7
7
|
|
8
|
-
function
|
8
|
+
function Ga4EventTracker (module) {
|
9
9
|
this.module = module
|
10
10
|
this.trackingTrigger = 'data-ga4' // elements with this attribute get tracked
|
11
11
|
}
|
12
12
|
|
13
|
-
|
13
|
+
Ga4EventTracker.prototype.init = function () {
|
14
14
|
this.module.addEventListener('click', this.trackClick.bind(this), true) // useCapture must be true
|
15
15
|
}
|
16
16
|
|
17
|
-
|
17
|
+
Ga4EventTracker.prototype.trackClick = function (event) {
|
18
18
|
if (window.dataLayer) {
|
19
19
|
var target = this.findTrackingAttributes(event.target)
|
20
20
|
if (target) {
|
@@ -33,7 +33,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
33
33
|
// get attributes from the data attribute to send to GA
|
34
34
|
// only allow it if it already exists in the schema
|
35
35
|
for (var property in data) {
|
36
|
-
if (schema.event_data
|
36
|
+
if (property in schema.event_data) {
|
37
37
|
schema.event_data[property] = data[property]
|
38
38
|
}
|
39
39
|
}
|
@@ -58,12 +58,25 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
58
58
|
var openAttribute = detailsElement.getAttribute('open')
|
59
59
|
schema.event_data.action = (openAttribute == null) ? 'opened' : 'closed'
|
60
60
|
}
|
61
|
+
|
62
|
+
/* If a tab was clicked, grab the href of the clicked tab (usually an anchor # link) */
|
63
|
+
var tabElement = event.target.closest('.gem-c-tabs')
|
64
|
+
if (tabElement) {
|
65
|
+
var aTag = event.target.closest('a')
|
66
|
+
if (aTag) {
|
67
|
+
var href = aTag.getAttribute('href')
|
68
|
+
if (href) {
|
69
|
+
schema.event_data.url = href
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
61
74
|
window.dataLayer.push(schema)
|
62
75
|
}
|
63
76
|
}
|
64
77
|
}
|
65
78
|
|
66
|
-
|
79
|
+
Ga4EventTracker.prototype.findTrackingAttributes = function (clicked) {
|
67
80
|
if (clicked.hasAttribute('[' + this.trackingTrigger + ']')) {
|
68
81
|
return clicked
|
69
82
|
} else {
|
@@ -72,7 +85,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
72
85
|
}
|
73
86
|
|
74
87
|
// check if an attribute exists or contains the attribute
|
75
|
-
|
88
|
+
Ga4EventTracker.prototype.getClosestAttribute = function (clicked, attribute) {
|
76
89
|
var isAttributeOnElement = clicked.getAttribute(attribute)
|
77
90
|
var containsAttribute = clicked.querySelector('[' + attribute + ']')
|
78
91
|
|
@@ -83,5 +96,5 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
83
96
|
}
|
84
97
|
}
|
85
98
|
|
86
|
-
Modules.
|
99
|
+
Modules.Ga4EventTracker = Ga4EventTracker
|
87
100
|
})(window.GOVUK.Modules)
|
@@ -0,0 +1,153 @@
|
|
1
|
+
// = require govuk/vendor/polyfills/Element/prototype/closest.js
|
2
|
+
|
3
|
+
;(function (global) {
|
4
|
+
'use strict'
|
5
|
+
|
6
|
+
var GOVUK = global.GOVUK || {}
|
7
|
+
GOVUK.analyticsGA4 = GOVUK.analyticsGA4 || {}
|
8
|
+
|
9
|
+
GOVUK.analyticsGA4.linkTracker = {
|
10
|
+
trackLinkClicks: function () {
|
11
|
+
if (window.dataLayer) {
|
12
|
+
this.internalLinksDomain = 'www.gov.uk/'
|
13
|
+
this.internalLinksDomainWithoutWww = 'gov.uk/'
|
14
|
+
this.handleClick = this.handleClick.bind(this)
|
15
|
+
this.handleMousedown = this.handleMousedown.bind(this)
|
16
|
+
document.querySelector('body').addEventListener('click', this.handleClick)
|
17
|
+
document.querySelector('body').addEventListener('contextmenu', this.handleClick)
|
18
|
+
document.querySelector('body').addEventListener('mousedown', this.handleMousedown)
|
19
|
+
}
|
20
|
+
},
|
21
|
+
|
22
|
+
stopTracking: function () {
|
23
|
+
document.querySelector('body').removeEventListener('click', this.handleClick)
|
24
|
+
document.querySelector('body').removeEventListener('contextmenu', this.handleClick)
|
25
|
+
document.querySelector('body').removeEventListener('mousedown', this.handleMousedown)
|
26
|
+
},
|
27
|
+
|
28
|
+
handleClick: function (event) {
|
29
|
+
var element = event.target
|
30
|
+
|
31
|
+
if (element.tagName !== 'A') {
|
32
|
+
element = element.closest('a')
|
33
|
+
}
|
34
|
+
|
35
|
+
if (!element) {
|
36
|
+
return
|
37
|
+
}
|
38
|
+
|
39
|
+
var clickData = {}
|
40
|
+
var href = element.getAttribute('href')
|
41
|
+
|
42
|
+
if (!href) {
|
43
|
+
return
|
44
|
+
}
|
45
|
+
|
46
|
+
if (this.isMailToLink(href)) {
|
47
|
+
clickData.type = 'email'
|
48
|
+
clickData.external = 'true'
|
49
|
+
} else if (this.isDownloadLink(href)) {
|
50
|
+
clickData.type = 'download'
|
51
|
+
clickData.external = 'false'
|
52
|
+
} else if (this.isExternalLink(href)) {
|
53
|
+
clickData.type = 'generic link'
|
54
|
+
clickData.external = 'true'
|
55
|
+
}
|
56
|
+
|
57
|
+
if (Object.keys(clickData).length > 0) {
|
58
|
+
clickData.event_name = 'navigation'
|
59
|
+
clickData.text = element.textContent.trim()
|
60
|
+
clickData.url = href
|
61
|
+
clickData.link_method = this.getClickType(event)
|
62
|
+
|
63
|
+
var schema = new window.GOVUK.analyticsGA4.Schemas().eventSchema()
|
64
|
+
schema.event = 'analytics'
|
65
|
+
|
66
|
+
// get attributes from the clickData object to send to GA
|
67
|
+
// only allow it if it already exists in the schema
|
68
|
+
for (var property in clickData) {
|
69
|
+
if (property in schema.event_data) {
|
70
|
+
schema.event_data[property] = clickData[property]
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
window.dataLayer.push(schema)
|
75
|
+
}
|
76
|
+
},
|
77
|
+
|
78
|
+
getClickType: function (event) {
|
79
|
+
switch (event.type) {
|
80
|
+
case 'click':
|
81
|
+
if (event.ctrlKey) {
|
82
|
+
return 'ctrl click'
|
83
|
+
} else if (event.metaKey) {
|
84
|
+
return 'command/win click'
|
85
|
+
} else {
|
86
|
+
return 'primary click'
|
87
|
+
}
|
88
|
+
case 'mousedown':
|
89
|
+
return 'middle click'
|
90
|
+
case 'contextmenu':
|
91
|
+
return 'secondary click'
|
92
|
+
}
|
93
|
+
},
|
94
|
+
|
95
|
+
handleMousedown: function (event) {
|
96
|
+
// 1 = middle mouse button
|
97
|
+
if (event.button === 1) {
|
98
|
+
this.handleClick(event)
|
99
|
+
}
|
100
|
+
},
|
101
|
+
|
102
|
+
isMailToLink: function (href) {
|
103
|
+
return href.substring(0, 7) === 'mailto:'
|
104
|
+
},
|
105
|
+
|
106
|
+
isDownloadLink: function (href) {
|
107
|
+
var assetsDomain = 'assets.publishing.service.gov.uk/'
|
108
|
+
var uploadsPath = '/government/uploads/'
|
109
|
+
|
110
|
+
if (this.hrefPointsToDomain(href, assetsDomain)) {
|
111
|
+
return true
|
112
|
+
}
|
113
|
+
|
114
|
+
var isInternalLink = this.hrefPointsToDomain(href, this.internalLinksDomain) || this.hrefPointsToDomain(href, this.internalLinksDomainWithoutWww)
|
115
|
+
if (isInternalLink && href.indexOf(uploadsPath) !== -1) {
|
116
|
+
return true
|
117
|
+
}
|
118
|
+
|
119
|
+
// Checks relative links to the uploadsPath
|
120
|
+
if (this.stringStartsWith(href, uploadsPath)) {
|
121
|
+
return true
|
122
|
+
}
|
123
|
+
},
|
124
|
+
|
125
|
+
isExternalLink: function (href) {
|
126
|
+
var isInternalLink = this.hrefPointsToDomain(href, this.internalLinksDomain) || this.hrefPointsToDomain(href, this.internalLinksDomainWithoutWww)
|
127
|
+
if (!isInternalLink && !this.hrefIsRelative(href)) {
|
128
|
+
return true
|
129
|
+
}
|
130
|
+
},
|
131
|
+
|
132
|
+
hrefPointsToDomain: function (href, domain) {
|
133
|
+
var httpDomain = 'http://' + domain
|
134
|
+
var httpsDomain = 'https://' + domain
|
135
|
+
var schemaRelativeDomain = '//' + domain
|
136
|
+
return this.stringStartsWith(href, domain) ||
|
137
|
+
this.stringStartsWith(href, httpDomain) ||
|
138
|
+
this.stringStartsWith(href, httpsDomain) ||
|
139
|
+
this.stringStartsWith(href, schemaRelativeDomain)
|
140
|
+
},
|
141
|
+
|
142
|
+
stringStartsWith: function (string, stringToFind) {
|
143
|
+
return string.substring(0, stringToFind.length) === stringToFind
|
144
|
+
},
|
145
|
+
|
146
|
+
hrefIsRelative: function (href) {
|
147
|
+
// Checks that a link is relative, but is not a protocol relative url
|
148
|
+
return href[0] === '/' && href[1] !== '/'
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
global.GOVUK = GOVUK
|
153
|
+
})(window)
|
@@ -2,9 +2,11 @@
|
|
2
2
|
'use strict'
|
3
3
|
|
4
4
|
var GOVUK = global.GOVUK || {}
|
5
|
+
GOVUK.analyticsGA4 = GOVUK.analyticsGA4 || {}
|
5
6
|
|
6
|
-
GOVUK.
|
7
|
+
GOVUK.analyticsGA4.pageViewTracker = {
|
7
8
|
PIIRemover: new GOVUK.analyticsGA4.PIIRemover(), // imported in analytics-ga4.js
|
9
|
+
nullValue: null,
|
8
10
|
|
9
11
|
sendPageView: function () {
|
10
12
|
if (window.dataLayer) {
|
@@ -32,9 +34,9 @@
|
|
32
34
|
language: this.getLanguage(),
|
33
35
|
history: this.getHistory(),
|
34
36
|
withdrawn: this.getWithDrawn(),
|
35
|
-
first_published_at: this.getMetaContent('first-published-at'),
|
36
|
-
updated_at: this.getMetaContent('updated-at'),
|
37
|
-
public_updated_at: this.getMetaContent('public-updated-at'),
|
37
|
+
first_published_at: this.stripTimeFrom(this.getMetaContent('first-published-at')),
|
38
|
+
updated_at: this.stripTimeFrom(this.getMetaContent('updated-at')),
|
39
|
+
public_updated_at: this.stripTimeFrom(this.getMetaContent('public-updated-at')),
|
38
40
|
publishing_government: this.getMetaContent('publishing-government'),
|
39
41
|
political_status: this.getMetaContent('political-status'),
|
40
42
|
primary_publishing_organisation: this.getMetaContent('primary-publishing-organisation'),
|
@@ -73,13 +75,17 @@
|
|
73
75
|
if (tag) {
|
74
76
|
return tag.getAttribute('content')
|
75
77
|
} else {
|
76
|
-
return
|
78
|
+
return this.nullValue
|
77
79
|
}
|
78
80
|
},
|
79
81
|
|
80
82
|
getLanguage: function () {
|
81
|
-
var
|
82
|
-
|
83
|
+
var content = document.getElementById('content')
|
84
|
+
if (content) {
|
85
|
+
return content.getAttribute('lang') || this.nullValue
|
86
|
+
} else {
|
87
|
+
return this.nullValue
|
88
|
+
}
|
83
89
|
},
|
84
90
|
|
85
91
|
getHistory: function () {
|
@@ -90,6 +96,16 @@
|
|
90
96
|
getWithDrawn: function () {
|
91
97
|
var withdrawn = this.getMetaContent('withdrawn')
|
92
98
|
return (withdrawn === 'withdrawn') ? 'true' : 'false'
|
99
|
+
},
|
100
|
+
|
101
|
+
// return only the date from given timestamps of the form
|
102
|
+
// 2022-03-28T19:11:00.000+00:00
|
103
|
+
stripTimeFrom: function (value) {
|
104
|
+
if (value !== null) {
|
105
|
+
return value.split('T')[0]
|
106
|
+
} else {
|
107
|
+
return this.nullValue
|
108
|
+
}
|
93
109
|
}
|
94
110
|
}
|
95
111
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
var GOVUK = global.GOVUK || {}
|
5
5
|
|
6
6
|
var Schemas = function () {
|
7
|
-
this.null =
|
7
|
+
this.null = null
|
8
8
|
}
|
9
9
|
|
10
10
|
Schemas.prototype.eventSchema = function () {
|
@@ -20,7 +20,8 @@
|
|
20
20
|
index_total: this.null,
|
21
21
|
section: this.null,
|
22
22
|
action: this.null,
|
23
|
-
external: this.null
|
23
|
+
external: this.null,
|
24
|
+
link_method: this.null
|
24
25
|
}
|
25
26
|
}
|
26
27
|
}
|
@@ -1,7 +1,9 @@
|
|
1
1
|
// The following modules are imported in a specific order
|
2
|
-
//= require ./analytics-ga4/
|
2
|
+
//= require ./analytics-ga4/ga4-schemas
|
3
3
|
//= require ./analytics-ga4/pii-remover
|
4
|
-
//= require ./analytics-ga4/
|
5
|
-
//= require ./analytics-ga4/
|
4
|
+
//= require ./analytics-ga4/ga4-page-views
|
5
|
+
//= require ./analytics-ga4/ga4-link-tracker
|
6
|
+
//= require ./analytics-ga4/ga4-event-tracker
|
6
7
|
|
7
|
-
window.GOVUK.
|
8
|
+
window.GOVUK.analyticsGA4.pageViewTracker.sendPageView() // this will need integrating with cookie consent before production
|
9
|
+
window.GOVUK.analyticsGA4.linkTracker.trackLinkClicks()
|
@@ -31,6 +31,7 @@ $govuk-new-link-styles: true;
|
|
31
31
|
@import "components/details";
|
32
32
|
@import "components/devolved-nations";
|
33
33
|
@import "components/document-list";
|
34
|
+
@import "components/emergency-banner";
|
34
35
|
@import "components/error-alert";
|
35
36
|
@import "components/error-message";
|
36
37
|
@import "components/error-summary";
|
@@ -7,6 +7,7 @@
|
|
7
7
|
@import "components/print/button";
|
8
8
|
@import "components/print/cards";
|
9
9
|
@import "components/print/contents-list";
|
10
|
+
@import "components/print/emergency-banner";
|
10
11
|
@import "components/print/govspeak-html-publication";
|
11
12
|
@import "components/print/govspeak";
|
12
13
|
@import "components/print/layout-super-navigation-header";
|
@@ -0,0 +1,76 @@
|
|
1
|
+
.gem-c-emergency-banner {
|
2
|
+
@include govuk-font(19);
|
3
|
+
background-color: govuk-colour("mid-grey");
|
4
|
+
color: govuk-colour("white");
|
5
|
+
margin-top: 2px;
|
6
|
+
padding: govuk-spacing(3) 0;
|
7
|
+
|
8
|
+
@include govuk-media-query($from: tablet) {
|
9
|
+
padding: govuk-spacing(6) 0;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
.gem-c-emergency-banner--homepage {
|
14
|
+
border-bottom: govuk-spacing(1) solid govuk-colour("white");
|
15
|
+
border-top: govuk-spacing(1) solid govuk-colour("white");
|
16
|
+
margin-bottom: govuk-spacing(-2);
|
17
|
+
margin-top: 0;
|
18
|
+
position: relative;
|
19
|
+
z-index: 10;
|
20
|
+
}
|
21
|
+
|
22
|
+
.gem-c-emergency-banner__heading {
|
23
|
+
@include govuk-font(24, $weight: bold);
|
24
|
+
margin: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
.gem-c-emergency-banner__heading--homepage {
|
28
|
+
@include govuk-font(48, $weight: bold);
|
29
|
+
|
30
|
+
@include govuk-media-query($from: tablet) {
|
31
|
+
margin-bottom: govuk-spacing(4);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
.gem-c-emergency-banner__description {
|
36
|
+
@include govuk-font(19);
|
37
|
+
color: govuk-colour("white");
|
38
|
+
margin-top: 0;
|
39
|
+
margin-bottom: govuk-spacing(4);
|
40
|
+
|
41
|
+
&:last-child {
|
42
|
+
margin-bottom: 0;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
.gem-c-emergency-banner__description--homepage {
|
47
|
+
margin: govuk-spacing(4) 0;
|
48
|
+
}
|
49
|
+
|
50
|
+
.gem-c-emergency-banner__link {
|
51
|
+
@include govuk-font(19);
|
52
|
+
}
|
53
|
+
|
54
|
+
.gem-c-emergency-banner__link:link,
|
55
|
+
.gem-c-emergency-banner__link:visited {
|
56
|
+
color: govuk-colour("white");
|
57
|
+
}
|
58
|
+
|
59
|
+
.gem-c-emergency-banner__link:focus {
|
60
|
+
@include govuk-focused-text;
|
61
|
+
}
|
62
|
+
|
63
|
+
.gem-c-emergency-banner--notable-death {
|
64
|
+
background-color: govuk-colour("black");
|
65
|
+
}
|
66
|
+
|
67
|
+
.gem-c-emergency-banner--national-emergency {
|
68
|
+
// Not using govuk-colour("red") aka #d4351c as that's a slightly different red.
|
69
|
+
background-color: #b10e1e;
|
70
|
+
}
|
71
|
+
|
72
|
+
.gem-c-emergency-banner--local-emergency {
|
73
|
+
// Not using govuk-colour("turquoise") for background colour as
|
74
|
+
// the contrast was too low with white text
|
75
|
+
background-color: #00847d;
|
76
|
+
}
|
@@ -150,7 +150,7 @@ module GovukPublishingComponents
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def clean_file_path(file)
|
153
|
-
file[/(?<=#{Regexp.escape(@path.to_s)}\/)[\/a-zA-Z_-]+.[a-zA-Z
|
153
|
+
file[/(?<=#{Regexp.escape(@path.to_s)}\/)[\/a-zA-Z_-]+.[a-zA-Z+.]+/]
|
154
154
|
end
|
155
155
|
|
156
156
|
def clean_file_name(name)
|
@@ -7,6 +7,10 @@
|
|
7
7
|
|
8
8
|
<%= render 'govuk_publishing_components/components/title', title: @component_example.name, context: "#{@component_doc.name} example", margin_top: 0 %>
|
9
9
|
|
10
|
+
<% code_example = capture do %>
|
11
|
+
<%= render partial: "govuk_publishing_components/component_guide/component_doc/call", locals: { component_doc: @component_doc, example: @component_example } %>
|
12
|
+
<% end %>
|
13
|
+
|
10
14
|
<div class="component-show">
|
11
15
|
<div class="component-doc">
|
12
16
|
<div class="component-markdown">
|
@@ -19,6 +23,6 @@
|
|
19
23
|
<%= render partial: "govuk_publishing_components/component_guide/component_doc/preview", locals: { component_doc: @component_doc, example: @component_example } %>
|
20
24
|
|
21
25
|
<h2 class="component-doc-h2">How to call this example</h2>
|
22
|
-
<%=
|
26
|
+
<%= code_example %>
|
23
27
|
</div>
|
24
28
|
</div>
|
@@ -74,8 +74,11 @@
|
|
74
74
|
<div class="component-markdown">
|
75
75
|
<%= raw(example.html_description) %>
|
76
76
|
</div>
|
77
|
+
<% code_example = capture do %>
|
78
|
+
<%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc, example: example %>
|
79
|
+
<% end %>
|
77
80
|
<%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, example: example %>
|
78
|
-
<%=
|
81
|
+
<%= code_example %>
|
79
82
|
</div>
|
80
83
|
<% end %>
|
81
84
|
</div>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
locales = {}
|
23
23
|
|
24
24
|
data_attributes ||= {}
|
25
|
-
data_attributes[:module]
|
25
|
+
((data_attributes[:module] ||= "") << " " << "govuk-accordion gem-accordion").strip!
|
26
26
|
data_attributes[:anchor_navigation] = anchor_navigation
|
27
27
|
data_attributes[:track_show_all_clicks] = track_show_all_clicks
|
28
28
|
data_attributes[:track_sections] = track_sections
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<%
|
2
|
+
heading ||= ""
|
3
|
+
short_description ||= nil
|
4
|
+
link ||= nil
|
5
|
+
link_text ||= "More information"
|
6
|
+
campaign_class ||= nil
|
7
|
+
homepage ||= false
|
8
|
+
|
9
|
+
emergency_banner_helper = GovukPublishingComponents::Presenters::EmergencyBannerHelper.new()
|
10
|
+
|
11
|
+
if !campaign_class
|
12
|
+
raise ArgumentError, "Need to specify an emergency_type"
|
13
|
+
end
|
14
|
+
|
15
|
+
if !emergency_banner_helper.is_a_valid_emergency_type?(campaign_class)
|
16
|
+
raise ArgumentError, "Emergency type #{campaign_class} is not in list of valid emergency types (#{emergency_banner_helper.emergency_types.join(', ')})"
|
17
|
+
end
|
18
|
+
|
19
|
+
banner_classes = %w[gem-c-emergency-banner]
|
20
|
+
banner_classes << "gem-c-emergency-banner--#{campaign_class}"
|
21
|
+
banner_classes << "gem-c-emergency-banner--homepage" if homepage
|
22
|
+
|
23
|
+
heading_classes = %w[gem-c-emergency-banner__heading]
|
24
|
+
heading_classes << "gem-c-emergency-banner__heading--homepage" if homepage
|
25
|
+
|
26
|
+
description_classes = %w[gem-c-emergency-banner__description]
|
27
|
+
description_classes << "gem-c-emergency-banner__description--homepage" if homepage
|
28
|
+
|
29
|
+
%>
|
30
|
+
|
31
|
+
<%= content_tag('div', class: banner_classes, "aria-label": "emergency banner", "role": "region", "data-nosnippet": true ) do %>
|
32
|
+
<div class="govuk-width-container">
|
33
|
+
<div class="govuk-grid-row">
|
34
|
+
<div class="govuk-grid-column-two-thirds">
|
35
|
+
<%= content_tag('h2', class: heading_classes) do %>
|
36
|
+
<%= heading %>
|
37
|
+
<% end %>
|
38
|
+
<% if short_description %>
|
39
|
+
<%= content_tag('p', class: description_classes) do %>
|
40
|
+
<%= short_description %>
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
43
|
+
<% if link %>
|
44
|
+
<a href="<%= link %>" class="gem-c-emergency-banner__link">
|
45
|
+
<%= link_text %>
|
46
|
+
</a>
|
47
|
+
<% end %>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
<% end %>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
margin_top ||= 3
|
7
7
|
margin_bottom ||= 3
|
8
8
|
|
9
|
-
data_attributes[:module]
|
9
|
+
((data_attributes[:module] ||= "") << " " << (require_js ? "print-link" : "button")).strip!
|
10
10
|
|
11
11
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new({
|
12
12
|
margin_top: margin_top,
|
@@ -185,18 +185,17 @@ examples:
|
|
185
185
|
description: |
|
186
186
|
Adds custom data attributes to each section of the accordion. Accepts a hash, so multiple attributes can be added.
|
187
187
|
|
188
|
-
The `data_attributes`
|
188
|
+
The `data_attributes` option applies attributes to the outermost element in the accordion. Each item can also have a `data_attributes` hash, which are placed on the `button` that triggers the opening and closing - useful for differentiating between each section of the accordion.
|
189
189
|
|
190
|
-
|
190
|
+
Data attributes can be added to the 'Show/hide all' link using the `data_attributes_show_all` option, primarily where custom tracking is required. These attributes are read from the accordion markup and then added to the link by JavaScript (which is how the link is created). More details on how this can be used with the GA4 event tracking can be found in the 'Advanced' section of the [event tracking documentation](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-gtm/ga4-event-tracker.md).
|
191
191
|
|
192
|
-
|
192
|
+
If `track_options` within `data_attributes_show_all` is set, then it is possible to pass a custom dimension when 'Show/Hide all' is clicked.
|
193
193
|
data:
|
194
194
|
data_attributes:
|
195
|
-
|
196
|
-
ga: ga-accordion
|
195
|
+
custom_data_attr: custom-data-attr-accordion
|
197
196
|
data_attributes_show_all:
|
198
|
-
|
199
|
-
|
197
|
+
custom_data_attr-event-name: example
|
198
|
+
custom_data_attr-attributes: "{ 'ui': { 'type': 'type value', 'section': 'section value' } }"
|
200
199
|
tracking-options: "{ 'dimension114': 1 }"
|
201
200
|
items:
|
202
201
|
- heading:
|
@@ -204,25 +203,39 @@ examples:
|
|
204
203
|
content:
|
205
204
|
html: <p class="govuk-body">This is the content for Writing well for the web.</p>
|
206
205
|
data_attributes:
|
207
|
-
|
206
|
+
custom_data_attr: custom-data-attr-accordion-item-1
|
208
207
|
- heading:
|
209
208
|
text: Writing well for specialists
|
210
209
|
content:
|
211
210
|
html: <p class="govuk-body">This is the content for Writing well for specialists.</p>
|
212
211
|
data_attributes:
|
213
|
-
|
212
|
+
custom_data_attr: custom-data-attr-accordion-item-2
|
214
213
|
- heading:
|
215
214
|
text: Know your audience
|
216
215
|
content:
|
217
216
|
html: <p class="govuk-body">This is the content for Know your audience.</p>
|
218
217
|
data_attributes:
|
219
|
-
|
218
|
+
custom_data_attr: custom-data-attr-accordion-item-3
|
220
219
|
- heading:
|
221
220
|
text: How people read
|
222
221
|
content:
|
223
222
|
html: <p class="govuk-body">This is the content for How people read.</p>
|
224
223
|
data_attributes:
|
225
|
-
|
224
|
+
custom_data_attr: custom-data-attr-accordion-item-4
|
225
|
+
with_custom_data_module:
|
226
|
+
description: The component includes its own `data-module` but others can be passed in addition if required, for example to apply tracking to an element. This will be included along with the components own `data-module`.
|
227
|
+
data:
|
228
|
+
data_attributes:
|
229
|
+
module: gem-track-click
|
230
|
+
items:
|
231
|
+
- heading:
|
232
|
+
text: Writing well for the web
|
233
|
+
content:
|
234
|
+
html: <p class="govuk-body">This is the content for Writing well for the web.</p>
|
235
|
+
- heading:
|
236
|
+
text: Writing well for specialists
|
237
|
+
content:
|
238
|
+
html: <p class="govuk-body">This is the content for Writing well for specialists.</p>
|
226
239
|
different_heading_level:
|
227
240
|
description: This will alter the level of the heading, not the appearance of the heading.
|
228
241
|
data:
|
@@ -0,0 +1,45 @@
|
|
1
|
+
name: Emergency banner
|
2
|
+
description: A site-wide banner used in the event of an emergency
|
3
|
+
body: |
|
4
|
+
There are three types of events that would lead GOV.UK to add an emergency banner to the top of each page on the web site; a notable death, a national emergency or a local emergency.
|
5
|
+
|
6
|
+
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.
|
7
|
+
|
8
|
+
shared_accessibility_criteria:
|
9
|
+
- link
|
10
|
+
|
11
|
+
examples:
|
12
|
+
default:
|
13
|
+
description: |
|
14
|
+
Death of a notable person
|
15
|
+
data:
|
16
|
+
campaign_class: "notable-death"
|
17
|
+
heading: "His Royal Highness Henry VIII"
|
18
|
+
short_description: "1491 to 1547"
|
19
|
+
link_text: "Override Link Text"
|
20
|
+
link: "https://www.gov.uk/"
|
21
|
+
national_emergency:
|
22
|
+
description: |
|
23
|
+
National emergency (level 1 or category 2)
|
24
|
+
data:
|
25
|
+
campaign_class: "national-emergency"
|
26
|
+
heading: "National emergency"
|
27
|
+
short_description: "This is a level 1 incident"
|
28
|
+
link: "https://www.gov.uk/"
|
29
|
+
local_emergency:
|
30
|
+
description: |
|
31
|
+
Localised large-scale emergency (level 2 or category 1)
|
32
|
+
data:
|
33
|
+
campaign_class: "local-emergency"
|
34
|
+
heading: "Local emergency"
|
35
|
+
short_description: "This is a level 2 incident"
|
36
|
+
link: "https://www.gov.uk/"
|
37
|
+
notable_death_homepage:
|
38
|
+
description: |
|
39
|
+
When presenting any type of emergency banner on homepage the styling is slightly different.
|
40
|
+
data:
|
41
|
+
campaign_class: "notable-death"
|
42
|
+
heading: "His Royal Highness Henry VIII"
|
43
|
+
short_description: "1491 to 1547"
|
44
|
+
link: "https://www.gov.uk/"
|
45
|
+
homepage: true
|
@@ -26,6 +26,11 @@ examples:
|
|
26
26
|
track-category: "printButton"
|
27
27
|
track-action: "clicked"
|
28
28
|
track-label: "Print this page"
|
29
|
+
with_custom_data_module:
|
30
|
+
description: The component includes its own `data-module` but others can be passed in addition if required, for example to apply tracking to an element. This will be included along with the components own `data-module`.
|
31
|
+
data:
|
32
|
+
data_attributes:
|
33
|
+
module: "gem-track-click"
|
29
34
|
with_custom_margins:
|
30
35
|
description: 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 margin level `3` on top and bottom.
|
31
36
|
data:
|
data/config/locales/hr.yml
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
module Presenters
|
3
|
+
class EmergencyBannerHelper
|
4
|
+
EMERGENCY_TYPES = %w[notable-death national-emergency local-emergency].freeze
|
5
|
+
|
6
|
+
def initialize; end
|
7
|
+
|
8
|
+
def emergency_types
|
9
|
+
EMERGENCY_TYPES
|
10
|
+
end
|
11
|
+
|
12
|
+
def is_a_valid_emergency_type?(type)
|
13
|
+
EMERGENCY_TYPES.include?(type)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -12,6 +12,7 @@ require "govuk_publishing_components/presenters/breadcrumb_selector"
|
|
12
12
|
require "govuk_publishing_components/presenters/button_helper"
|
13
13
|
require "govuk_publishing_components/presenters/contextual_navigation"
|
14
14
|
require "govuk_publishing_components/presenters/devolved_nations_helper"
|
15
|
+
require "govuk_publishing_components/presenters/emergency_banner_helper"
|
15
16
|
require "govuk_publishing_components/presenters/related_navigation_helper"
|
16
17
|
require "govuk_publishing_components/presenters/step_by_step_nav_helper"
|
17
18
|
require "govuk_publishing_components/presenters/page_with_step_by_step_navigation"
|
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: 30.
|
4
|
+
version: 30.2.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: 2022-
|
11
|
+
date: 2022-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|
@@ -436,9 +436,10 @@ files:
|
|
436
436
|
- app/assets/javascripts/component_guide/vendor/matches-polyfill.min.js
|
437
437
|
- app/assets/javascripts/govuk_publishing_components/all_components.js
|
438
438
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4.js
|
439
|
-
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/
|
440
|
-
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/
|
441
|
-
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/
|
439
|
+
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js
|
440
|
+
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js
|
441
|
+
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js
|
442
|
+
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js
|
442
443
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/pii-remover.js
|
443
444
|
- app/assets/javascripts/govuk_publishing_components/analytics.js
|
444
445
|
- app/assets/javascripts/govuk_publishing_components/analytics/analytics.js
|
@@ -534,6 +535,7 @@ files:
|
|
534
535
|
- app/assets/stylesheets/govuk_publishing_components/components/_details.scss
|
535
536
|
- app/assets/stylesheets/govuk_publishing_components/components/_devolved-nations.scss
|
536
537
|
- app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss
|
538
|
+
- app/assets/stylesheets/govuk_publishing_components/components/_emergency-banner.scss
|
537
539
|
- app/assets/stylesheets/govuk_publishing_components/components/_error-alert.scss
|
538
540
|
- app/assets/stylesheets/govuk_publishing_components/components/_error-message.scss
|
539
541
|
- app/assets/stylesheets/govuk_publishing_components/components/_error-summary.scss
|
@@ -622,6 +624,7 @@ files:
|
|
622
624
|
- app/assets/stylesheets/govuk_publishing_components/components/print/_button.scss
|
623
625
|
- app/assets/stylesheets/govuk_publishing_components/components/print/_cards.scss
|
624
626
|
- app/assets/stylesheets/govuk_publishing_components/components/print/_contents-list.scss
|
627
|
+
- app/assets/stylesheets/govuk_publishing_components/components/print/_emergency-banner.scss
|
625
628
|
- app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak-html-publication.scss
|
626
629
|
- app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss
|
627
630
|
- app/assets/stylesheets/govuk_publishing_components/components/print/_layout-super-navigation-header.scss
|
@@ -678,6 +681,7 @@ files:
|
|
678
681
|
- app/views/govuk_publishing_components/components/_details.html.erb
|
679
682
|
- app/views/govuk_publishing_components/components/_devolved_nations.html.erb
|
680
683
|
- app/views/govuk_publishing_components/components/_document_list.html.erb
|
684
|
+
- app/views/govuk_publishing_components/components/_emergency_banner.html.erb
|
681
685
|
- app/views/govuk_publishing_components/components/_error_alert.html.erb
|
682
686
|
- app/views/govuk_publishing_components/components/_error_message.html.erb
|
683
687
|
- app/views/govuk_publishing_components/components/_error_summary.html.erb
|
@@ -760,6 +764,7 @@ files:
|
|
760
764
|
- app/views/govuk_publishing_components/components/docs/details.yml
|
761
765
|
- app/views/govuk_publishing_components/components/docs/devolved_nations.yml
|
762
766
|
- app/views/govuk_publishing_components/components/docs/document_list.yml
|
767
|
+
- app/views/govuk_publishing_components/components/docs/emergency_banner.yml
|
763
768
|
- app/views/govuk_publishing_components/components/docs/error_alert.yml
|
764
769
|
- app/views/govuk_publishing_components/components/docs/error_message.yml
|
765
770
|
- app/views/govuk_publishing_components/components/docs/error_summary.yml
|
@@ -922,6 +927,7 @@ files:
|
|
922
927
|
- lib/govuk_publishing_components/presenters/contextual_navigation.rb
|
923
928
|
- lib/govuk_publishing_components/presenters/curated_taxonomy_sidebar_links.rb
|
924
929
|
- lib/govuk_publishing_components/presenters/devolved_nations_helper.rb
|
930
|
+
- lib/govuk_publishing_components/presenters/emergency_banner_helper.rb
|
925
931
|
- lib/govuk_publishing_components/presenters/heading_helper.rb
|
926
932
|
- lib/govuk_publishing_components/presenters/image_card_helper.rb
|
927
933
|
- lib/govuk_publishing_components/presenters/intervention_helper.rb
|
@@ -1931,7 +1937,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1931
1937
|
- !ruby/object:Gem::Version
|
1932
1938
|
version: '0'
|
1933
1939
|
requirements: []
|
1934
|
-
rubygems_version: 3.3.
|
1940
|
+
rubygems_version: 3.3.20
|
1935
1941
|
signing_key:
|
1936
1942
|
specification_version: 4
|
1937
1943
|
summary: A gem to document components in GOV.UK frontend applications
|