govuk_publishing_components 27.14.0 → 27.16.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/auto-scroll-tracker.js +24 -3
- data/app/assets/javascripts/govuk_publishing_components/analytics/custom-dimensions.js +52 -26
- data/app/assets/javascripts/govuk_publishing_components/analytics/ecommerce.js +25 -25
- data/app/assets/javascripts/govuk_publishing_components/analytics/explicit-cross-domain-links.js +24 -8
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +1 -0
- data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +3 -3
- data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +15 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +10 -8
- data/app/views/govuk_publishing_components/components/_big_number.html.erb +0 -1
- data/app/views/govuk_publishing_components/components/_button.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_intervention.html.erb +21 -4
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_search.html.erb +25 -9
- data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +9 -7
- data/app/views/govuk_publishing_components/components/_success_alert.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/docs/intervention.yml +11 -0
- data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/radio.yml +40 -33
- data/app/views/govuk_publishing_components/components/docs/search.yml +25 -0
- data/app/views/govuk_publishing_components/components/docs/success_alert.yml +6 -0
- data/config/locales/en.yml +3 -1
- data/lib/govuk_publishing_components/presenters/button_helper.rb +24 -0
- data/lib/govuk_publishing_components/presenters/intervention_helper.rb +20 -2
- data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +4 -7
- 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: 586ea5662dfd4f3951905b244afc78556dc687bf861a05e11e56ff7d2ee172eb
|
4
|
+
data.tar.gz: eab6ea6544883bc5fa511f29e589d996eabae18a6661f0772ac45356668f5396
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f513e048959e7e81b753583f923772b590f5c4da1841e666f4131bc79e8dea9b8cd4571cba7bab859e0d1b4683a1b10ebaa17d56cd6d3ab3a4eff68090837a1c
|
7
|
+
data.tar.gz: 5f2d6aa1171a47b3074ba65b0dc5488b9269dc4f7781580df52d7d1c354559d19270bace849b39342c51e3e4ad9342a966354da39dabb6f52838de4c505f0f03
|
@@ -31,9 +31,21 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
31
31
|
return
|
32
32
|
}
|
33
33
|
|
34
|
+
this.trackType = this.$module.getAttribute('data-track-type')
|
35
|
+
var trackHeadings = this.$module.getAttribute('data-track-headings')
|
36
|
+
if (trackHeadings) {
|
37
|
+
try {
|
38
|
+
this.config.trackHeadings = JSON.parse(trackHeadings)
|
39
|
+
} catch (e) {
|
40
|
+
// if there's a problem with the config, don't start the tracker
|
41
|
+
console.error('Scroll tracker configuration error: ' + e.message, window.location)
|
42
|
+
window.GOVUK.analyticsVars.scrollTrackerStarted = false
|
43
|
+
return
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
34
47
|
window.GOVUK.analyticsVars.scrollTrackerStarted = true
|
35
48
|
|
36
|
-
this.trackType = this.$module.getAttribute('data-track-type')
|
37
49
|
if (this.trackType === 'headings') {
|
38
50
|
this.track = new AutoScrollTracker.Heading(this.config)
|
39
51
|
} else {
|
@@ -145,15 +157,24 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
145
157
|
|
146
158
|
// check heading is inside allowed elements, generally ignores everything outside of page content
|
147
159
|
AutoScrollTracker.Heading.prototype.findAllowedHeadings = function () {
|
148
|
-
var headings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
|
149
160
|
var headingsFound = []
|
161
|
+
var headings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
|
162
|
+
var trackHeadings = this.config.trackHeadings
|
150
163
|
|
164
|
+
// this is a loop that only happens once as we currently only have one
|
165
|
+
// allowed element for headings to be in - 'main'
|
151
166
|
for (var h = 0; h < this.config.allowHeadingsInside.length; h++) {
|
152
167
|
var insideElements = document.querySelectorAll(this.config.allowHeadingsInside[h])
|
153
168
|
for (var e = 0; e < insideElements.length; e++) {
|
154
169
|
var found = insideElements[e].querySelectorAll(headings)
|
155
170
|
for (var f = 0; f < found.length; f++) {
|
156
|
-
|
171
|
+
if (trackHeadings) {
|
172
|
+
if (trackHeadings.includes(found[f].textContent.trim())) {
|
173
|
+
headingsFound.push(found[f])
|
174
|
+
}
|
175
|
+
} else {
|
176
|
+
headingsFound.push(found[f])
|
177
|
+
}
|
157
178
|
}
|
158
179
|
}
|
159
180
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* global GOVUK
|
1
|
+
/* global GOVUK */
|
2
2
|
|
3
3
|
(function () {
|
4
4
|
'use strict'
|
@@ -7,11 +7,11 @@
|
|
7
7
|
|
8
8
|
CustomDimensions.getAndExtendDefaultTrackingOptions = function (extraOptions) {
|
9
9
|
var trackingOptions = this.customDimensions()
|
10
|
-
return
|
10
|
+
return this.extend(trackingOptions, extraOptions)
|
11
11
|
}
|
12
12
|
|
13
13
|
CustomDimensions.customDimensions = function () {
|
14
|
-
var dimensions =
|
14
|
+
var dimensions = this.extend(
|
15
15
|
{},
|
16
16
|
customDimensionsFromBrowser(),
|
17
17
|
customDimensionsFromMetaTags(),
|
@@ -19,9 +19,28 @@
|
|
19
19
|
abTestCustomDimensions()
|
20
20
|
)
|
21
21
|
|
22
|
-
|
23
|
-
dimensions[key] = new GOVUK.Analytics.PIISafe(String(
|
24
|
-
}
|
22
|
+
for (var key in dimensions) {
|
23
|
+
dimensions[key] = new GOVUK.Analytics.PIISafe(String(dimensions[key]))
|
24
|
+
}
|
25
|
+
return dimensions
|
26
|
+
}
|
27
|
+
|
28
|
+
CustomDimensions.extend = function (out) {
|
29
|
+
out = out || {}
|
30
|
+
|
31
|
+
for (var i = 1; i < arguments.length; i++) {
|
32
|
+
if (!arguments[i]) {
|
33
|
+
continue
|
34
|
+
}
|
35
|
+
|
36
|
+
for (var key in arguments[i]) {
|
37
|
+
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
|
38
|
+
out[key] = arguments[i][key]
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
return out
|
25
44
|
}
|
26
45
|
|
27
46
|
function customDimensionsFromBrowser () {
|
@@ -70,52 +89,59 @@
|
|
70
89
|
'spelling-suggestion': { dimension: 81 }
|
71
90
|
}
|
72
91
|
|
73
|
-
var
|
92
|
+
var metas = document.querySelectorAll("meta[name^='govuk']")
|
74
93
|
var customDimensions = {}
|
75
94
|
var tags = {}
|
76
95
|
|
77
|
-
|
78
|
-
var
|
79
|
-
var
|
80
|
-
|
81
|
-
var dimension = dimensionMappings[key]
|
96
|
+
for (var i = 0; i < metas.length; i++) {
|
97
|
+
var meta = metas[i]
|
98
|
+
var metaKey = meta.getAttribute('name').split('govuk:')[1]
|
99
|
+
var dimension = dimensionMappings[metaKey]
|
82
100
|
if (dimension) {
|
83
|
-
tags[
|
101
|
+
tags[metaKey] = meta.getAttribute('content')
|
84
102
|
}
|
85
|
-
}
|
103
|
+
}
|
86
104
|
|
87
|
-
|
88
|
-
var value = tags[key] ||
|
105
|
+
for (var key in dimensionMappings) {
|
106
|
+
var value = tags[key] || dimensionMappings[key].defaultValue
|
89
107
|
if (typeof value !== 'undefined') {
|
90
|
-
customDimensions['dimension' +
|
108
|
+
customDimensions['dimension' + dimensionMappings[key].dimension] = value
|
91
109
|
}
|
92
|
-
}
|
110
|
+
}
|
93
111
|
|
94
112
|
return customDimensions
|
95
113
|
}
|
96
114
|
|
97
115
|
function customDimensionsFromDom () {
|
116
|
+
var mainLang = document.getElementById('content')
|
117
|
+
if (mainLang) {
|
118
|
+
mainLang = mainLang.getAttribute('lang')
|
119
|
+
}
|
120
|
+
var globalBar = document.querySelector('[data-module="global-bar"]') || false
|
121
|
+
if (globalBar) {
|
122
|
+
globalBar = globalBar.style.display !== 'none'
|
123
|
+
}
|
98
124
|
return {
|
99
125
|
dimension26: GOVUK.PageContent.getNumberOfSections(),
|
100
126
|
dimension27: GOVUK.PageContent.getNumberOfLinks(),
|
101
|
-
dimension23:
|
102
|
-
dimension38:
|
127
|
+
dimension23: mainLang || 'unknown',
|
128
|
+
dimension38: globalBar && 'Global Banner viewed'
|
103
129
|
}
|
104
130
|
}
|
105
131
|
|
106
132
|
function abTestCustomDimensions () {
|
107
|
-
var
|
133
|
+
var abMetas = document.querySelectorAll("meta[name^='govuk:ab-test']")
|
108
134
|
var customDimensions = {}
|
109
135
|
|
110
|
-
|
111
|
-
var
|
112
|
-
var dimension = parseInt(
|
113
|
-
var testNameAndBucket =
|
136
|
+
for (var i = 0; i < abMetas.length; i++) {
|
137
|
+
var meta = abMetas[i]
|
138
|
+
var dimension = parseInt(meta.getAttribute('data-analytics-dimension'))
|
139
|
+
var testNameAndBucket = meta.getAttribute('content')
|
114
140
|
|
115
141
|
if (dimension) {
|
116
142
|
customDimensions['dimension' + dimension] = testNameAndBucket
|
117
143
|
}
|
118
|
-
}
|
144
|
+
}
|
119
145
|
|
120
146
|
return customDimensions
|
121
147
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
// https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce
|
2
|
-
/* global GOVUK,
|
2
|
+
/* global GOVUK, ga */
|
3
3
|
|
4
4
|
(function () {
|
5
5
|
'use strict'
|
@@ -12,25 +12,25 @@
|
|
12
12
|
this.init = function (element) {
|
13
13
|
// Limiting to 100 characters to avoid noise from extra longs search queries
|
14
14
|
// and to stop the size of the payload going over 8k limit.
|
15
|
-
var searchQuery = GOVUK.analytics.stripPII(element.
|
16
|
-
var ecommerceRows = element.
|
17
|
-
var startPosition = parseInt(element.
|
18
|
-
var listTitle = element.
|
19
|
-
var variant = element.
|
20
|
-
var trackClickLabel = element.
|
21
|
-
|
22
|
-
ecommerceRows.
|
23
|
-
var
|
24
|
-
var listSubheading =
|
25
|
-
var contentId =
|
26
|
-
var path =
|
27
|
-
|
28
|
-
var indexOverride =
|
29
|
-
index = indexOverride ? parseInt(indexOverride, 10) - 1 :
|
15
|
+
var searchQuery = GOVUK.analytics.stripPII(element.getAttribute('data-search-query')).substring(0, 100).toLowerCase()
|
16
|
+
var ecommerceRows = element.querySelectorAll('[data-ecommerce-row]')
|
17
|
+
var startPosition = parseInt(element.getAttribute('data-ecommerce-start-index'), 10)
|
18
|
+
var listTitle = element.getAttribute('data-list-title') || DEFAULT_LIST_TITLE
|
19
|
+
var variant = element.getAttribute('data-ecommerce-variant') || undefined
|
20
|
+
var trackClickLabel = element.getAttribute('data-track-click-label') || DEFAULT_TRACK_CLICK_LABEL
|
21
|
+
|
22
|
+
for (var i = 0; i < ecommerceRows.length; i++) {
|
23
|
+
var ecommerceRow = ecommerceRows[i]
|
24
|
+
var listSubheading = ecommerceRow.getAttribute('data-ecommerce-subheading') || undefined
|
25
|
+
var contentId = ecommerceRow.getAttribute('data-ecommerce-content-id') || undefined
|
26
|
+
var path = ecommerceRow.getAttribute('data-ecommerce-path')
|
27
|
+
|
28
|
+
var indexOverride = ecommerceRow.getAttribute('data-ecommerce-index')
|
29
|
+
var index = indexOverride ? parseInt(indexOverride, 10) - 1 : i
|
30
30
|
|
31
31
|
addImpression(contentId, path, index + startPosition, searchQuery, listTitle, listSubheading, variant)
|
32
|
-
trackProductOnClick(
|
33
|
-
}
|
32
|
+
trackProductOnClick(ecommerceRow, contentId, path, index + startPosition, searchQuery, listTitle, listSubheading, variant, trackClickLabel)
|
33
|
+
}
|
34
34
|
}
|
35
35
|
|
36
36
|
function constructData (contentId, path, position, listTitle, listSubheading, searchQuery, variant) {
|
@@ -67,7 +67,7 @@
|
|
67
67
|
}
|
68
68
|
|
69
69
|
function trackProductOnClick (row, contentId, path, position, searchQuery, listTitle, listSubheading, variant, trackClickLabel) {
|
70
|
-
row.click
|
70
|
+
row.addEventListener('click', function () {
|
71
71
|
if (contentId || path) {
|
72
72
|
var clickData = constructData(contentId, path, position, listTitle, listSubheading, searchQuery, variant)
|
73
73
|
ga('ec:addProduct', clickData)
|
@@ -82,18 +82,18 @@
|
|
82
82
|
}
|
83
83
|
|
84
84
|
Ecommerce.ecLoaded = false
|
85
|
-
Ecommerce.start = function (
|
85
|
+
Ecommerce.start = function (elements) {
|
86
86
|
if (!window.ga) { return }
|
87
|
-
|
88
|
-
if (
|
87
|
+
elements = elements || document.querySelectorAll('[data-analytics-ecommerce]')
|
88
|
+
if (elements.length > 0) {
|
89
89
|
if (!Ecommerce.ecLoaded) {
|
90
90
|
ga('require', 'ec')
|
91
91
|
Ecommerce.ecLoaded = true
|
92
92
|
}
|
93
|
-
|
93
|
+
for (var i = 0; i < elements.length; i++) {
|
94
94
|
var ecommerce = new Ecommerce()
|
95
|
-
ecommerce.init(
|
96
|
-
}
|
95
|
+
ecommerce.init(elements[i])
|
96
|
+
}
|
97
97
|
}
|
98
98
|
}
|
99
99
|
|
data/app/assets/javascripts/govuk_publishing_components/analytics/explicit-cross-domain-links.js
CHANGED
@@ -10,12 +10,18 @@
|
|
10
10
|
|
11
11
|
var cookieBannerEngaged = GOVUK.cookie('cookies_preferences_set')
|
12
12
|
|
13
|
-
// If not engaged, append only ?
|
14
|
-
// If engaged and rejected, append only ?
|
15
|
-
// If engaged and accepted usage, append ?_ga=clientid if available and
|
13
|
+
// If not engaged, append only ?cookie_consent=not-engaged
|
14
|
+
// If engaged and rejected, append only ?cookie_consent=reject
|
15
|
+
// If engaged and accepted usage, append ?_ga=clientid if available and cookie_consent=accept
|
16
16
|
|
17
17
|
if (cookieBannerEngaged !== 'true') {
|
18
18
|
this.decorate(element, 'cookie_consent=not-engaged')
|
19
|
+
this.start = this.start.bind(this, $module)
|
20
|
+
|
21
|
+
// if the user has not engaged with the cookie banner yet, listen for the cookie consent accept/reject events
|
22
|
+
// re-start the module if cookies are accepted or rejected on the current page – setting cookie preferences does not reload the page
|
23
|
+
window.addEventListener('cookie-consent', this.start)
|
24
|
+
window.addEventListener('cookie-reject', this.start)
|
19
25
|
return
|
20
26
|
}
|
21
27
|
var cookieConsent = GOVUK.getConsentCookie()
|
@@ -50,6 +56,8 @@
|
|
50
56
|
this.decorate = function (element, param) {
|
51
57
|
var attribute = 'href'
|
52
58
|
var attributeValue = element.getAttribute(attribute)
|
59
|
+
var cookieConsentParameterPattern = /cookie_consent=[^&]*/
|
60
|
+
var paramIsCookieConsent = param.match(cookieConsentParameterPattern)
|
53
61
|
|
54
62
|
if (!attributeValue) {
|
55
63
|
attribute = 'action'
|
@@ -58,13 +66,21 @@
|
|
58
66
|
|
59
67
|
if (!attributeValue) { return }
|
60
68
|
|
61
|
-
|
62
|
-
|
63
|
-
|
69
|
+
var attributeHasCookieConsent = attributeValue.match(cookieConsentParameterPattern)
|
70
|
+
|
71
|
+
if (attributeHasCookieConsent && paramIsCookieConsent) {
|
72
|
+
// if the decorate function has received a cookie_consent parameter, but the target element already has a cookie_consent parameter, replace the existing parameter with the new value
|
73
|
+
attributeValue = attributeValue.replace(cookieConsentParameterPattern, param)
|
64
74
|
} else {
|
65
|
-
|
66
|
-
|
75
|
+
// otherwise, simply append the parameter to the target element href query string
|
76
|
+
if (attributeValue.includes('?')) {
|
77
|
+
attributeValue += '&' + param
|
78
|
+
} else {
|
79
|
+
attributeValue += '?' + param
|
80
|
+
}
|
67
81
|
}
|
82
|
+
|
83
|
+
element.setAttribute(attribute, attributeValue)
|
68
84
|
}
|
69
85
|
}
|
70
86
|
|
@@ -97,6 +97,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
97
97
|
this.$module.cookieBannerConfirmationMessage.focus()
|
98
98
|
window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
|
99
99
|
window.GOVUK.setDefaultConsentCookie()
|
100
|
+
window.GOVUK.triggerEvent(window, 'cookie-reject')
|
100
101
|
}
|
101
102
|
|
102
103
|
CookieBanner.prototype.showConfirmationMessage = function () {
|
@@ -26,9 +26,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
26
26
|
var html = document.createElement('div')
|
27
27
|
html.innerHTML = newButton
|
28
28
|
// test that the html returned contains the button component; if yes, swap the button for the updated version
|
29
|
-
var
|
30
|
-
if (
|
31
|
-
this.$module.
|
29
|
+
var responseButtonContainer = html.querySelector('form.gem-c-single-page-notification-button')
|
30
|
+
if (responseButtonContainer) {
|
31
|
+
this.$module.parentNode.replaceChild(responseButtonContainer, this.$module)
|
32
32
|
}
|
33
33
|
}
|
34
34
|
}
|
@@ -1,13 +1,26 @@
|
|
1
1
|
.gem-c-big-number {
|
2
2
|
margin-bottom: govuk-spacing(3);
|
3
|
+
@include govuk-typography-common;
|
4
|
+
@include govuk-text-colour;
|
3
5
|
}
|
4
6
|
|
5
7
|
.gem-c-big-number__value {
|
6
|
-
|
8
|
+
font-size: 80px;
|
9
|
+
@include govuk-typography-weight-bold;
|
10
|
+
line-height: 1;
|
11
|
+
|
12
|
+
@if $govuk-typography-use-rem {
|
13
|
+
font-size: govuk-px-to-rem(80px);
|
14
|
+
}
|
7
15
|
}
|
8
16
|
|
9
17
|
.gem-c-big-number__label {
|
10
|
-
|
18
|
+
font-size: 16px;
|
19
|
+
@include govuk-typography-weight-bold;
|
20
|
+
|
21
|
+
@if $govuk-typography-use-rem {
|
22
|
+
font-size: govuk-px-to-rem(16px);
|
23
|
+
}
|
11
24
|
|
12
25
|
// This pseudo element is to bypass an issue with NVDA where block level elements are dictated separately.
|
13
26
|
// What's happening here is that the label and the number technically have an inline relationship but appear to have a block relationship thanks to this element
|
@@ -102,6 +102,7 @@ $icon-size: 20px;
|
|
102
102
|
$chevron-indent-spacing: 7px;
|
103
103
|
$black-bar-height: 50px;
|
104
104
|
$search-width-or-height: $black-bar-height;
|
105
|
+
$pseudo-underline-height: 3px;
|
105
106
|
|
106
107
|
@mixin chevron($colour, $update: false) {
|
107
108
|
@if ($update == true) {
|
@@ -111,7 +112,7 @@ $search-width-or-height: $black-bar-height;
|
|
111
112
|
@include prefixed-transform($rotate: 45deg, $translateY: -35%);
|
112
113
|
border-bottom: 2px solid $colour;
|
113
114
|
border-right: 2px solid $colour;
|
114
|
-
content: "
|
115
|
+
content: "";
|
115
116
|
display: inline-block;
|
116
117
|
height: 8px;
|
117
118
|
margin: 0 8px 0 2px;
|
@@ -123,7 +124,7 @@ $search-width-or-height: $black-bar-height;
|
|
123
124
|
@mixin make-selectable-area-bigger {
|
124
125
|
background: none;
|
125
126
|
bottom: 0;
|
126
|
-
content: "
|
127
|
+
content: "";
|
127
128
|
left: 0;
|
128
129
|
position: absolute;
|
129
130
|
right: 0;
|
@@ -133,11 +134,11 @@ $search-width-or-height: $black-bar-height;
|
|
133
134
|
@mixin pseudo-underline {
|
134
135
|
background: none;
|
135
136
|
bottom: 0;
|
136
|
-
content: "
|
137
|
-
height:
|
138
|
-
left: govuk-spacing(
|
137
|
+
content: "";
|
138
|
+
height: $pseudo-underline-height;
|
139
|
+
left: govuk-spacing(5);
|
139
140
|
position: absolute;
|
140
|
-
right: govuk-spacing(
|
141
|
+
right: govuk-spacing(6);
|
141
142
|
top: auto;
|
142
143
|
}
|
143
144
|
|
@@ -441,7 +442,7 @@ $search-width-or-height: $black-bar-height;
|
|
441
442
|
font-size: govuk-px-to-rem(16px);
|
442
443
|
}
|
443
444
|
height: $black-bar-height;
|
444
|
-
padding: govuk-spacing(3);
|
445
|
+
padding: govuk-spacing(3) govuk-spacing(6) govuk-spacing(3) govuk-spacing(5);
|
445
446
|
position: relative;
|
446
447
|
text-decoration: none;
|
447
448
|
|
@@ -762,7 +763,7 @@ $search-width-or-height: $black-bar-height;
|
|
762
763
|
|
763
764
|
&:hover {
|
764
765
|
background: govuk-colour("black");
|
765
|
-
border-bottom:
|
766
|
+
border-bottom: $pseudo-underline-height solid govuk-colour("mid-grey");
|
766
767
|
color: govuk-colour("mid-grey");
|
767
768
|
}
|
768
769
|
|
@@ -845,6 +846,7 @@ $search-width-or-height: $black-bar-height;
|
|
845
846
|
|
846
847
|
// Navigation menu items.
|
847
848
|
.gem-c-layout-super-navigation-header__navigation-second-items {
|
849
|
+
list-style: none;
|
848
850
|
margin: 0;
|
849
851
|
padding: govuk-spacing(6) govuk-spacing(4);
|
850
852
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
suggestion_link_text ||= false
|
4
4
|
suggestion_link_url ||= false
|
5
5
|
suggestion_text ||= nil
|
6
|
+
new_tab ||= false
|
6
7
|
|
7
8
|
data_attributes ||= {}
|
8
9
|
data_attributes[:module] = 'intervention'
|
@@ -13,17 +14,33 @@
|
|
13
14
|
aria_attributes[:label] = 'Intervention'
|
14
15
|
|
15
16
|
local_assigns[:query_string] ||= request.query_string
|
17
|
+
local_assigns[:suggestion_link_text] = suggestion_link_text
|
18
|
+
local_assigns[:suggestion_link_url] = suggestion_link_url
|
16
19
|
|
17
20
|
intervention_helper = GovukPublishingComponents::Presenters::InterventionHelper.new(local_assigns)
|
18
21
|
dismiss_href = intervention_helper.dismiss_link
|
22
|
+
|
23
|
+
suggestion_tag_options = {
|
24
|
+
class: "govuk-link gem-c-intervention__suggestion-link",
|
25
|
+
href: suggestion_link_url,
|
26
|
+
data: suggestion_data_attributes,
|
27
|
+
}
|
28
|
+
|
29
|
+
if new_tab && (suggestion_link_text && suggestion_link_url)
|
30
|
+
target = "_blank"
|
31
|
+
rel = intervention_helper.security_attr
|
32
|
+
|
33
|
+
suggestion_tag_options.merge!({ target: target, rel: rel })
|
34
|
+
|
35
|
+
suggestion_link_text = intervention_helper.accessible_text
|
36
|
+
end
|
19
37
|
%>
|
20
|
-
<% if suggestion_text
|
38
|
+
<% if suggestion_text || (suggestion_link_text && suggestion_link_url) %>
|
21
39
|
<%= tag.section class: "gem-c-intervention", role: "region", aria: aria_attributes, data: data_attributes do %>
|
22
40
|
<p class="govuk-body">
|
23
41
|
<%= tag.span suggestion_text, class: "gem-c-intervention__textwrapper" if suggestion_text %>
|
24
|
-
<% if suggestion_link_text
|
25
|
-
<%= tag.a suggestion_link_text,
|
26
|
-
|
42
|
+
<% if suggestion_link_text && suggestion_link_url %>
|
43
|
+
<%= tag.a suggestion_link_text, suggestion_tag_options %>
|
27
44
|
<% end %>
|
28
45
|
</p>
|
29
46
|
|
data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb
CHANGED
@@ -144,7 +144,7 @@
|
|
144
144
|
</div>
|
145
145
|
<div class="govuk-grid-column-two-thirds-from-desktop">
|
146
146
|
<% if link[:menu_contents].present? %>
|
147
|
-
<ul class="
|
147
|
+
<ul class="gem-c-layout-super-navigation-header__navigation-second-items gem-c-layout-super-navigation-header__navigation-second-items--<%= link[:label].parameterize %>">
|
148
148
|
<% link[:menu_contents].each do | item | %>
|
149
149
|
<%
|
150
150
|
has_description = item[:description].present?
|
@@ -1,9 +1,12 @@
|
|
1
1
|
<%
|
2
2
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
3
|
+
heading_helper = GovukPublishingComponents::Presenters::HeadingHelper.new(local_assigns)
|
3
4
|
|
4
5
|
aria_controls ||= nil
|
5
6
|
button_text ||= t("components.search_box.search_button")
|
6
7
|
id ||= "search-main-" + SecureRandom.hex(4)
|
8
|
+
wrap_label_in_a_heading ||= false
|
9
|
+
label_margin_bottom ||= nil
|
7
10
|
label_size ||= nil
|
8
11
|
label_text ||= t("components.search_box.label")
|
9
12
|
name ||= "q"
|
@@ -14,13 +17,6 @@
|
|
14
17
|
data_attributes ||= {}
|
15
18
|
data_attributes[:module] = 'gem-track-click'
|
16
19
|
|
17
|
-
label_classes = []
|
18
|
-
if (shared_helper.valid_heading_size?(label_size))
|
19
|
-
label_classes << "govuk-label govuk-label--#{label_size}"
|
20
|
-
else
|
21
|
-
label_classes << "gem-c-search__label"
|
22
|
-
end
|
23
|
-
|
24
20
|
classes = %w[gem-c-search govuk-!-display-none-print]
|
25
21
|
classes << (shared_helper.get_margin_top)
|
26
22
|
classes << (shared_helper.get_margin_bottom) if local_assigns[:margin_bottom]
|
@@ -32,11 +28,31 @@
|
|
32
28
|
classes << "gem-c-search--on-white"
|
33
29
|
end
|
34
30
|
classes << "gem-c-search--separate-label" if local_assigns.include?(:inline_label) or local_assigns.include?(:label_size)
|
31
|
+
|
32
|
+
label_classes = []
|
33
|
+
if (shared_helper.valid_heading_size?(label_size))
|
34
|
+
label_classes << "govuk-label govuk-label--#{label_size}"
|
35
|
+
else
|
36
|
+
label_classes << "gem-c-search__label"
|
37
|
+
end
|
38
|
+
label_classes << "govuk-!-margin-bottom-#{label_margin_bottom}" if [*1..9].include?(label_margin_bottom) and local_assigns.include?(:inline_label)
|
39
|
+
|
40
|
+
tag_label = capture do
|
41
|
+
tag.label({ for: id, class: label_classes }) do
|
42
|
+
label_text
|
43
|
+
end
|
44
|
+
end
|
35
45
|
%>
|
36
46
|
|
37
47
|
<div class="<%= classes.join(" ") %>" data-module="gem-toggle-input-class-on-focus">
|
38
|
-
|
39
|
-
<%=
|
48
|
+
<% if wrap_label_in_a_heading %>
|
49
|
+
<%= content_tag(shared_helper.get_heading_level, {
|
50
|
+
class: "govuk-!-margin-0",
|
51
|
+
}) do %>
|
52
|
+
<%= tag_label %>
|
53
|
+
<% end %>
|
54
|
+
<% else %>
|
55
|
+
<%= tag_label %>
|
40
56
|
<% end %>
|
41
57
|
<div class="gem-c-search__item-wrapper">
|
42
58
|
<%= tag.input(
|
data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb
CHANGED
@@ -2,16 +2,18 @@
|
|
2
2
|
component_helper = GovukPublishingComponents::Presenters::SinglePageNotificationButtonHelper.new(local_assigns)
|
3
3
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
4
4
|
|
5
|
-
wrapper_classes = %w(
|
5
|
+
wrapper_classes = %w(govuk-!-display-none-print)
|
6
6
|
wrapper_classes << shared_helper.get_margin_bottom
|
7
7
|
%>
|
8
8
|
<% button_text = capture do %>
|
9
9
|
<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><%= component_helper.button_text %>
|
10
10
|
<% end %>
|
11
|
-
<%= tag.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
<%= tag.div class: wrapper_classes, data: { module: "gem-track-click"} do %>
|
12
|
+
<%= tag.form class: "gem-c-single-page-notification-button", action: "/email/subscriptions/single-page/new", method: "POST", data: component_helper.data do %>
|
13
|
+
<input type="hidden" name="base_path" value="<%= component_helper.base_path %>">
|
14
|
+
<%= content_tag(:button, button_text, {
|
15
|
+
class: "govuk-body-s gem-c-single-page-notification-button__submit",
|
16
|
+
type: "submit",
|
17
|
+
}) %>
|
18
|
+
<% end %>
|
17
19
|
<% end if component_helper.base_path %>
|
@@ -1,9 +1,12 @@
|
|
1
1
|
<%
|
2
2
|
description ||= nil
|
3
3
|
title_id ||= "govuk-notification-banner-title-#{SecureRandom.hex(4)}"
|
4
|
+
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
5
|
+
classes = %w(gem-c-success-alert govuk-notification-banner govuk-notification-banner--success)
|
6
|
+
classes << shared_helper.get_margin_bottom if local_assigns[:margin_bottom]
|
4
7
|
%>
|
5
8
|
|
6
|
-
<%= tag.div class:
|
9
|
+
<%= tag.div class: classes,
|
7
10
|
role: "alert",
|
8
11
|
tabindex: "-1",
|
9
12
|
aria: {
|
@@ -38,6 +38,17 @@ examples:
|
|
38
38
|
suggestion_link_text: "You can now apply for a permit online."
|
39
39
|
suggestion_link_url: "/permit"
|
40
40
|
|
41
|
+
open_suggestion_link_in_new_tab:
|
42
|
+
description: |
|
43
|
+
When sending users to another online task, you don't want to completely hijack
|
44
|
+
their original flow on GOV.UK. Adding the option to open links in a new tab helps to address this.
|
45
|
+
Link text should tell the user that the link opens in a new tab.
|
46
|
+
Note: "(opens in a new tab)" is added to link text if the phrase isn't included.
|
47
|
+
data:
|
48
|
+
suggestion_link_text: "You can now apply for a permit online"
|
49
|
+
suggestion_link_url: "www.google.com/permit"
|
50
|
+
new_tab: true
|
51
|
+
|
41
52
|
with_data_attributes:
|
42
53
|
description: |
|
43
54
|
This example shows the use of `suggestion_data_attributes` and
|
@@ -69,7 +69,7 @@ examples:
|
|
69
69
|
<h2 class="govuk-heading-l">This is a title</h2>
|
70
70
|
<p class="govuk-body">This is some body text with <a href="https://example.com">a link</a>.
|
71
71
|
with_current_account_navigation:
|
72
|
-
description: "The account layout renders with an account-specific nav to help users navigate different areas of their account. This flag is here to allow control over which option in the nav is highlighted as `current`. Valid options are currently `your-account
|
72
|
+
description: "The account layout renders with an account-specific nav to help users navigate different areas of their account. This flag is here to allow control over which option in the nav is highlighted as `current`. Valid options are currently `your-account` and `manage`."
|
73
73
|
data:
|
74
74
|
show_account_layout: true
|
75
75
|
account_nav_location: "manage"
|
@@ -37,6 +37,7 @@ govuk_frontend_components:
|
|
37
37
|
examples:
|
38
38
|
default:
|
39
39
|
data:
|
40
|
+
heading: How do you want to sign in?
|
40
41
|
name: "radio-group"
|
41
42
|
items:
|
42
43
|
- value: "government-gateway"
|
@@ -45,6 +46,7 @@ examples:
|
|
45
46
|
text: "Use GOV.UK Verify"
|
46
47
|
with_small_radios:
|
47
48
|
data:
|
49
|
+
heading: How do you want to sign in?
|
48
50
|
name: "radio-group"
|
49
51
|
small: true
|
50
52
|
items:
|
@@ -52,9 +54,10 @@ examples:
|
|
52
54
|
text: "Use Government Gateway"
|
53
55
|
- value: "govuk-verify"
|
54
56
|
text: "Use GOV.UK Verify"
|
55
|
-
|
56
|
-
description: Used to provide better contrast between long labels and hint text
|
57
|
+
with_bold_labels:
|
58
|
+
description: Used to provide better contrast between long labels and hint text.
|
57
59
|
data:
|
60
|
+
heading: How do you want to sign in?
|
58
61
|
name: "radio-group-bold"
|
59
62
|
items:
|
60
63
|
- value: "government-gateway"
|
@@ -65,9 +68,10 @@ examples:
|
|
65
68
|
text: "Use GOV.UK Verify"
|
66
69
|
hint_text: "You'll have an account if you've already proved your identity with a certified company, such as the Post Office."
|
67
70
|
bold: true
|
68
|
-
|
71
|
+
with_custom_bottom_margin:
|
69
72
|
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 a margin bottom of `30px` (`6`).
|
70
73
|
data:
|
74
|
+
heading: How do you want to sign in?
|
71
75
|
name: "radio-group"
|
72
76
|
margin_bottom: 9
|
73
77
|
items:
|
@@ -77,6 +81,7 @@ examples:
|
|
77
81
|
text: "Use GOV.UK Verify"
|
78
82
|
with_hint_on_form_group:
|
79
83
|
data:
|
84
|
+
heading: How do you want to sign in?
|
80
85
|
name: "radio-group-error"
|
81
86
|
id_prefix: "hint"
|
82
87
|
hint: "You’ll need to prove your identity using one of the following methods"
|
@@ -97,10 +102,10 @@ examples:
|
|
97
102
|
text: "Yes"
|
98
103
|
- value: "no"
|
99
104
|
text: "No"
|
100
|
-
|
105
|
+
with_custom_heading_size:
|
101
106
|
description: |
|
102
|
-
By default, text supplied for the `legend` is wrapped inside a `h2`.
|
103
|
-
|
107
|
+
By default, text supplied for the `legend` is wrapped inside a `h2`.
|
108
|
+
|
104
109
|
The font size of this heading can be changed using the `heading_size` option. Valid options are `s`, `m`, `l`, `xl`, defaulting to `m` if no option is passed.
|
105
110
|
data:
|
106
111
|
name: "radio-group-description"
|
@@ -113,10 +118,10 @@ examples:
|
|
113
118
|
text: "Green"
|
114
119
|
- value: "blue"
|
115
120
|
text: "Blue"
|
116
|
-
|
121
|
+
with_custom_heading_level:
|
117
122
|
description: |
|
118
123
|
By default, text supplied for the `legend` is wrapped inside a `h2`. This can be changed using the `heading_level` option.
|
119
|
-
|
124
|
+
|
120
125
|
If `heading_level` is `1` and `heading_size` is not set, the text size will be `xl`.
|
121
126
|
data:
|
122
127
|
name: "radio-group-description"
|
@@ -129,22 +134,10 @@ examples:
|
|
129
134
|
text: "Green"
|
130
135
|
- value: "blue"
|
131
136
|
text: "Blue"
|
132
|
-
|
133
|
-
data:
|
134
|
-
name: "radio-group-heading"
|
135
|
-
heading: "What is your favourite colour?"
|
136
|
-
hint: "If your favourite is not below, pick the colour closest to it."
|
137
|
-
items:
|
138
|
-
- value: "red"
|
139
|
-
text: "Red"
|
140
|
-
- value: "green"
|
141
|
-
text: "Green"
|
142
|
-
- value: "blue"
|
143
|
-
text: "Blue"
|
144
|
-
with_page_header_and_caption:
|
137
|
+
with_page_heading_and_caption:
|
145
138
|
description: |
|
146
139
|
A caption can be added using the `heading_caption` option. Captions will only be displayed if text for the heading option is present.
|
147
|
-
|
140
|
+
|
148
141
|
The pattern is used across GOV.UK to show a high-level section that this page belongs to.
|
149
142
|
data:
|
150
143
|
name: "radio-group-heading"
|
@@ -167,7 +160,7 @@ examples:
|
|
167
160
|
text: "Yes"
|
168
161
|
- value: "no"
|
169
162
|
text: "No"
|
170
|
-
|
163
|
+
with_description:
|
171
164
|
data:
|
172
165
|
name: "radio-group-description"
|
173
166
|
heading: "What is your favourite colour?"
|
@@ -217,6 +210,7 @@ examples:
|
|
217
210
|
text: "Blue"
|
218
211
|
with_hint_text_on_radios:
|
219
212
|
data:
|
213
|
+
heading: How do you want to sign in?
|
220
214
|
name: "radio-group-hint-text"
|
221
215
|
items:
|
222
216
|
- value: "government-gateway"
|
@@ -227,6 +221,7 @@ examples:
|
|
227
221
|
text: "Use GOV.UK Verify"
|
228
222
|
with_checked_option:
|
229
223
|
data:
|
224
|
+
heading: How do you want to sign in?
|
230
225
|
name: "radio-group-checked"
|
231
226
|
items:
|
232
227
|
- value: "government-gateway"
|
@@ -236,15 +231,17 @@ examples:
|
|
236
231
|
checked: true
|
237
232
|
with_data_attributes:
|
238
233
|
data:
|
234
|
+
heading: How do you want to sign in?
|
239
235
|
name: "radio-group-data-attributes"
|
240
236
|
items:
|
241
|
-
- value: "
|
242
|
-
text: "
|
243
|
-
|
244
|
-
|
245
|
-
|
237
|
+
- value: "government-gateway"
|
238
|
+
text: "Use Government Gateway"
|
239
|
+
- value: "govuk-verify"
|
240
|
+
text: "Use GOV.UK Verify"
|
241
|
+
data_attributes: { "contextual-guidance": "government-gateway" }
|
246
242
|
with_custom_id_prefix:
|
247
243
|
data:
|
244
|
+
heading: How do you want to sign in?
|
248
245
|
id_prefix: 'custom'
|
249
246
|
name: "radio-custom-id-prefix"
|
250
247
|
items:
|
@@ -255,6 +252,7 @@ examples:
|
|
255
252
|
with_or_divider:
|
256
253
|
description: "See [related service manual guidance for this pattern](https://www.gov.uk/service-manual/design/writing-for-user-interfaces#ask-questions-that-users-can-understand)"
|
257
254
|
data:
|
255
|
+
heading: How do you want to sign in?
|
258
256
|
name: "radio-group-or-divider"
|
259
257
|
items:
|
260
258
|
- value: "government-gateway"
|
@@ -267,6 +265,7 @@ examples:
|
|
267
265
|
extreme:
|
268
266
|
description: 'Note that the `:or` option [is documented as a string due to a bug](https://github.com/alphagov/govuk_publishing_components/issues/102)'
|
269
267
|
data:
|
268
|
+
heading: How do you want to sign in?
|
270
269
|
id_prefix: 'extreme'
|
271
270
|
name: "radio-custom-extreme"
|
272
271
|
items:
|
@@ -289,6 +288,7 @@ examples:
|
|
289
288
|
bold: true
|
290
289
|
with_error_on_form_group:
|
291
290
|
data:
|
291
|
+
heading: How do you want to sign in?
|
292
292
|
name: "radio-group-error"
|
293
293
|
id_prefix: "error"
|
294
294
|
error_message: "Please select one option"
|
@@ -300,6 +300,7 @@ examples:
|
|
300
300
|
with_error_and_hint_on_form_group:
|
301
301
|
description: ""
|
302
302
|
data:
|
303
|
+
heading: How do you want to sign in?
|
303
304
|
name: "radio-group-error"
|
304
305
|
id_prefix: "error"
|
305
306
|
error_message: "Please select one option"
|
@@ -311,6 +312,7 @@ examples:
|
|
311
312
|
text: "Use GOV.UK Verify"
|
312
313
|
with_error_items_on_form_group:
|
313
314
|
data:
|
315
|
+
heading: How do you want to sign in?
|
314
316
|
name: "radio-group-error"
|
315
317
|
id_prefix: "error"
|
316
318
|
error_items:
|
@@ -325,6 +327,7 @@ examples:
|
|
325
327
|
text: "Use GOV.UK Verify"
|
326
328
|
conditional:
|
327
329
|
data:
|
330
|
+
heading: How do you want to sign in?
|
328
331
|
name: "radio-group-conditional"
|
329
332
|
id_prefix: "conditional"
|
330
333
|
items:
|
@@ -336,7 +339,8 @@ examples:
|
|
336
339
|
conditional: "You’ll need to prove your identity using GOV.UK Verify"
|
337
340
|
conditional_checked:
|
338
341
|
data:
|
339
|
-
|
342
|
+
heading: How do you want to sign in?
|
343
|
+
name: "radio-group-conditional-checked"
|
340
344
|
id_prefix: "conditional-checked"
|
341
345
|
items:
|
342
346
|
- value: "government-gateway"
|
@@ -348,6 +352,7 @@ examples:
|
|
348
352
|
conditional: "You’ll need to prove your identity using GOV.UK Verify"
|
349
353
|
tracking-url:
|
350
354
|
data:
|
355
|
+
heading: How do you want to sign in?
|
351
356
|
name: "radio-group-tracking-url"
|
352
357
|
id_prefix: "tracking-url"
|
353
358
|
items:
|
@@ -360,15 +365,17 @@ examples:
|
|
360
365
|
inline:
|
361
366
|
description: "When providing few options, radio buttons should be inline rather than stacked. We recommend this for two small options like yes and no, on and off"
|
362
367
|
data:
|
368
|
+
heading: Have you changed your name?
|
363
369
|
name: "inline-radios"
|
364
370
|
inline: true
|
365
371
|
items:
|
366
|
-
- value: "
|
367
|
-
text: "
|
368
|
-
- value: "
|
369
|
-
text: "
|
372
|
+
- value: "yes"
|
373
|
+
text: "Yes"
|
374
|
+
- value: "no"
|
375
|
+
text: "No"
|
370
376
|
with_custom_id_attribute:
|
371
377
|
data:
|
378
|
+
heading: How do you want to sign in?
|
372
379
|
name: "radio-group"
|
373
380
|
id: "radio-group"
|
374
381
|
items:
|
@@ -69,3 +69,28 @@ examples:
|
|
69
69
|
Allows the label text size to be set to `xl`, `l`, `m`, or `s`. If this is set, then `inline_label` is automatically set to `false`.
|
70
70
|
data:
|
71
71
|
label_size: "xl"
|
72
|
+
wrap_label_inside_a_heading:
|
73
|
+
description: |
|
74
|
+
Puts the label inside a heading; heading level defaults to 2 if not set.
|
75
|
+
|
76
|
+
(The size of the label can still be set with `label_size` to appear more like a heading.)
|
77
|
+
data:
|
78
|
+
wrap_label_in_a_heading: true
|
79
|
+
heading_level: 1
|
80
|
+
with_margin_bottom:
|
81
|
+
description: |
|
82
|
+
Allows the spacing at the bottom of the component to be adjusted.
|
83
|
+
|
84
|
+
This accepts a number 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 no margin bottom.
|
85
|
+
data:
|
86
|
+
margin_bottom: 9
|
87
|
+
with_margin_bottom_for_the_label:
|
88
|
+
description: |
|
89
|
+
Allows the spacing between the label and the input be adjusted.
|
90
|
+
|
91
|
+
Requires `inline_label` to be false.
|
92
|
+
|
93
|
+
This accepts a number 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 no margin bottom.
|
94
|
+
data:
|
95
|
+
label_margin_bottom: 9
|
96
|
+
inline_label: false
|
@@ -37,3 +37,9 @@ examples:
|
|
37
37
|
orci. Proin semper porttitor ipsum, vel maximus justo rutrum vel.
|
38
38
|
Morbi volutpat facilisis libero. Donec posuere eget odio non egestas.
|
39
39
|
Nullam sed neque quis turpis.
|
40
|
+
with_custom_margin_bottom:
|
41
|
+
description: |
|
42
|
+
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). The default margins for the component are inherited from the [notification-banner](https://github.com/alphagov/govuk-frontend/blob/main/package/govuk/components/notification-banner/_index.scss) styles defined in the Design System.
|
43
|
+
data:
|
44
|
+
message: Message to alert the user to a successful action goes here
|
45
|
+
margin_bottom: 3
|
data/config/locales/en.yml
CHANGED
@@ -86,8 +86,10 @@ en:
|
|
86
86
|
news_and_communications: News and communications
|
87
87
|
statistics: Statistics
|
88
88
|
worldwide: Worldwide
|
89
|
+
intervention:
|
90
|
+
accessible_link_text_suffix: " (opens in a new tab)"
|
89
91
|
layout_footer:
|
90
|
-
copyright_html: <a class="govuk-footer__link govuk-footer__copyright-logo" href="
|
92
|
+
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>
|
91
93
|
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
|
92
94
|
support_links: Support links
|
93
95
|
layout_for_public:
|
@@ -11,6 +11,7 @@ module GovukPublishingComponents
|
|
11
11
|
:rel,
|
12
12
|
:data_attributes,
|
13
13
|
:margin_bottom,
|
14
|
+
:id,
|
14
15
|
:inline_layout,
|
15
16
|
:target,
|
16
17
|
:type,
|
@@ -49,16 +50,39 @@ module GovukPublishingComponents
|
|
49
50
|
@value = local_assigns[:value]
|
50
51
|
@classes = local_assigns[:classes]
|
51
52
|
@aria_label = local_assigns[:aria_label]
|
53
|
+
@info_text_id = "info-text-id-#{SecureRandom.hex(4)}"
|
54
|
+
@button_id = "button-id-#{SecureRandom.hex(4)}"
|
52
55
|
end
|
53
56
|
|
54
57
|
def link?
|
55
58
|
href.present?
|
56
59
|
end
|
57
60
|
|
61
|
+
def info_text?
|
62
|
+
info_text.present?
|
63
|
+
end
|
64
|
+
|
65
|
+
def aria_labelledby
|
66
|
+
if info_text?
|
67
|
+
text = "#{@button_id} "
|
68
|
+
text << @info_text_id
|
69
|
+
text
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def info_text_options
|
74
|
+
options = { class: info_text_classes }
|
75
|
+
options[:aria] = { hidden: true } if info_text?
|
76
|
+
options[:id] = @info_text_id if info_text?
|
77
|
+
options
|
78
|
+
end
|
79
|
+
|
58
80
|
def html_options
|
59
81
|
options = { class: css_classes }
|
60
82
|
options[:role] = "button" if link?
|
61
83
|
options[:type] = button_type
|
84
|
+
options[:id] = @button_id if info_text?
|
85
|
+
options[:aria] = { labelledby: aria_labelledby }
|
62
86
|
options[:rel] = rel if rel
|
63
87
|
options[:data] = data_attributes if data_attributes
|
64
88
|
options[:title] = title if title
|
@@ -1,10 +1,17 @@
|
|
1
1
|
module GovukPublishingComponents
|
2
2
|
module Presenters
|
3
3
|
class InterventionHelper
|
4
|
-
attr_reader :query_string
|
5
|
-
|
6
4
|
def initialize(local_assigns)
|
5
|
+
@accessible_text_suffix = I18n.t("components.intervention.accessible_link_text_suffix")
|
7
6
|
@query_string = local_assigns[:query_string]
|
7
|
+
@suggestion_link_text = local_assigns[:suggestion_link_text]
|
8
|
+
@suggestion_link_url = local_assigns[:suggestion_link_url]
|
9
|
+
end
|
10
|
+
|
11
|
+
def accessible_text
|
12
|
+
@suggestion_link_text << @accessible_text_suffix unless @suggestion_link_text.include?(@accessible_text_suffix)
|
13
|
+
|
14
|
+
@suggestion_link_text
|
8
15
|
end
|
9
16
|
|
10
17
|
def dismiss_link
|
@@ -14,6 +21,17 @@ module GovukPublishingComponents
|
|
14
21
|
"?hide-intervention=true"
|
15
22
|
end
|
16
23
|
end
|
24
|
+
|
25
|
+
def security_attr
|
26
|
+
rel = "noopener noreferrer"
|
27
|
+
rel << " external" unless @suggestion_link_url.start_with?("/", "https://gov.uk", "https://www.gov.uk")
|
28
|
+
|
29
|
+
rel
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :accessible_text_suffix, :query_string, :suggestion_link_text, :suggestion_link_url
|
17
35
|
end
|
18
36
|
end
|
19
37
|
end
|
@@ -14,15 +14,12 @@ module GovukPublishingComponents
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def data
|
17
|
-
|
18
|
-
module_names << "single-page-notification-button" if js_enhancement
|
19
|
-
|
20
|
-
@data_attributes[:label] = base_path
|
17
|
+
@data_attributes[:track_label] = base_path
|
21
18
|
# data-action for tracking should have the format of e.g. "Unsubscribe-button-top", or "Subscribe-button-bottom"
|
22
19
|
# when button_location is not present data-action will fall back to "Unsubscribe-button"/"Subscribe-button"
|
23
|
-
@data_attributes[:
|
24
|
-
@data_attributes[:module] =
|
25
|
-
@data_attributes[:
|
20
|
+
@data_attributes[:track_action] = [button_type, "button", button_location].compact.join("-")
|
21
|
+
@data_attributes[:module] = "single-page-notification-button" if js_enhancement
|
22
|
+
@data_attributes[:track_category] = "Single-page-notification-button"
|
26
23
|
# This attribute is passed through to the personalisation API to ensure when a new button is returned from the API, it has the same button_location
|
27
24
|
@data_attributes[:button_location] = button_location
|
28
25
|
@data_attributes
|
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: 27.
|
4
|
+
version: 27.16.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: 2021-
|
11
|
+
date: 2021-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|