govuk_publishing_components 35.15.2 → 35.15.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e84a39ca858aeb5f82b99db7e36787fcb9de0789d216a01ae705edc8b6412e50
4
- data.tar.gz: cd621c972ba4b393cd8ca2921a43e45101dcdd1330c5d1dc80eee74b11ac1556
3
+ metadata.gz: c5baadeb72cff594caeffb0d791d32d3d32a6135dd93bd1c6b8190ba01997865
4
+ data.tar.gz: '078f9bf537fe6341f5bd7d6fb859be1859d9832ad62d8cac2438c5ad5ae06b13'
5
5
  SHA512:
6
- metadata.gz: ac457ab2307e9a0c5e38b494b54268c34113521a93e25d1d0bc99378b075b8ae8a9a3ba4477a6dc7249fc58e1d42be51600f3746019109eff8b31460d3ae8a6d
7
- data.tar.gz: 8369bcf1d142762cd85e4c5e9a483560b1e904071dd73e500407c8abfffa692cc7f60745debae002861850a08a170a1fbc90c5b0ae7f72abe972e5ba089de898
6
+ metadata.gz: 03131a4e41598a5f770f188d50a8e8ac3625d2b063ab47e2cc3485a3b5611aa6367af68093c33ac315d8a1b4d956ac8921080a1b7b9e93d0f12c1e8507b684e1
7
+ data.tar.gz: ecbb58fc79d2026ea8f096d93803addf0ce5d75ac30ff4e6fb00a0e86fbe3eab7ce2a78b9a332a7ddc90ef69ab16ee14b8d3b8b2a69d767d678e48a1f78dc985
@@ -290,7 +290,8 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
290
290
 
291
291
  // In order to extract the number of results from resultCount (which is a string at this point (e.g. '12,345 results')), we remove the comma and
292
292
  // split string at the space character so it can be parsed as an integer
293
- resultCount = resultCount.textContent.replace(',', '')
293
+ resultCount = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(resultCount.textContent)
294
+ resultCount = resultCount.replace(',', '')
294
295
  resultCount = resultCount.split(' ')[0]
295
296
 
296
297
  return parseInt(resultCount)
@@ -57,7 +57,9 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
57
57
  emergency_banner: document.querySelector('[data-ga4-emergency-banner]') ? 'true' : undefined,
58
58
  phase_banner: this.getElementAttribute('data-ga4-phase-banner') || undefined,
59
59
  devolved_nations_banner: this.getElementAttribute('data-ga4-devolved-nations-banner') || undefined,
60
- cookie_banner: document.querySelector('[data-ga4-cookie-banner]') ? 'true' : undefined
60
+ cookie_banner: document.querySelector('[data-ga4-cookie-banner]') ? 'true' : undefined,
61
+ intervention: this.getInterventionPresence(),
62
+ query_string: this.getQueryString()
61
63
  }
62
64
  }
63
65
  window.GOVUK.analyticsGa4.core.sendData(data)
@@ -68,6 +70,20 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
68
70
  return this.PIIRemover.stripPII(this.stripGaParam(document.location.href))
69
71
  },
70
72
 
73
+ getSearch: function () {
74
+ return window.location.search
75
+ },
76
+
77
+ getQueryString: function () {
78
+ var queryString = this.getSearch()
79
+ if (queryString) {
80
+ queryString = this.PIIRemover.stripPIIWithOverride(queryString, true, true)
81
+ queryString = this.stripGaParam(queryString)
82
+ queryString = queryString.substring(1) // removes the '?' character from the start.
83
+ return queryString
84
+ }
85
+ },
86
+
71
87
  getReferrer: function (referrer) {
72
88
  referrer = this.stripGaParam(referrer || document.referrer)
73
89
  return this.PIIRemover.stripPIIWithOverride(referrer, true, true)
@@ -76,7 +92,7 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
76
92
  // remove GA parameters of the form _ga=2320.021-012302 or _gl=02.10320.01230-123
77
93
  stripGaParam: function (str) {
78
94
  str = str.replace(/(_ga=[0-9.-]+)/g, '_ga=[id]')
79
- str = str.replace(/(_gl=[0-9.-]+)/g, '_gl=[id]')
95
+ str = str.replace(/(_gl=[a-zA-Z0-9._\-*]+)/g, '_gl=[id]')
80
96
  return str
81
97
  },
82
98
 
@@ -112,11 +128,12 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
112
128
 
113
129
  getLanguage: function () {
114
130
  var content = document.getElementById('content')
131
+ var html = document.querySelector('html')
115
132
  if (content) {
116
133
  return content.getAttribute('lang') || this.nullValue
117
- } else {
118
- return this.nullValue
119
134
  }
135
+ // html.getAttribute('lang') is untested - Jasmine would not allow lang to be set on <html>.
136
+ return html.getAttribute('lang') || this.nullValue
120
137
  },
121
138
 
122
139
  getHistory: function () {
@@ -129,6 +146,25 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
129
146
  return (withdrawn === 'withdrawn') ? 'true' : 'false'
130
147
  },
131
148
 
149
+ getInterventionPresence: function () {
150
+ /* If the user hides the banner using JS, a cookie is set to hide it on future page loads.
151
+ * Therefore we need to start the intervention banner early so that it hides if this cookie exists.
152
+ * Without this, our pageview object will track the banner as visible before it gets hidden. */
153
+
154
+ var intervention = document.querySelector('[data-ga4-intervention-banner]')
155
+
156
+ if (intervention) {
157
+ window.GOVUK.modules.start(intervention)
158
+ var interventionHidden = intervention.getAttribute('hidden') === '' || intervention.getAttribute('hidden')
159
+
160
+ if (interventionHidden) {
161
+ return undefined
162
+ }
163
+ return 'true'
164
+ }
165
+ return undefined
166
+ },
167
+
132
168
  splitLongMetaContent: function (metatag) {
133
169
  var tag = this.getMetaContent(metatag)
134
170
  if (tag) {
@@ -150,6 +150,22 @@
150
150
  }
151
151
  }
152
152
 
153
+ .gem-c-action-link--dark-large-icon {
154
+ &:before {
155
+ background: image-url("govuk_publishing_components/action-link-arrow--dark.png");
156
+ background: image-url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
157
+ height: 34px;
158
+ width: 40px;
159
+ background-repeat: no-repeat;
160
+ background-size: 32px auto;
161
+ background-position: 0 2px;
162
+ }
163
+
164
+ @include govuk-media-query($until: tablet) {
165
+ margin-bottom: govuk-spacing(2);
166
+ }
167
+ }
168
+
153
169
  .gem-c-action-link--dark-icon,
154
170
  .gem-c-action-link--small-icon {
155
171
  max-width: none;
@@ -13,11 +13,8 @@
13
13
  margin: 0 govuk-spacing(-3);
14
14
 
15
15
  display: grid;
16
- grid-auto-flow: row;
17
- // Use CSS grid to calculate the number of rows
18
- grid-template-rows: auto;
19
- // Use the tallest cell in the grid to set the height for all rows
20
- grid-auto-rows: fractions(1);
16
+ grid-auto-flow: row; // Use CSS grid to calculate the number of rows
17
+ grid-auto-rows: fractions(1); // Set all rows to same fractional height of the complete grid
21
18
  grid-template-columns: fractions(1);
22
19
 
23
20
  @include govuk-media-query($from: "tablet") {
@@ -16,6 +16,7 @@
16
16
  simple ||= false
17
17
  simple_light ||= false
18
18
  dark_icon ||= false
19
+ dark_large_icon ||= false
19
20
  small_icon ||= false
20
21
  nhs_icon ||= false
21
22
  brexit_icon ||= false
@@ -27,6 +28,7 @@
27
28
  css_classes = %w(gem-c-action-link)
28
29
  css_classes << "gem-c-action-link--light-text" if light_text
29
30
  css_classes << "gem-c-action-link--dark-icon" if dark_icon
31
+ css_classes << "gem-c-action-link--dark-large-icon" if dark_large_icon
30
32
  css_classes << "gem-c-action-link--small-icon" if small_icon
31
33
  css_classes << "gem-c-action-link--transparent-icon" if transparent_icon
32
34
  css_classes << "gem-c-action-link--nhs" if nhs_icon
@@ -11,6 +11,8 @@
11
11
 
12
12
  data_attributes ||= {}
13
13
  suggestion_data_attributes ||= {}
14
+ dismiss_data_attributes ||= {}
15
+ dismiss_link_data_attributes ||= {}
14
16
  data_attributes[:module] = "intervention"
15
17
  data_attributes["intervention-name"] = name
16
18
 
@@ -30,6 +32,11 @@
30
32
  intervention_helper = GovukPublishingComponents::Presenters::InterventionHelper.new(options)
31
33
  dismiss_href = intervention_helper.dismiss_link
32
34
 
35
+ ga4_tracking ||= false
36
+ suggestion_data_attributes[:module] = "#{suggestion_data_attributes[:module]} ga4-link-tracker".strip if ga4_tracking
37
+ suggestion_data_attributes[:ga4_link] = { event_name: "navigation", type: "intervention", section: suggestion_text, index: 1, index_total: 1 }.to_json if ga4_tracking
38
+ data_attributes[:ga4_intervention_banner] = "" if ga4_tracking # Added to the parent element for the GA4 pageview object to use
39
+
33
40
  suggestion_tag_options = {
34
41
  class: "govuk-link",
35
42
  href: suggestion_link_url,
@@ -51,6 +58,9 @@
51
58
  data: data_attributes,
52
59
  }
53
60
  section_options.merge!({ hidden: true }) if hide
61
+
62
+ dismiss_link_data_attributes[:module] = "#{dismiss_link_data_attributes[:module]} ga4-event-tracker".strip if ga4_tracking
63
+ dismiss_link_data_attributes[:ga4_event] = { event_name: "select_content", type: "intervention", section: suggestion_text, action: 'closed' }.to_json if ga4_tracking
54
64
  %>
55
65
  <% if intervention_helper.show? %>
56
66
  <%= tag.section **section_options do %>
@@ -62,8 +72,8 @@
62
72
  </p>
63
73
 
64
74
  <% if dismiss_text %>
65
- <p class="govuk-body">
66
- <%= tag.a class: "govuk-link js-dismiss-link", href: dismiss_href do %>
75
+ <%= tag.p class: "govuk-body", data: dismiss_data_attributes do %>
76
+ <%= tag.a class: "govuk-link js-dismiss-link", href: dismiss_href, data: dismiss_link_data_attributes do %>
67
77
  <svg class="gem-c-intervention__dismiss-icon"
68
78
  width="19" height="19" viewBox="0 0 19 19"
69
79
  aria-hidden="true"
@@ -74,7 +84,7 @@
74
84
  </svg>
75
85
  <%= dismiss_text %>
76
86
  <% end %>
77
- </p>
87
+ <% end %>
78
88
  <% end %>
79
89
  <% end %>
80
90
  <% end %>
@@ -115,6 +115,11 @@ examples:
115
115
  text: Coronavirus (COVID-19)
116
116
  href: "/my-test-page"
117
117
  dark_icon: true
118
+ with_dark_large_icon:
119
+ data:
120
+ text: Coronavirus (COVID-19)
121
+ href: "/my-test-page"
122
+ dark_large_icon: true
118
123
  with_brexit_icon_and_custom_font_size:
119
124
  data:
120
125
  text: Guidance for businesses
@@ -65,8 +65,8 @@ examples:
65
65
 
66
66
  with_data_attributes:
67
67
  description: |
68
- This example shows the use of `suggestion_data_attributes` and
69
- `dismiss_data_attributes` for click tracking.
68
+ This example shows the use of `suggestion_data_attributes`,
69
+ `dismiss_data_attributes` for click tracking on the dismiss section <p> tag, and `dismiss_link_data_attributes` for adding attributes to the dismiss link <a> tag.
70
70
 
71
71
  Other data attributes can also be applied as required. Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
72
72
  data:
@@ -87,3 +87,15 @@ examples:
87
87
  track-dimension: Hide this suggestion
88
88
  track-dimension-index: 29
89
89
  track-label: hide the intervention
90
+ dismiss_link_data_attributes:
91
+ track-category: example
92
+ with_ga4_tracking:
93
+ description: |
94
+ Enables GA4 tracking on the banner. This includes link tracking on the component itself, event tracking on the 'Hide' link, and allows pageviews to record the presence of the banner on page load.
95
+ data:
96
+ ga4_tracking: true
97
+ suggestion_text: Based on your browsing you might be interested in
98
+ suggestion_link_text: "Travel abroad: step by step"
99
+ suggestion_link_url: /travel-abroad
100
+ dismiss_text: Hide this suggestion
101
+ name: another-campaign-name
@@ -241,6 +241,8 @@ en:
241
241
  href: "/sign-in-universal-credit"
242
242
  - label: Check your National Insurance record
243
243
  href: "/check-national-insurance-record"
244
+ - label: 'Check MOT history of a vehicle'
245
+ href: /check-mot-history
244
246
  popular_links_heading: Popular on GOV.UK
245
247
  search_text: Search GOV.UK
246
248
  metadata:
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "35.15.2".freeze
2
+ VERSION = "35.15.4".freeze
3
3
  end
@@ -164,9 +164,9 @@ declare namespace axe {
164
164
  interface NodeResult {
165
165
  html: string;
166
166
  impact?: ImpactValue;
167
- target: string[];
167
+ target: UnlabelledFrameSelector;
168
168
  xpath?: string[];
169
- ancestry?: string[];
169
+ ancestry?: UnlabelledFrameSelector;
170
170
  any: CheckResult[];
171
171
  all: CheckResult[];
172
172
  none: CheckResult[];
@@ -181,8 +181,11 @@ declare namespace axe {
181
181
  relatedNodes?: RelatedNode[];
182
182
  }
183
183
  interface RelatedNode {
184
- target: string[];
185
184
  html: string;
185
+ target: UnlabelledFrameSelector;
186
+ xpath?: string[];
187
+ ancestry?: UnlabelledFrameSelector;
188
+ element?: HTMLElement;
186
189
  }
187
190
  interface RuleLocale {
188
191
  [key: string]: {
@@ -193,7 +196,7 @@ declare namespace axe {
193
196
  interface CheckMessages {
194
197
  pass: string | { [key: string]: string };
195
198
  fail: string | { [key: string]: string };
196
- incomplete: string | { [key: string]: string };
199
+ incomplete?: string | { [key: string]: string };
197
200
  }
198
201
  interface CheckLocale {
199
202
  [key: string]: CheckMessages;
@@ -257,10 +260,31 @@ declare namespace axe {
257
260
  brand?: string;
258
261
  application?: string;
259
262
  }
263
+ interface CheckHelper {
264
+ async: () => (result: boolean | undefined | Error) => void;
265
+ data: (data: unknown) => void;
266
+ relatedNodes: (nodes: Element[]) => void;
267
+ }
268
+ interface AfterResult {
269
+ id: string;
270
+ data?: unknown;
271
+ relatedNodes: SerialDqElement[];
272
+ result: boolean | undefined;
273
+ node: SerialDqElement;
274
+ }
260
275
  interface Check {
261
276
  id: string;
262
- evaluate?: Function | string;
263
- after?: Function | string;
277
+ evaluate?:
278
+ | string
279
+ | ((
280
+ this: CheckHelper,
281
+ node: Element,
282
+ options: unknown,
283
+ virtualNode: VirtualNode
284
+ ) => boolean | undefined | void);
285
+ after?:
286
+ | string
287
+ | ((results: AfterResult[], options: unknown) => AfterResult[]);
264
288
  options?: any;
265
289
  matches?: string;
266
290
  enabled?: boolean;
@@ -280,9 +304,10 @@ declare namespace axe {
280
304
  all?: string[];
281
305
  none?: string[];
282
306
  tags?: string[];
283
- matches?: string;
307
+ matches?: string | ((node: Element, virtualNode: VirtualNode) => boolean);
284
308
  reviewOnFail?: boolean;
285
- metadata?: Omit<RuleMetadata, 'ruleId'>;
309
+ actIds?: string[];
310
+ metadata?: Omit<RuleMetadata, 'ruleId' | 'tags' | 'actIds'>;
286
311
  }
287
312
  interface AxePlugin {
288
313
  id: string;
@@ -346,7 +371,8 @@ declare namespace axe {
346
371
  type AxeReporter<T = unknown> = (
347
372
  rawResults: RawResult[],
348
373
  option: RunOptions,
349
- callback: (report: T) => void
374
+ resolve: (report: T) => void,
375
+ reject: (error: Error) => void
350
376
  ) => void;
351
377
 
352
378
  interface VirtualNode {
@@ -367,6 +393,42 @@ declare namespace axe {
367
393
  shadowSelect: (selector: CrossTreeSelector) => Element | null;
368
394
  shadowSelectAll: (selector: CrossTreeSelector) => Element[];
369
395
  getStandards(): Required<Standards>;
396
+ DqElement: new (
397
+ elm: Element,
398
+ options?: { absolutePaths?: boolean }
399
+ ) => SerialDqElement;
400
+ uuid: (
401
+ options?: { random?: Uint8Array | Array<number> },
402
+ buf?: Uint8Array | Array<number>,
403
+ offset?: number
404
+ ) => string | Uint8Array | Array<number>;
405
+ }
406
+
407
+ interface Aria {
408
+ getRoleType: (role: string | Element | VirtualNode | null) => string | null;
409
+ }
410
+
411
+ interface Dom {
412
+ isFocusable: (node: Element | VirtualNode) => boolean;
413
+ isNativelyFocusable: (node: Element | VirtualNode) => boolean;
414
+ }
415
+
416
+ type AccessibleTextOptions = {
417
+ inControlContext?: boolean;
418
+ inLabelledByContext?: boolean;
419
+ };
420
+
421
+ interface Text {
422
+ accessibleText: (
423
+ element: Element,
424
+ options?: AccessibleTextOptions
425
+ ) => string;
426
+ }
427
+
428
+ interface Commons {
429
+ aria: Aria;
430
+ dom: Dom;
431
+ text: Text;
370
432
  }
371
433
 
372
434
  interface EnvironmentData {
@@ -380,6 +442,7 @@ declare namespace axe {
380
442
  let version: string;
381
443
  let plugins: any;
382
444
  let utils: Utils;
445
+ let commons: Commons;
383
446
 
384
447
  /**
385
448
  * Source string to use as an injected script in Selenium