govuk_publishing_components 35.5.0 → 35.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/app/assets/javascripts/component_guide/audit-filter.js +45 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-auto-tracker.js +0 -3
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +30 -35
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +1 -3
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +1 -1
- data/app/assets/stylesheets/component_guide/application.scss +0 -29
- data/app/assets/stylesheets/govuk_publishing_components/components/_select.scss +0 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +3 -2
- data/app/views/govuk_publishing_components/audit/_component_contents.html.erb +37 -49
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +38 -18
- data/app/views/govuk_publishing_components/components/_character_count.html.erb +4 -2
- data/app/views/govuk_publishing_components/components/_contents_list.html.erb +17 -2
- data/app/views/govuk_publishing_components/components/_feedback.html.erb +1 -0
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +3 -0
- data/app/views/govuk_publishing_components/components/_metadata.html.erb +12 -1
- data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +20 -1
- data/app/views/govuk_publishing_components/components/_radio.html.erb +1 -0
- data/app/views/govuk_publishing_components/components/_search.html.erb +1 -0
- data/app/views/govuk_publishing_components/components/_select.html.erb +1 -0
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/attachment/_thumbnail_document.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/attachment/_thumbnail_generic.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/attachment/_thumbnail_html.html.erb +3 -0
- data/app/views/govuk_publishing_components/components/attachment/_thumbnail_spreadsheet.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/docs/attachment.yml +21 -0
- data/app/views/govuk_publishing_components/components/docs/contents_list.yml +19 -0
- data/app/views/govuk_publishing_components/components/docs/contextual_guidance.yml +11 -4
- data/app/views/govuk_publishing_components/components/docs/fieldset.yml +75 -30
- data/app/views/govuk_publishing_components/components/docs/govspeak.yml +43 -0
- data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +42 -32
- data/app/views/govuk_publishing_components/components/docs/metadata.yml +7 -0
- data/app/views/govuk_publishing_components/components/docs/modal_dialogue.yml +35 -5
- data/app/views/govuk_publishing_components/components/docs/previous_and_next_navigation.yml +12 -0
- data/app/views/govuk_publishing_components/components/docs/textarea.yml +8 -2
- data/app/views/layouts/govuk_publishing_components/application.html.erb +23 -20
- data/config/locales/ar.yml +1 -0
- data/config/locales/az.yml +1 -0
- data/config/locales/be.yml +1 -0
- data/config/locales/bg.yml +1 -0
- data/config/locales/bn.yml +1 -0
- data/config/locales/cs.yml +1 -0
- data/config/locales/cy.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +1 -0
- data/config/locales/dr.yml +1 -0
- data/config/locales/el.yml +1 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/es-419.yml +1 -0
- data/config/locales/es.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/fa.yml +1 -0
- data/config/locales/fi.yml +1 -0
- data/config/locales/fr.yml +1 -0
- data/config/locales/gd.yml +1 -0
- data/config/locales/gu.yml +1 -0
- data/config/locales/he.yml +1 -0
- data/config/locales/hi.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +1 -0
- data/config/locales/hy.yml +1 -0
- data/config/locales/id.yml +1 -0
- data/config/locales/is.yml +1 -0
- data/config/locales/it.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/config/locales/ka.yml +1 -0
- data/config/locales/kk.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +1 -0
- data/config/locales/ms.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +1 -0
- data/config/locales/no.yml +1 -0
- data/config/locales/pa-pk.yml +1 -0
- data/config/locales/pa.yml +1 -0
- data/config/locales/pl.yml +1 -0
- data/config/locales/ps.yml +1 -0
- data/config/locales/pt.yml +1 -0
- data/config/locales/ro.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/config/locales/si.yml +1 -0
- data/config/locales/sk.yml +1 -0
- data/config/locales/sl.yml +1 -0
- data/config/locales/so.yml +1 -0
- data/config/locales/sq.yml +1 -0
- data/config/locales/sr.yml +1 -0
- data/config/locales/sv.yml +1 -0
- data/config/locales/sw.yml +1 -0
- data/config/locales/ta.yml +1 -0
- data/config/locales/th.yml +1 -0
- data/config/locales/tk.yml +1 -0
- data/config/locales/tr.yml +1 -0
- data/config/locales/uk.yml +1 -0
- data/config/locales/ur.yml +1 -0
- data/config/locales/uz.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-hk.yml +1 -0
- data/config/locales/zh-tw.yml +1 -0
- data/config/locales/zh.yml +1 -0
- data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +5 -1
- data/lib/govuk_publishing_components/presenters/attachment_helper.rb +15 -3
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/README.md +4 -0
- data/node_modules/axe-core/axe.js +25 -19
- data/node_modules/axe-core/axe.min.js +2 -2
- data/node_modules/axe-core/package.json +1 -1
- data/node_modules/axe-core/sri-history.json +4 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19aaa8a186568f17fc86baced60aab3d35f790e35f819702736f6dc861f64bcb
|
4
|
+
data.tar.gz: 947c684323444fb20d04063a801f71868193ca46ee7dfba877a26b05c235ae5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c151b005305fa534de28d3769131a41334c3a39b64e89a8f737f6e59747ba03d28d24e62fcdf122fb9b290c5a3d3596842aa973100a208144c83280dcf12fb1
|
7
|
+
data.tar.gz: 1ef830fa00101728968b9bc2e0d865f923cf00cbd265b33d5e8958f18539938146a1b802e6e6d42a0ee269fc2be3664ba89734d67dbcabef04187a46caa22df8
|
data/README.md
CHANGED
@@ -58,6 +58,7 @@ yarn run jasmine:ci
|
|
58
58
|
- [Testing a component](docs/testing-components.md)
|
59
59
|
- [Component auditing](docs/auditing.md)
|
60
60
|
- [Code documentation on rubydoc.info](http://www.rubydoc.info/gems/govuk_publishing_components)
|
61
|
+
- [Our analytics approach](docs/analytics-ga4/analytics.md)
|
61
62
|
|
62
63
|
More documentation can be found in the [docs directory](docs/).
|
63
64
|
|
@@ -5,6 +5,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
5
5
|
function AuditFilter ($module) {
|
6
6
|
this.module = $module
|
7
7
|
this.data = this.module.querySelector('[data-audit-list]')
|
8
|
+
this.headings = this.module.querySelector('[data-audit-headings]')
|
8
9
|
}
|
9
10
|
|
10
11
|
AuditFilter.prototype.init = function () {
|
@@ -14,6 +15,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
14
15
|
|
15
16
|
this.filterComponentsFunction = this.filterComponents.bind(this)
|
16
17
|
this.select.addEventListener('change', this.filterComponentsFunction)
|
18
|
+
this.setHeadingCount()
|
17
19
|
}
|
18
20
|
}
|
19
21
|
|
@@ -75,6 +77,49 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
75
77
|
}
|
76
78
|
}
|
77
79
|
}
|
80
|
+
this.setHeadingCount()
|
81
|
+
}
|
82
|
+
|
83
|
+
AuditFilter.prototype.setHeadingCount = function () {
|
84
|
+
if (this.headings) {
|
85
|
+
var visibleRows = this.data.querySelectorAll('[data-application]:not([hidden])')
|
86
|
+
|
87
|
+
if (!this.headingLabels) {
|
88
|
+
this.headingLabels = this.getHeadingLabels()
|
89
|
+
}
|
90
|
+
// need an array of zeroes same length as headingLabels to store the counts
|
91
|
+
var headingCounts = new Array(this.headingLabels.length)
|
92
|
+
for (var i = 0; i < this.headingLabels.length; ++i) {
|
93
|
+
headingCounts[i] = 0
|
94
|
+
}
|
95
|
+
|
96
|
+
for (var j = 0; j < visibleRows.length; j++) {
|
97
|
+
for (var k = 0; k < this.headingLabels.length; k++) {
|
98
|
+
var cell = visibleRows[j].querySelector('[data-component-type=' + this.headingLabels[k] + ']')
|
99
|
+
if (cell.textContent.trim().length) {
|
100
|
+
headingCounts[k] += 1
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
var reg = /\([0-9]+\)/i
|
106
|
+
for (var l = 0; l < this.headingLabels.length; l++) {
|
107
|
+
var headingItem = this.headings.querySelector('[data-component-type=' + this.headingLabels[l] + ']')
|
108
|
+
headingItem.textContent = headingItem.textContent.replace(reg, '') + ' (' + headingCounts[l] + ')'
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
AuditFilter.prototype.getHeadingLabels = function () {
|
114
|
+
var headings = this.headings.querySelectorAll('[data-component-type]')
|
115
|
+
var labels = []
|
116
|
+
for (var i = 0; i < headings.length; i++) {
|
117
|
+
var label = headings[i].getAttribute('data-component-type')
|
118
|
+
if (labels.indexOf(label) === -1) {
|
119
|
+
labels.push(label)
|
120
|
+
}
|
121
|
+
}
|
122
|
+
return labels
|
78
123
|
}
|
79
124
|
|
80
125
|
Modules.AuditFilter = AuditFilter
|
@@ -35,9 +35,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
35
35
|
return
|
36
36
|
}
|
37
37
|
|
38
|
-
if (data.index) {
|
39
|
-
data.index = window.GOVUK.analyticsGa4.core.trackFunctions.createIndexObject(data.index)
|
40
|
-
}
|
41
38
|
var schemas = new window.GOVUK.analyticsGa4.Schemas()
|
42
39
|
var schema = schemas.mergeProperties(data, 'event_data')
|
43
40
|
|
@@ -30,7 +30,32 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
|
|
30
30
|
firstScript.parentNode.insertBefore(newScript, firstScript)
|
31
31
|
},
|
32
32
|
|
33
|
+
ensureIndexesArePopulated: function (data) {
|
34
|
+
if (!data.event_data) {
|
35
|
+
return data
|
36
|
+
}
|
37
|
+
|
38
|
+
if (!data.event_data.index) {
|
39
|
+
return data
|
40
|
+
}
|
41
|
+
|
42
|
+
var indexKeys = ['index_link', 'index_section', 'index_section_count']
|
43
|
+
|
44
|
+
for (var i = 0; i < indexKeys.length; i++) {
|
45
|
+
var indexKey = indexKeys[i]
|
46
|
+
|
47
|
+
// If the index key isn't in the object, populate it. However if it's set to 0, leave it as 0. 0 is falsy so we have to add this extra check.
|
48
|
+
if (!data.event_data.index[indexKey] && data.event_data.index[indexKey] !== 0) {
|
49
|
+
data.event_data.index[indexKey] = undefined
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
return data
|
54
|
+
},
|
55
|
+
|
33
56
|
sendData: function (data) {
|
57
|
+
data = this.ensureIndexesArePopulated(data)
|
58
|
+
|
34
59
|
data.govuk_gem_version = this.getGemVersion()
|
35
60
|
// set this in the console as a debugging aid
|
36
61
|
if (window.GOVUK.analyticsGa4.showDebug) {
|
@@ -231,11 +256,12 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
|
|
231
256
|
var totalLinks = 0
|
232
257
|
for (var i = 0; i < links.length; i++) {
|
233
258
|
var link = links[i]
|
234
|
-
// Only index links that are not search results
|
235
|
-
if (
|
236
|
-
|
237
|
-
link.setAttribute('data-ga4-index', '{"index_link": ' + totalLinks + '}')
|
259
|
+
// Only index links that are not search results or do not have a data-ga4-do-not-index attribute
|
260
|
+
if (link.getAttribute('data-ga4-ecommerce-path') || link.getAttribute('data-ga4-do-not-index') !== null) {
|
261
|
+
continue
|
238
262
|
}
|
263
|
+
totalLinks++
|
264
|
+
link.setAttribute('data-ga4-index', '{"index_link": ' + totalLinks + '}')
|
239
265
|
}
|
240
266
|
|
241
267
|
try {
|
@@ -248,37 +274,6 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
|
|
248
274
|
}
|
249
275
|
},
|
250
276
|
|
251
|
-
// index is given as a string of the form 1.2.3 or 1.2
|
252
|
-
// split this into named sub-parameters
|
253
|
-
createIndexObject: function (index) {
|
254
|
-
if (typeof index === 'undefined') {
|
255
|
-
return undefined
|
256
|
-
}
|
257
|
-
if (typeof index === 'object') {
|
258
|
-
return index
|
259
|
-
}
|
260
|
-
|
261
|
-
index = index.toString().split('.')
|
262
|
-
// this will soon include 'index_section_count'
|
263
|
-
// number of sections overall in the thing being tracked (but not yet in use)
|
264
|
-
switch (index.length) {
|
265
|
-
case 1:
|
266
|
-
return {
|
267
|
-
index_section: parseInt(index[0])
|
268
|
-
}
|
269
|
-
case 2:
|
270
|
-
return {
|
271
|
-
index_section: parseInt(index[0]),
|
272
|
-
index_link: parseInt(index[1])
|
273
|
-
}
|
274
|
-
case 3:
|
275
|
-
return {
|
276
|
-
index_section: parseInt(index[1]),
|
277
|
-
index_link: parseInt(index[2])
|
278
|
-
}
|
279
|
-
}
|
280
|
-
},
|
281
|
-
|
282
277
|
addAttributesToElements: function (selector, dataAttributes) {
|
283
278
|
var targetElements = document.querySelectorAll(selector)
|
284
279
|
|
@@ -42,7 +42,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
42
42
|
|
43
43
|
var text = data.text || event.target.textContent
|
44
44
|
data.text = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(text)
|
45
|
-
data.index = window.GOVUK.analyticsGa4.core.trackFunctions.createIndexObject(data.index)
|
46
45
|
|
47
46
|
var schemas = new window.GOVUK.analyticsGa4.Schemas()
|
48
47
|
var schema = schemas.mergeProperties(data, 'event_data')
|
@@ -111,9 +111,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
111
111
|
}
|
112
112
|
}
|
113
113
|
|
114
|
-
Ga4LinkTracker.prototype.setIndex = function (
|
115
|
-
var index = window.GOVUK.analyticsGa4.core.trackFunctions.createIndexObject(indexData)
|
116
|
-
|
114
|
+
Ga4LinkTracker.prototype.setIndex = function (index, target) {
|
117
115
|
if (target.getAttribute('data-ga4-index')) {
|
118
116
|
try {
|
119
117
|
var indexLink = JSON.parse(target.getAttribute('data-ga4-index'))
|
@@ -17,7 +17,7 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
|
|
17
17
|
location: this.getLocation(),
|
18
18
|
/* If the init() function receives a referrer parameter, this indicates that it has been called as a part of an AJAX request and
|
19
19
|
this.getReferrer() will not return the correct value. Therefore we need to rely on the referrer parameter. */
|
20
|
-
referrer: referrer
|
20
|
+
referrer: referrer ? this.PIIRemover.stripPIIWithOverride(referrer, true, true) : this.getReferrer(),
|
21
21
|
title: this.getTitle(),
|
22
22
|
status_code: this.getStatusCode(),
|
23
23
|
|
@@ -6,35 +6,6 @@ $govuk-new-link-styles: true;
|
|
6
6
|
@import "govuk_publishing_components/govuk_frontend_support";
|
7
7
|
@import "govuk_publishing_components/component_support";
|
8
8
|
|
9
|
-
// Import the same stylesheets used in static
|
10
|
-
// https://github.com/alphagov/static/blob/198a598682df40ce4a2c3c286c06244297c18cf0/app/assets/stylesheets/application.scss
|
11
|
-
// Although the component guide does not use static, we still need to import the same stylesheets used in static
|
12
|
-
// to avoid any rendering issues
|
13
|
-
// By following the same approach as frontend rendering applications,
|
14
|
-
// we ensure that stylesheets are loaded in the expected order and components render correctly
|
15
|
-
@import "govuk_publishing_components/components/breadcrumbs";
|
16
|
-
@import "govuk_publishing_components/components/button";
|
17
|
-
@import "govuk_publishing_components/components/error-message";
|
18
|
-
@import "govuk_publishing_components/components/heading";
|
19
|
-
@import "govuk_publishing_components/components/hint";
|
20
|
-
@import "govuk_publishing_components/components/input";
|
21
|
-
@import "govuk_publishing_components/components/label";
|
22
|
-
@import "govuk_publishing_components/components/search";
|
23
|
-
@import "govuk_publishing_components/components/skip-link";
|
24
|
-
@import "govuk_publishing_components/components/textarea";
|
25
|
-
@import "govuk_publishing_components/components/title";
|
26
|
-
|
27
|
-
@import "govuk_publishing_components/components/cookie-banner";
|
28
|
-
@import "govuk_publishing_components/components/feedback";
|
29
|
-
@import "govuk_publishing_components/components/layout-footer";
|
30
|
-
@import "govuk_publishing_components/components/layout-for-public";
|
31
|
-
@import "govuk_publishing_components/components/layout-header";
|
32
|
-
@import "govuk_publishing_components/components/layout-super-navigation-header";
|
33
|
-
|
34
|
-
// Imported to ensure inverse-header component examples render correctly
|
35
|
-
// this helps avoid any issues with visual regressions tests
|
36
|
-
@import "govuk_publishing_components/components/lead-paragraph";
|
37
|
-
|
38
9
|
// Include required helpers
|
39
10
|
@import "../../stylesheets/govuk_publishing_components/components/helpers/markdown-typography";
|
40
11
|
|
@@ -4,11 +4,3 @@
|
|
4
4
|
.gem-c-select__select--full-width {
|
5
5
|
width: 100%;
|
6
6
|
}
|
7
|
-
|
8
|
-
// Solution to text inside selects becoming unreadable if font size in
|
9
|
-
// the browser is increased. This is currently a problem in govuk-frontend
|
10
|
-
.gem-c-select {
|
11
|
-
.govuk-select {
|
12
|
-
height: 2.14em;
|
13
|
-
}
|
14
|
-
}
|
data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss
CHANGED
@@ -87,7 +87,9 @@
|
|
87
87
|
|
88
88
|
ol,
|
89
89
|
ul {
|
90
|
-
list-style
|
90
|
+
// we intentionally don't set list-style for ol elements, so that they can
|
91
|
+
// utilise the type attribute for the formatting. Browsers default to a
|
92
|
+
// style of decimal.
|
91
93
|
list-style-position: outside;
|
92
94
|
margin-left: $gutter-two-thirds;
|
93
95
|
padding: 0;
|
@@ -102,7 +104,6 @@
|
|
102
104
|
|
103
105
|
ul {
|
104
106
|
list-style: disc;
|
105
|
-
list-style-position: outside;
|
106
107
|
}
|
107
108
|
|
108
109
|
li {
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<table class="govuk-table"
|
1
|
+
<table class="govuk-table">
|
2
2
|
<thead class="govuk-table__head">
|
3
|
-
<tr class="govuk-table__row"
|
4
|
-
<th scope="col" class="govuk-table__header sticky-table-header">Component</th>
|
3
|
+
<tr class="govuk-table__row" <% if show_application_name %>data-audit-headings<% end %>>
|
4
|
+
<th scope="col" class="govuk-table__header sticky-table-header" data-component-type="total">Component</th>
|
5
5
|
<th scope="col" class="govuk-table__header sticky-table-header" data-component-type="template">
|
6
6
|
Template
|
7
7
|
<% unless show_application_name %>
|
@@ -46,10 +46,10 @@
|
|
46
46
|
</th>
|
47
47
|
</tr>
|
48
48
|
</thead>
|
49
|
-
<tbody class="govuk-table__body"
|
49
|
+
<tbody class="govuk-table__body" <% if show_application_name %>data-audit-list<% end %>>
|
50
50
|
<% passed_components[:component_file_details].each do |component| %>
|
51
51
|
<tr class="govuk-table__row" data-application="<%= component[:application] %>">
|
52
|
-
<th scope="row" class="govuk-table__header">
|
52
|
+
<th scope="row" class="govuk-table__header" data-component-type="total">
|
53
53
|
<% if component[:link] %>
|
54
54
|
<a href="<%= component[:link] %>" class="govuk-link">
|
55
55
|
<%= component[:name] %>
|
@@ -63,69 +63,57 @@
|
|
63
63
|
</span>
|
64
64
|
<% end %>
|
65
65
|
</th>
|
66
|
-
<td class="govuk-table__cell">
|
66
|
+
<td class="govuk-table__cell" data-component-type="template">
|
67
67
|
<% if component[:template_exists] %>
|
68
|
-
<
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
</a>
|
73
|
-
</strong>
|
68
|
+
<a href="<%= component[:template_link] %>" class="govuk-link">
|
69
|
+
<%= component[:template_lines] %>
|
70
|
+
<span class="govuk-visually-hidden">lines of code in <%= component[:name] %> template</span>
|
71
|
+
</a>
|
74
72
|
<% end %>
|
75
73
|
</td>
|
76
|
-
<td class="govuk-table__cell">
|
74
|
+
<td class="govuk-table__cell" data-component-type="stylesheet">
|
77
75
|
<% if component[:stylesheet_exists] %>
|
78
|
-
<
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
</a>
|
83
|
-
</strong>
|
76
|
+
<a href="<%= component[:stylesheet_link] %>" class="govuk-link">
|
77
|
+
<%= component[:stylesheet_lines] %>
|
78
|
+
<span class="govuk-visually-hidden">lines of code in <%= component[:name] %> stylesheet</span>
|
79
|
+
</a>
|
84
80
|
<% end %>
|
85
81
|
</td>
|
86
|
-
<td class="govuk-table__cell">
|
82
|
+
<td class="govuk-table__cell" data-component-type="print_stylesheet">
|
87
83
|
<% if component[:print_stylesheet_exists] %>
|
88
|
-
|
84
|
+
Yes
|
89
85
|
<% end %>
|
90
86
|
</td>
|
91
|
-
<td class="govuk-table__cell">
|
87
|
+
<td class="govuk-table__cell" data-component-type="javascript">
|
92
88
|
<% if component[:javascript_exists] %>
|
93
|
-
<
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
</a>
|
98
|
-
</strong>
|
89
|
+
<a href="<%= component[:javascript_link] %>" class="govuk-link">
|
90
|
+
<%= component[:javascript_lines] %>
|
91
|
+
<span class="govuk-visually-hidden">lines of code in <%= component[:name] %> javascript</span>
|
92
|
+
</a>
|
99
93
|
<% end %>
|
100
94
|
</td>
|
101
|
-
<td class="govuk-table__cell">
|
95
|
+
<td class="govuk-table__cell" data-component-type="test">
|
102
96
|
<% if component[:test_exists] %>
|
103
|
-
<
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
</a>
|
108
|
-
</strong>
|
97
|
+
<a href="<%= component[:test_link] %>" class="govuk-link">
|
98
|
+
<%= component[:test_lines] %>
|
99
|
+
<span class="govuk-visually-hidden">lines of code in <%= component[:name] %> test</span>
|
100
|
+
</a>
|
109
101
|
<% end %>
|
110
102
|
</td>
|
111
|
-
<td class="govuk-table__cell">
|
103
|
+
<td class="govuk-table__cell" data-component-type="javascript_test">
|
112
104
|
<% if component[:javascript_test_exists] %>
|
113
|
-
<
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
</a>
|
118
|
-
</strong>
|
105
|
+
<a href="<%= component[:javascript_test_link] %>" class="govuk-link">
|
106
|
+
<%= component[:javascript_test_lines] %>
|
107
|
+
<span class="govuk-visually-hidden">lines of code in <%= component[:name] %> javascript test</span>
|
108
|
+
</a>
|
119
109
|
<% end %>
|
120
110
|
</td>
|
121
|
-
<td class="govuk-table__cell">
|
111
|
+
<td class="govuk-table__cell" data-component-type="helper">
|
122
112
|
<% if component[:helper_exists] %>
|
123
|
-
<
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
</a>
|
128
|
-
</strong>
|
113
|
+
<a href="<%= component[:helper_link] %>" class="govuk-link">
|
114
|
+
<%= component[:helper_lines] %>
|
115
|
+
<span class="govuk-visually-hidden">lines of code in <%= component[:name] %> helper</span>
|
116
|
+
</a>
|
129
117
|
<% end %>
|
130
118
|
</td>
|
131
119
|
</tr>
|
@@ -9,30 +9,44 @@
|
|
9
9
|
data_attributes ||= {}
|
10
10
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
case attachment.type
|
13
|
+
when "file"
|
14
|
+
if attachment.content_type_name
|
15
|
+
content = if attachment.content_type_abbr
|
16
|
+
raw tag.abbr(attachment.content_type.abbr,
|
17
|
+
title: attachment.content_type_name,
|
18
|
+
class: "gem-c-attachment__abbr")
|
19
|
+
else
|
20
|
+
attachment.content_type_name
|
21
|
+
end
|
22
|
+
attributes << tag.span(content, class: "gem-c-attachment__attribute")
|
23
|
+
end
|
24
|
+
|
25
|
+
if attachment.file_size
|
26
|
+
attributes << tag.span(
|
27
|
+
number_to_human_size(attachment.file_size),
|
28
|
+
class: "gem-c-attachment__attribute",
|
29
|
+
)
|
30
|
+
end
|
22
31
|
|
23
|
-
|
32
|
+
if attachment.number_of_pages
|
33
|
+
attributes << tag.span(
|
34
|
+
t("components.attachment.page", count: attachment.number_of_pages),
|
35
|
+
class: "gem-c-attachment__attribute",
|
36
|
+
)
|
37
|
+
end
|
38
|
+
when "html"
|
24
39
|
attributes << tag.span(
|
25
|
-
|
40
|
+
"HTML",
|
26
41
|
class: "gem-c-attachment__attribute",
|
27
42
|
)
|
28
|
-
|
29
|
-
|
30
|
-
if attachment.number_of_pages
|
43
|
+
when "external"
|
31
44
|
attributes << tag.span(
|
32
|
-
|
45
|
+
attachment.url,
|
33
46
|
class: "gem-c-attachment__attribute",
|
34
47
|
)
|
35
48
|
end
|
49
|
+
|
36
50
|
%>
|
37
51
|
<%= tag.section class: "gem-c-attachment govuk-!-display-none-print" do %>
|
38
52
|
<%= tag.div class: "gem-c-attachment__thumbnail" do %>
|
@@ -42,8 +56,10 @@
|
|
42
56
|
tabindex: "-1",
|
43
57
|
"aria-hidden": true,
|
44
58
|
data: data_attributes do %>
|
45
|
-
<% if attachment.thumbnail_url %>
|
46
|
-
<% image_tag(attachment.thumbnail_url, alt: "") %>
|
59
|
+
<% if attachment.thumbnail_url.present? %>
|
60
|
+
<% image_tag(attachment.thumbnail_url, alt: "", class: "gem-c-attachment__thumbnail-image gem-c-attachment__thumbnail-image--custom") %>
|
61
|
+
<% elsif attachment.html? %>
|
62
|
+
<%= render "govuk_publishing_components/components/attachment/thumbnail_html" %>
|
47
63
|
<% elsif attachment.document? %>
|
48
64
|
<%= render "govuk_publishing_components/components/attachment/thumbnail_document" %>
|
49
65
|
<% elsif attachment.spreadsheet? %>
|
@@ -74,6 +90,10 @@
|
|
74
90
|
<%= tag.p raw(attributes.join(', ')), class: "gem-c-attachment__metadata" %>
|
75
91
|
<% end %>
|
76
92
|
|
93
|
+
<% if attachment.preview_url.present? %>
|
94
|
+
<%= tag.p link_to(t("components.attachment.preview_link"), attachment.preview_url, class: "govuk-link"), class: "gem-c-attachment__metadata" %>
|
95
|
+
<% end %>
|
96
|
+
|
77
97
|
<% if attachment.is_official_document && !hide_order_copy_link %>
|
78
98
|
<%= tag.p link_to(t("components.attachment.order_a_copy"), "https://www.gov.uk/guidance/how-to-buy-printed-copies-of-official-documents", class: "govuk-link govuk-link--no-visited-state", target: "_blank"),
|
79
99
|
class: "gem-c-attachment__metadata" %>
|
@@ -1,6 +1,4 @@
|
|
1
1
|
<%
|
2
|
-
add_gem_component_stylesheet("character-count")
|
3
|
-
|
4
2
|
id ||= "character-count-#{SecureRandom.hex(4)}"
|
5
3
|
maxlength ||= nil
|
6
4
|
maxwords ||= nil
|
@@ -24,3 +22,7 @@
|
|
24
22
|
</div>
|
25
23
|
<% end %>
|
26
24
|
<% end %>
|
25
|
+
<%
|
26
|
+
add_gem_component_stylesheet("error-message")
|
27
|
+
add_gem_component_stylesheet("character-count")
|
28
|
+
%>
|
@@ -12,10 +12,21 @@
|
|
12
12
|
link_classes << brand_helper.color_class
|
13
13
|
link_classes << "govuk-link--no-underline" unless underline_links
|
14
14
|
|
15
|
+
ga4_tracking ||= false
|
16
|
+
ga4_data = nil
|
17
|
+
if ga4_tracking
|
18
|
+
ga4_data = {
|
19
|
+
event_name: "navigation",
|
20
|
+
type: "content",
|
21
|
+
section: t("components.contents_list.contents", locale: :en) || ""
|
22
|
+
}.to_json
|
23
|
+
end
|
15
24
|
local_assigns[:aria] ||= {}
|
16
25
|
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
17
26
|
component_helper.add_class("gem-c-contents-list #{brand_helper.brand_class}")
|
18
27
|
component_helper.add_data_attribute({ module: "gem-track-click" })
|
28
|
+
component_helper.add_data_attribute({ module: "ga4-link-tracker" }) if ga4_tracking
|
29
|
+
component_helper.add_data_attribute({ ga4_link: ga4_data, ga4_track_links_only: "" }) if ga4_tracking
|
19
30
|
component_helper.add_aria_attribute({ label: t("components.contents_list.contents") }) unless local_assigns[:aria][:label]
|
20
31
|
component_helper.add_role("navigation")
|
21
32
|
-%>
|
@@ -32,7 +43,10 @@
|
|
32
43
|
<ol class="gem-c-contents-list__list">
|
33
44
|
<% contents.each.with_index(1) do |contents_item, position| %>
|
34
45
|
<li class="<%= cl_helper.list_item_classes(contents_item, false) %>" <%= "aria-current=true" if contents_item[:active] %>>
|
35
|
-
<% link_text = format_numbers ? cl_helper.wrap_numbers_with_spans(contents_item[:text]) : contents_item[:text]
|
46
|
+
<% link_text = format_numbers ? cl_helper.wrap_numbers_with_spans(contents_item[:text]) : contents_item[:text]
|
47
|
+
ga4_link_data = nil
|
48
|
+
ga4_link_data = { "index": { "index_link": position }, "index_total": contents.length }.to_json if ga4_tracking
|
49
|
+
%>
|
36
50
|
<%= link_to_if !contents_item[:active], link_text, contents_item[:href],
|
37
51
|
class: link_classes,
|
38
52
|
data: {
|
@@ -41,7 +55,8 @@
|
|
41
55
|
track_label: contents_item[:href],
|
42
56
|
track_options: {
|
43
57
|
dimension29: contents_item[:text]
|
44
|
-
}
|
58
|
+
},
|
59
|
+
ga4_link: ga4_link_data
|
45
60
|
}
|
46
61
|
%>
|
47
62
|
|
data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
<%
|
2
|
+
add_gem_component_stylesheet("layout-header")
|
2
3
|
add_gem_component_stylesheet("layout-super-navigation-header")
|
3
4
|
|
4
5
|
logo_link ||= "https://www.gov.uk/"
|
@@ -38,7 +39,9 @@
|
|
38
39
|
"text": "GOV.UK",
|
39
40
|
"section": "Logo",
|
40
41
|
"index": {
|
42
|
+
"index_link": 1,
|
41
43
|
"index_section": 0,
|
44
|
+
"index_section_count": 2,
|
42
45
|
},
|
43
46
|
"index_total": 1
|
44
47
|
}.to_json %>"
|
@@ -18,6 +18,8 @@
|
|
18
18
|
classes << "direction-#{direction}" if local_assigns.include?(:direction)
|
19
19
|
classes << "gem-c-metadata--inverse" if inverse
|
20
20
|
classes << shared_helper.get_margin_bottom if local_assigns[:margin_bottom]
|
21
|
+
|
22
|
+
ga4_tracking ||= false
|
21
23
|
%>
|
22
24
|
<%= content_tag :div, class: classes, data: { module: "gem-toggle metadata" } do %>
|
23
25
|
<dl class="gem-c-metadata__list" data-module="gem-track-click">
|
@@ -49,7 +51,16 @@
|
|
49
51
|
— <a href="#full-publication-update-history" class="gem-c-metadata__definition-link govuk-!-display-none-print js-see-all-updates-link"
|
50
52
|
data-track-category="content-history"
|
51
53
|
data-track-action="see-all-updates-link-clicked"
|
52
|
-
data-track-label="history"
|
54
|
+
data-track-label="history"
|
55
|
+
<% if ga4_tracking %>
|
56
|
+
data-module="ga4-link-tracker"
|
57
|
+
data-ga4-link="<%= {
|
58
|
+
event_name: "navigation",
|
59
|
+
type: "content",
|
60
|
+
section: "Top"
|
61
|
+
}.to_json %>"
|
62
|
+
<% end%>
|
63
|
+
>
|
53
64
|
<%= t("components.metadata.see_all_updates") %>
|
54
65
|
</a>
|
55
66
|
<% end %>
|