govuk_publishing_components 44.9.1 → 44.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-search-tracker.js +73 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_chart.scss +15 -0
- data/app/views/govuk_publishing_components/components/_chart.html.erb +17 -2
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +6 -12
- data/app/views/govuk_publishing_components/components/docs/chart.yml +37 -0
- data/config/locales/ar.yml +2 -0
- data/config/locales/az.yml +2 -0
- data/config/locales/be.yml +2 -0
- data/config/locales/bg.yml +2 -0
- data/config/locales/bn.yml +2 -0
- data/config/locales/cs.yml +2 -0
- data/config/locales/cy.yml +2 -0
- data/config/locales/da.yml +2 -0
- data/config/locales/de.yml +2 -0
- data/config/locales/dr.yml +2 -0
- data/config/locales/el.yml +2 -0
- data/config/locales/en.yml +3 -1
- data/config/locales/es-419.yml +2 -0
- data/config/locales/es.yml +2 -0
- data/config/locales/et.yml +2 -0
- data/config/locales/fa.yml +2 -0
- data/config/locales/fi.yml +2 -0
- data/config/locales/fr.yml +2 -0
- data/config/locales/gd.yml +2 -0
- data/config/locales/gu.yml +2 -0
- data/config/locales/he.yml +2 -0
- data/config/locales/hi.yml +2 -0
- data/config/locales/hr.yml +2 -0
- data/config/locales/hu.yml +2 -0
- data/config/locales/hy.yml +2 -0
- data/config/locales/id.yml +2 -0
- data/config/locales/is.yml +2 -0
- data/config/locales/it.yml +2 -0
- data/config/locales/ja.yml +2 -0
- data/config/locales/ka.yml +2 -0
- data/config/locales/kk.yml +2 -0
- data/config/locales/ko.yml +2 -0
- data/config/locales/lt.yml +2 -0
- data/config/locales/lv.yml +2 -0
- data/config/locales/ms.yml +2 -0
- data/config/locales/mt.yml +2 -0
- data/config/locales/nl.yml +2 -0
- data/config/locales/no.yml +2 -0
- data/config/locales/pa-pk.yml +2 -0
- data/config/locales/pa.yml +2 -0
- data/config/locales/pl.yml +2 -0
- data/config/locales/ps.yml +2 -0
- data/config/locales/pt.yml +2 -0
- data/config/locales/ro.yml +2 -0
- data/config/locales/ru.yml +2 -0
- data/config/locales/si.yml +2 -0
- data/config/locales/sk.yml +2 -0
- data/config/locales/sl.yml +2 -0
- data/config/locales/so.yml +2 -0
- data/config/locales/sq.yml +2 -0
- data/config/locales/sr.yml +2 -0
- data/config/locales/sv.yml +2 -0
- data/config/locales/sw.yml +2 -0
- data/config/locales/ta.yml +2 -0
- data/config/locales/th.yml +2 -0
- data/config/locales/tk.yml +2 -0
- data/config/locales/tr.yml +2 -0
- data/config/locales/uk.yml +2 -0
- data/config/locales/ur.yml +2 -0
- data/config/locales/uz.yml +2 -0
- data/config/locales/vi.yml +2 -0
- data/config/locales/zh-hk.yml +2 -0
- data/config/locales/zh-tw.yml +2 -0
- data/config/locales/zh.yml +2 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f4db62d52d8c311f54f21051c42fc89884500067e38c2811bac64a7ab8bf084
|
4
|
+
data.tar.gz: 96a578c2b154bd53f006a527ec1a075949f636162e999edcf9499cfb6b29705d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c64c3dacd3f123635c3d3de5fd7a43522541480171c3c643ee94e83d9bd974ed0c7368621943b8e0cef7052f3f3ea1a65acf6f1483982b505747c09ae0f82caa
|
7
|
+
data.tar.gz: 953bffaefdd0ca1141e5a5ba4fd37f7af96fa3b96f25879eb1e3167656945848d6db077954a11b89daa435218a9426fdb1eb151f4f123f21616dece1a65567c5
|
@@ -0,0 +1,73 @@
|
|
1
|
+
window.GOVUK = window.GOVUK || {}
|
2
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
3
|
+
(function (Modules) {
|
4
|
+
'use strict'
|
5
|
+
// Tracks interactions with search forms, including on the all content finder ("site search"),
|
6
|
+
// homepage, and the layout super navigation header search.
|
7
|
+
class Ga4SearchTracker {
|
8
|
+
constructor ($module) {
|
9
|
+
this.$module = $module
|
10
|
+
this.$searchInput = this.$module.querySelector('input[type="search"]')
|
11
|
+
|
12
|
+
this.type = this.$module.dataset.ga4SearchType
|
13
|
+
this.url = this.$module.dataset.ga4SearchUrl
|
14
|
+
this.section = this.$module.dataset.ga4SearchSection
|
15
|
+
this.indexSection = this.$module.dataset.ga4SearchIndexSection
|
16
|
+
this.indexSectionCount = this.$module.dataset.ga4SearchIndexSectionCount
|
17
|
+
}
|
18
|
+
|
19
|
+
init () {
|
20
|
+
if (!this.$searchInput) {
|
21
|
+
console.warn('Ga4SearchTracker: Module added to element without child search input')
|
22
|
+
return
|
23
|
+
}
|
24
|
+
|
25
|
+
this.initialKeywords = this.$searchInput.value
|
26
|
+
|
27
|
+
if (window.GOVUK.getConsentCookie() && window.GOVUK.getConsentCookie().usage) {
|
28
|
+
this.startModule()
|
29
|
+
} else {
|
30
|
+
window.addEventListener('cookie-consent', () => this.startModule())
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
startModule () {
|
35
|
+
this.$module.addEventListener('submit', event => this.trackSearch(event))
|
36
|
+
}
|
37
|
+
|
38
|
+
trackSearch () {
|
39
|
+
if (this.skipTracking()) return
|
40
|
+
|
41
|
+
const data = {
|
42
|
+
event_name: 'search',
|
43
|
+
action: 'search',
|
44
|
+
|
45
|
+
type: this.type,
|
46
|
+
section: this.section,
|
47
|
+
url: this.url,
|
48
|
+
index_section: this.indexSection,
|
49
|
+
index_section_count: this.indexSectionCount,
|
50
|
+
text: this.searchTerm()
|
51
|
+
}
|
52
|
+
|
53
|
+
window.GOVUK.analyticsGa4.core.applySchemaAndSendData(data, 'event_data')
|
54
|
+
}
|
55
|
+
|
56
|
+
skipTracking () {
|
57
|
+
// Skip tracking for those events that we do not want to track: where the search term is
|
58
|
+
// present, but has not changed from its initial value
|
59
|
+
return this.searchTerm() !== '' && this.searchTerm() === this.initialKeywords
|
60
|
+
}
|
61
|
+
|
62
|
+
searchTerm () {
|
63
|
+
const { standardiseSearchTerm } = window.GOVUK.analyticsGa4.core.trackFunctions
|
64
|
+
|
65
|
+
// `standardiseSearchTerm` returns undefined for empty strings, whereas we actively want an
|
66
|
+
// empty string as part of search events (undefined would not overwrite the current value in
|
67
|
+
// the analytics state)
|
68
|
+
return standardiseSearchTerm(this.$searchInput.value) || ''
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
Modules.Ga4SearchTracker = Ga4SearchTracker
|
73
|
+
})(window.GOVUK.Modules)
|
@@ -13,6 +13,7 @@
|
|
13
13
|
//= require ./analytics-ga4/ga4-auto-tracker
|
14
14
|
//= require ./analytics-ga4/ga4-smart-answer-results-tracker
|
15
15
|
//= require ./analytics-ga4/ga4-scroll-tracker
|
16
|
+
//= require ./analytics-ga4/ga4-search-tracker
|
16
17
|
//= require ./analytics-ga4/ga4-video-tracker
|
17
18
|
//= require ./analytics-ga4/ga4-focus-loss-tracker
|
18
19
|
//= require ./analytics-ga4/init-ga4
|
@@ -47,3 +47,18 @@
|
|
47
47
|
padding: 0 govuk-spacing(4);
|
48
48
|
}
|
49
49
|
}
|
50
|
+
|
51
|
+
.gem-c-chart .gem-c-chart__a11y-note-link {
|
52
|
+
display: none;
|
53
|
+
margin-bottom: govuk-spacing(2);
|
54
|
+
}
|
55
|
+
|
56
|
+
.js-enabled {
|
57
|
+
.gem-c-chart .gem-c-chart__a11y-note-link {
|
58
|
+
display: inline;
|
59
|
+
}
|
60
|
+
|
61
|
+
.gem-c-chart .gem-c-chart__a11y-note-link:focus-within {
|
62
|
+
display: inline-block;
|
63
|
+
}
|
64
|
+
}
|
@@ -3,6 +3,7 @@
|
|
3
3
|
add_gem_component_stylesheet("table")
|
4
4
|
add_gem_component_stylesheet("details")
|
5
5
|
add_gem_component_stylesheet("heading")
|
6
|
+
add_gem_component_stylesheet("skip-link")
|
6
7
|
|
7
8
|
chart_heading ||= nil
|
8
9
|
chart_heading_level ||= 2
|
@@ -13,6 +14,7 @@
|
|
13
14
|
keys ||= []
|
14
15
|
chart_overview ||= nil
|
15
16
|
minimal ||= false
|
17
|
+
hide_heading ||= minimal
|
16
18
|
hide_legend ||= minimal
|
17
19
|
link ||= false
|
18
20
|
height ||= 400
|
@@ -44,6 +46,10 @@
|
|
44
46
|
textPosition = nil
|
45
47
|
textPosition = 'none' if minimal
|
46
48
|
|
49
|
+
if !minimal && !chart_heading
|
50
|
+
raise ArgumentError, "A chart heading must be provided for accessibility purposes."
|
51
|
+
end
|
52
|
+
|
47
53
|
chart_library_options = {
|
48
54
|
chartArea: { width: '80%', height: '60%' },
|
49
55
|
crosshair: { orientation: 'vertical', trigger: 'both', color: '#ccc' },
|
@@ -82,7 +88,7 @@
|
|
82
88
|
<% if rows.length > 0 && keys.length > 0 %>
|
83
89
|
<%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" if @external_script[:loaded] == 1 %>
|
84
90
|
<%= tag.div(**component_helper.all_attributes) do %>
|
85
|
-
<% if chart_heading && !
|
91
|
+
<% if chart_heading && !hide_heading %>
|
86
92
|
<div class="gem-c-chart__header">
|
87
93
|
<%= render "govuk_publishing_components/components/heading", {
|
88
94
|
text: chart_heading,
|
@@ -97,8 +103,14 @@
|
|
97
103
|
<% unless minimal %>
|
98
104
|
<div class="govuk-visually-hidden">
|
99
105
|
<%= content_tag :div, chart_overview, class: "gem-c-chart__a11y-note-1" if chart_overview %>
|
100
|
-
<%= content_tag :div, t("components.chart.accessibility_html"
|
106
|
+
<%= content_tag :div, t("components.chart.accessibility_html"), class: "gem-c-chart__a11y-note-2" %>
|
101
107
|
</div>
|
108
|
+
<span class="gem-c-chart__a11y-note-link">
|
109
|
+
<%= render "govuk_publishing_components/components/skip_link", {
|
110
|
+
text: t("components.chart.accessibility_link", chart_heading: chart_heading),
|
111
|
+
href: "##{table_id}"
|
112
|
+
} %>
|
113
|
+
</span>
|
102
114
|
<% end %>
|
103
115
|
|
104
116
|
<%= line_chart(chart_format_data, library: chart_library_options) %>
|
@@ -112,6 +124,9 @@
|
|
112
124
|
) do %>
|
113
125
|
<div tabindex="0" class="gem-c-chart__table-wrapper">
|
114
126
|
<table class="govuk-table">
|
127
|
+
<caption class="govuk-visually-hidden" id="<%= "data-table-caption-#{SecureRandom.hex(4)}" %>">
|
128
|
+
<%= t("components.chart.accessibility_heading", chart_heading: chart_heading) %>
|
129
|
+
</caption>
|
115
130
|
<% if table_direction == "horizontal" %>
|
116
131
|
<thead class="govuk-table__head">
|
117
132
|
<tr class="govuk-table__row">
|
data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb
CHANGED
@@ -303,18 +303,12 @@
|
|
303
303
|
class: "gem-c-layout-super-navigation-header__search-form",
|
304
304
|
id: "search",
|
305
305
|
data: {
|
306
|
-
module: "ga4-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
url: "/search/all",
|
313
|
-
index_section: 3,
|
314
|
-
index_section_count: 3,
|
315
|
-
},
|
316
|
-
ga4_form_include_text: "",
|
317
|
-
ga4_form_no_answer_undefined: "",
|
306
|
+
module: "ga4-search-tracker",
|
307
|
+
ga4_search_type: "header menu bar",
|
308
|
+
ga4_search_url: "/search/all",
|
309
|
+
ga4_search_section: "Search GOV.UK",
|
310
|
+
ga4_search_index_section: 3,
|
311
|
+
ga4_search_index_section_count: 3,
|
318
312
|
},
|
319
313
|
action: absolute_links_helper.make_url_absolute("/search/all"),
|
320
314
|
method: "get",
|
@@ -11,6 +11,7 @@ accessibility_criteria: |
|
|
11
11
|
Charts must:
|
12
12
|
|
13
13
|
- use line colours with a contrast ratio higher than 4.5:1 against the background colour to meet WCAG AA
|
14
|
+
- contain a `chart_heading` option if `minimal` is not set to true, so that skip links and visually hidden headings are accurate
|
14
15
|
shared_accessibility_criteria:
|
15
16
|
- link
|
16
17
|
uses_component_wrapper_helper: true
|
@@ -361,4 +362,40 @@ examples:
|
|
361
362
|
- 118
|
362
363
|
- 85
|
363
364
|
- 80
|
365
|
+
with_hidden_heading:
|
366
|
+
description: |
|
367
|
+
The heading element is optional, allowing a heading to be set outside the component. Hiding the heading doesn't remove the need to populate `chart_heading` with text, as `chart_heading` is needed for accessibility.
|
368
|
+
data:
|
369
|
+
chart_heading: Page views
|
370
|
+
hide_heading: true
|
371
|
+
h_axis_title: Day
|
372
|
+
v_axis_title: Views
|
373
|
+
chart_overview: This is a graph of views per day
|
374
|
+
keys:
|
375
|
+
- 1st
|
376
|
+
- 2nd
|
377
|
+
- 3rd
|
378
|
+
- 4th
|
379
|
+
- 5th
|
380
|
+
- 6th
|
381
|
+
- 7th
|
382
|
+
rows:
|
383
|
+
- label: January 2015
|
384
|
+
values:
|
385
|
+
- 5
|
386
|
+
- 119
|
387
|
+
- 74
|
388
|
+
- 117
|
389
|
+
- 33
|
390
|
+
- 89
|
391
|
+
- 79
|
392
|
+
- label: January 2016
|
393
|
+
values:
|
394
|
+
- 3
|
395
|
+
- 8
|
396
|
+
- 37
|
397
|
+
- 82
|
398
|
+
- 118
|
399
|
+
- 85
|
400
|
+
- 80
|
364
401
|
|
data/config/locales/ar.yml
CHANGED
data/config/locales/az.yml
CHANGED
data/config/locales/be.yml
CHANGED
data/config/locales/bg.yml
CHANGED
data/config/locales/bn.yml
CHANGED
data/config/locales/cs.yml
CHANGED
data/config/locales/cy.yml
CHANGED
data/config/locales/da.yml
CHANGED
data/config/locales/de.yml
CHANGED
data/config/locales/dr.yml
CHANGED
data/config/locales/el.yml
CHANGED
data/config/locales/en.yml
CHANGED
@@ -34,7 +34,9 @@ en:
|
|
34
34
|
words: words
|
35
35
|
chart:
|
36
36
|
table_dropdown: Data table
|
37
|
-
accessibility_html: This chart is a visual representation of the data available in the
|
37
|
+
accessibility_html: This chart is a visual representation of the data available in the table.
|
38
|
+
accessibility_link: Skip to "%{chart_heading}" data table
|
39
|
+
accessibility_heading: Data table for "%{chart_heading}"
|
38
40
|
chat_entry:
|
39
41
|
heading: Try GOV.UK Chat
|
40
42
|
description: Sign up to GOV.UK’s experimental new AI tool and find answers to your business questions
|
data/config/locales/es-419.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/et.yml
CHANGED
data/config/locales/fa.yml
CHANGED
data/config/locales/fi.yml
CHANGED
data/config/locales/fr.yml
CHANGED
data/config/locales/gd.yml
CHANGED
data/config/locales/gu.yml
CHANGED
data/config/locales/he.yml
CHANGED
data/config/locales/hi.yml
CHANGED
data/config/locales/hr.yml
CHANGED
data/config/locales/hu.yml
CHANGED
data/config/locales/hy.yml
CHANGED
data/config/locales/id.yml
CHANGED
data/config/locales/is.yml
CHANGED
data/config/locales/it.yml
CHANGED
data/config/locales/ja.yml
CHANGED
data/config/locales/ka.yml
CHANGED
data/config/locales/kk.yml
CHANGED
data/config/locales/ko.yml
CHANGED
data/config/locales/lt.yml
CHANGED
data/config/locales/lv.yml
CHANGED
data/config/locales/ms.yml
CHANGED
data/config/locales/mt.yml
CHANGED
data/config/locales/nl.yml
CHANGED
data/config/locales/no.yml
CHANGED
data/config/locales/pa-pk.yml
CHANGED
data/config/locales/pa.yml
CHANGED
data/config/locales/pl.yml
CHANGED
data/config/locales/ps.yml
CHANGED
data/config/locales/pt.yml
CHANGED
data/config/locales/ro.yml
CHANGED
data/config/locales/ru.yml
CHANGED
data/config/locales/si.yml
CHANGED
data/config/locales/sk.yml
CHANGED
data/config/locales/sl.yml
CHANGED
data/config/locales/so.yml
CHANGED
data/config/locales/sq.yml
CHANGED
data/config/locales/sr.yml
CHANGED
data/config/locales/sv.yml
CHANGED
data/config/locales/sw.yml
CHANGED
data/config/locales/ta.yml
CHANGED
data/config/locales/th.yml
CHANGED
data/config/locales/tk.yml
CHANGED
data/config/locales/tr.yml
CHANGED
data/config/locales/uk.yml
CHANGED
data/config/locales/ur.yml
CHANGED
data/config/locales/uz.yml
CHANGED
data/config/locales/vi.yml
CHANGED
data/config/locales/zh-hk.yml
CHANGED
data/config/locales/zh-tw.yml
CHANGED
data/config/locales/zh.yml
CHANGED
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: 44.
|
4
|
+
version: 44.11.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: 2024-
|
11
|
+
date: 2024-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|
@@ -455,6 +455,7 @@ files:
|
|
455
455
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-print-intent-tracker.js
|
456
456
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js
|
457
457
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-scroll-tracker.js
|
458
|
+
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-search-tracker.js
|
458
459
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-smart-answer-results-tracker.js
|
459
460
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js
|
460
461
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-video-tracker.js
|