govuk_publishing_components 29.8.0 → 29.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/page-content.js +4 -4
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-click-tracking.js +33 -23
  4. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +15 -0
  5. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-measurer.js +18 -9
  6. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +166 -142
  7. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +20 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +3 -8
  10. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +7 -1
  11. data/app/assets/stylesheets/govuk_publishing_components/components/print/_organisation-logo.scss +4 -0
  12. data/app/controllers/govuk_publishing_components/audit_controller.rb +3 -2
  13. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +0 -9
  14. data/app/models/govuk_publishing_components/audit_comparer.rb +92 -34
  15. data/app/views/govuk_publishing_components/audit/_applications.html.erb +20 -9
  16. data/app/views/govuk_publishing_components/component_guide/index.html.erb +1 -19
  17. data/app/views/govuk_publishing_components/components/_accordion.html.erb +7 -5
  18. data/app/views/govuk_publishing_components/components/_character_count.html.erb +1 -1
  19. data/app/views/govuk_publishing_components/components/_date_input.html.erb +0 -1
  20. data/app/views/govuk_publishing_components/components/_input.html.erb +0 -2
  21. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +20 -2
  22. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +4 -5
  23. data/app/views/govuk_publishing_components/components/contextual_sidebar/_ukraine_cta.html.erb +18 -19
  24. data/app/views/govuk_publishing_components/components/docs/accordion.yml +20 -13
  25. data/config/locales/ar.yml +1 -2
  26. data/config/locales/az.yml +1 -2
  27. data/config/locales/be.yml +1 -2
  28. data/config/locales/bg.yml +1 -2
  29. data/config/locales/bn.yml +1 -2
  30. data/config/locales/cs.yml +1 -2
  31. data/config/locales/cy.yml +1 -2
  32. data/config/locales/da.yml +1 -2
  33. data/config/locales/de.yml +1 -2
  34. data/config/locales/dr.yml +1 -2
  35. data/config/locales/el.yml +1 -2
  36. data/config/locales/en.yml +9 -2
  37. data/config/locales/es-419.yml +1 -2
  38. data/config/locales/es.yml +1 -2
  39. data/config/locales/et.yml +1 -2
  40. data/config/locales/fa.yml +1 -2
  41. data/config/locales/fi.yml +1 -2
  42. data/config/locales/fr.yml +1 -2
  43. data/config/locales/gd.yml +1 -2
  44. data/config/locales/gu.yml +1 -2
  45. data/config/locales/he.yml +1 -2
  46. data/config/locales/hi.yml +1 -2
  47. data/config/locales/hr.yml +1 -2
  48. data/config/locales/hu.yml +1 -2
  49. data/config/locales/hy.yml +1 -2
  50. data/config/locales/id.yml +1 -2
  51. data/config/locales/is.yml +1 -2
  52. data/config/locales/it.yml +1 -2
  53. data/config/locales/ja.yml +1 -2
  54. data/config/locales/ka.yml +1 -2
  55. data/config/locales/kk.yml +1 -2
  56. data/config/locales/ko.yml +1 -2
  57. data/config/locales/lt.yml +1 -2
  58. data/config/locales/lv.yml +1 -2
  59. data/config/locales/ms.yml +1 -2
  60. data/config/locales/mt.yml +1 -2
  61. data/config/locales/nl.yml +1 -2
  62. data/config/locales/no.yml +1 -2
  63. data/config/locales/pa-pk.yml +1 -2
  64. data/config/locales/pa.yml +1 -2
  65. data/config/locales/pl.yml +1 -2
  66. data/config/locales/ps.yml +1 -2
  67. data/config/locales/pt.yml +1 -2
  68. data/config/locales/ro.yml +1 -2
  69. data/config/locales/ru.yml +1 -2
  70. data/config/locales/si.yml +1 -2
  71. data/config/locales/sk.yml +1 -2
  72. data/config/locales/sl.yml +1 -2
  73. data/config/locales/so.yml +1 -2
  74. data/config/locales/sq.yml +1 -2
  75. data/config/locales/sr.yml +1 -2
  76. data/config/locales/sv.yml +1 -2
  77. data/config/locales/sw.yml +1 -2
  78. data/config/locales/ta.yml +1 -2
  79. data/config/locales/th.yml +1 -2
  80. data/config/locales/tk.yml +1 -2
  81. data/config/locales/tr.yml +1 -2
  82. data/config/locales/uk.yml +1 -2
  83. data/config/locales/ur.yml +1 -2
  84. data/config/locales/uz.yml +1 -2
  85. data/config/locales/vi.yml +1 -2
  86. data/config/locales/zh-hk.yml +1 -2
  87. data/config/locales/zh-tw.yml +1 -2
  88. data/config/locales/zh.yml +1 -2
  89. data/lib/govuk_publishing_components/presenters/attachment_helper.rb +1 -2
  90. data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +35 -16
  91. data/lib/govuk_publishing_components/version.rb +1 -1
  92. data/node_modules/govuk-frontend/govuk/all.js +120 -49
  93. data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +2 -2
  94. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +0 -2
  95. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +2 -2
  96. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +6 -16
  97. data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +2 -2
  98. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +120 -49
  99. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +33 -17
  100. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +2 -2
  101. data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +1 -4
  102. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +3 -2
  103. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +22 -10
  104. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +2 -2
  105. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +23 -23
  106. data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +1 -1
  107. data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +4 -4
  108. data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +2 -2
  109. data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +3 -3
  110. data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +2 -2
  111. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +12 -22
  112. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +13 -3
  113. data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +2 -2
  114. data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +2 -2
  115. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +4 -13
  116. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +5 -5
  117. data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +2 -2
  118. data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +2 -2
  119. data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +1 -1
  120. data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +4 -4
  121. data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +2 -2
  122. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -4
  123. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +17 -12
  124. data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +2 -2
  125. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -3
  126. data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +2 -2
  127. data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +5 -5
  128. data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +4 -4
  129. data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +2 -2
  130. data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +2 -2
  131. data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +2 -2
  132. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +3 -3
  133. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +7 -5
  134. data/node_modules/govuk-frontend/govuk/helpers/_media-queries.scss +2 -2
  135. data/node_modules/govuk-frontend/govuk/helpers/_shape-arrow.scss +1 -1
  136. data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +3 -3
  137. data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +2 -2
  138. data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +10 -26
  139. data/node_modules/govuk-frontend/govuk/objects/_template.scss +1 -1
  140. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +0 -4
  141. data/node_modules/govuk-frontend/govuk/tools/_exports.scss +1 -1
  142. data/node_modules/govuk-frontend/govuk/tools/_font-url.scss +1 -1
  143. data/node_modules/govuk-frontend/govuk/tools/_image-url.scss +1 -1
  144. data/node_modules/govuk-frontend/govuk/tools/_px-to-em.scss +2 -2
  145. data/node_modules/govuk-frontend/govuk/tools/_px-to-rem.scss +1 -1
  146. data/node_modules/govuk-frontend/govuk-esm/all.mjs +88 -0
  147. data/node_modules/govuk-frontend/govuk-esm/common.mjs +28 -0
  148. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +374 -0
  149. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +64 -0
  150. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +251 -0
  151. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +164 -0
  152. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +147 -0
  153. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +168 -0
  154. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +52 -0
  155. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +55 -0
  156. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +122 -0
  157. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +94 -0
  158. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +282 -0
  159. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.js +264 -0
  160. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.js +26 -0
  161. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.js +93 -0
  162. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.js +24 -0
  163. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.js +23 -0
  164. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.js +22 -0
  165. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.js +22 -0
  166. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.js +114 -0
  167. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.js +252 -0
  168. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.js +159 -0
  169. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.js +86 -0
  170. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.js +20 -0
  171. data/node_modules/govuk-frontend/package.json +8 -1
  172. metadata +28 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cef8771d15136a9e4ebbe4fc0cbedb616731c433ea12db09af6fa12c1613594
4
- data.tar.gz: 721a1fb8532f1952e49aa9ff61a6aa075d3719f8a774c387319858da6c153edf
3
+ metadata.gz: 4908ab95bb70e9f55096b46cae08b0ea6fff5f168da24aa427c810a39de96e4a
4
+ data.tar.gz: 99873d158278fbbf30eb341558a5424b9957054b0711486312bd4e18b9c45b35
5
5
  SHA512:
6
- metadata.gz: f1544190ffc2c00a4f1576c84c74c89e1bc647d4916bccd72deb7f571a9b3f010ebba18abec66a1d67868b86de280dd83cbe4c5bc34677b5a1150bf1a54fdf16
7
- data.tar.gz: 868c8e7d02ab075e08fa196c526c39f02e6583dada12cfbb70f0384326a22728471cffe310d16692712d985960c4f78ec1e0f3ad5e8daeae84a4596398cf21a9
6
+ metadata.gz: 7c6a51b33e3f4fccb750bdc8ab05171bb7d3e877f5ee8e9f0a601be977baa390162cfbab07a94facf2905d7eadd5f504640e25e86260d5b756e82959a8532522
7
+ data.tar.gz: 5531061592b4e1db78a34d8ecf15f613f05140585df1d5edb76224e82b317a62be16fb7ae4345d75c075297f164b3eb1569c794a7337a09d7345fee4061e0daf
@@ -15,8 +15,8 @@
15
15
  return document.querySelectorAll('.document-collection .group-title').length
16
16
  case isNewBrowsePageLevelTwo():
17
17
  // if there are no accordion sections on the browse level 2 page
18
- // then it is a default page with only one section
19
- return document.querySelectorAll('[data-track-count="accordionSection"]').length || 1
18
+ // then it is a default page with one or two lists
19
+ return document.querySelectorAll('[data-track-count="accordionSection"]').length || document.querySelectorAll('main .govuk-list').length
20
20
  case isNewBrowsePage():
21
21
  return document.querySelectorAll('[data-track-count="cardList"]').length
22
22
  case isMainstreamBrowsePage():
@@ -77,7 +77,6 @@
77
77
  var metaApplicationSelector = 'meta[name="govuk:rendering-application"]'
78
78
  var metaFormatSelector = 'meta[name="govuk:format"]'
79
79
  var metaNavigationTypeSelector = 'meta[name="govuk:navigation-page-type"]'
80
- var metaSectionSelector = 'meta[name="govuk:section"]'
81
80
 
82
81
  function getMetaAttribute (selector) {
83
82
  var element = document.querySelector(selector)
@@ -111,7 +110,8 @@
111
110
 
112
111
  function isNewBrowsePage () {
113
112
  return getMetaAttribute(metaApplicationSelector) === 'collections' &&
114
- getMetaAttribute(metaSectionSelector) === 'new_browse_page' &&
113
+ (getMetaAttribute(metaNavigationTypeSelector) === 'browse level 0' ||
114
+ getMetaAttribute(metaNavigationTypeSelector) === 'browse level 1') &&
115
115
  getMetaAttribute(metaFormatSelector) === 'mainstream_browse_page'
116
116
  }
117
117
 
@@ -1,3 +1,4 @@
1
+ // = require govuk/vendor/polyfills/Element/prototype/closest.js
1
2
  window.GOVUK = window.GOVUK || {}
2
3
  window.GOVUK.Modules = window.GOVUK.Modules || {};
3
4
 
@@ -10,38 +11,47 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
10
11
  }
11
12
 
12
13
  GtmClickTracking.prototype.init = function () {
13
- var trackClicksOn = [this.module]
14
- if (!this.module.getAttribute(this.trackingTrigger)) {
15
- trackClicksOn = this.module.querySelectorAll('[' + this.trackingTrigger + ']')
16
- }
17
-
18
- for (var i = 0; i < trackClicksOn.length; i++) {
19
- trackClicksOn[i].addEventListener('click', this.trackClick.bind(this))
20
- }
14
+ this.module.addEventListener('click', this.trackClick.bind(this), true) // useCapture must be true
21
15
  }
22
16
 
23
17
  GtmClickTracking.prototype.trackClick = function (event) {
24
18
  if (window.dataLayer) {
25
- var target = event.currentTarget
26
- var data = {
27
- event: 'analytics',
28
- event_name: target.getAttribute('data-gtm-event-name'),
29
- // get entire URL apart from domain
30
- link_url: window.location.href.substring(window.location.origin.length),
31
- ui: JSON.parse(target.getAttribute('data-gtm-attributes'))
32
- }
33
- var ariaExpanded = this.checkExpandedState(target)
34
- if (ariaExpanded) {
35
- data.ui.state = ariaExpanded === 'false' ? 'opened' : 'closed'
19
+ var target = this.findTrackingAttributes(event.target)
20
+ if (target) {
21
+ var data = {
22
+ event: 'analytics',
23
+ event_name: target.getAttribute('data-gtm-event-name'),
24
+ // get entire URL apart from domain
25
+ link_url: window.location.href.substring(window.location.origin.length),
26
+ ui: JSON.parse(target.getAttribute('data-gtm-attributes')) || {}
27
+ }
28
+ var ariaExpanded = this.checkExpandedState(target)
29
+ if (ariaExpanded) {
30
+ data.ui.state = ariaExpanded === 'false' ? 'opened' : 'closed'
31
+ data.ui.text = data.ui.text || target.innerText
32
+ }
33
+ window.dataLayer.push(data)
36
34
  }
37
- window.dataLayer.push(data)
38
35
  }
39
36
  }
40
37
 
38
+ GtmClickTracking.prototype.findTrackingAttributes = function (clicked) {
39
+ if (clicked.hasAttribute('[' + this.trackingTrigger + ']')) {
40
+ return clicked
41
+ } else {
42
+ return clicked.closest('[' + this.trackingTrigger + ']')
43
+ }
44
+ }
45
+
46
+ // check either element is expandable or contains expandable element
41
47
  GtmClickTracking.prototype.checkExpandedState = function (clicked) {
42
- var expanded = clicked.querySelector('[aria-expanded]')
43
- if (expanded) {
44
- return expanded.getAttribute('aria-expanded')
48
+ var isExpandable = clicked.getAttribute('aria-expanded')
49
+ var containsExpandable = clicked.querySelector('[aria-expanded]')
50
+
51
+ if (isExpandable) {
52
+ return isExpandable
53
+ } else if (containsExpandable) {
54
+ return containsExpandable.getAttribute('aria-expanded')
45
55
  }
46
56
  }
47
57
 
@@ -45,6 +45,21 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
45
45
  if (this.$module.getAttribute('data-track-sections') === 'true') {
46
46
  this.addEventListenerSections()
47
47
  }
48
+
49
+ // look for data attributes to put onto the 'show/hide all' link
50
+ var showAllAttributes = this.$module.getAttribute('data-show-all-attributes')
51
+ if (showAllAttributes) {
52
+ try {
53
+ var showAll = this.$module.querySelector('.' + this.showAllControls)
54
+ var values = JSON.parse(showAllAttributes)
55
+ var keys = Object.keys(values)
56
+ for (var i = 0; i < keys.length; i++) {
57
+ showAll.setAttribute('data-' + keys[i], values[keys[i]])
58
+ }
59
+ } catch (e) {
60
+ console.error('Could not read accordion data attributes error: ' + e.message, window.location)
61
+ }
62
+ }
48
63
  }
49
64
 
50
65
  // Navigate to and open accordions with anchored content on page load if a hash is present
@@ -171,16 +171,25 @@ if (
171
171
  // `DOMContentReady` event before we can see what the HTTP version is.
172
172
  //
173
173
  // [1]: https://github.com/alphagov/govuk-rfcs/pull/148
174
- try {
175
- if (typeof performance !== 'undefined') {
176
- document.addEventListener('DOMContentLoaded', function () {
177
- var getEntriesByType = performance.getEntriesByType('navigation')
178
174
 
179
- if (getEntriesByType.length > 0) {
180
- var httpProtocol = performance.getEntriesByType('navigation')[0].nextHopProtocol
181
- LUX.addData("http-protocol", httpProtocol)
182
- }
183
- })
175
+ var measureHTTPProtocol = function () {
176
+ var getEntriesByType = performance.getEntriesByType('navigation')
177
+
178
+ if (getEntriesByType.length > 0) {
179
+ var httpProtocol = JSON.parse(JSON.stringify(performance.getEntriesByType('navigation')[0].nextHopProtocol))
180
+ LUX.addData("http-protocol", httpProtocol)
181
+ }
182
+ }
183
+
184
+ try {
185
+ if (typeof performance !== 'undefined' && typeof performance.getEntriesByType !== 'undefined') {
186
+ if (document.readyState === 'complete') {
187
+ measureHTTPProtocol()
188
+ } else {
189
+ window.addEventListener('load', function() {
190
+ measureHTTPProtocol()
191
+ })
192
+ }
184
193
  }
185
194
  } catch (e) {
186
195
  console.error('Error in LUX reporting the HTTP protocol (' + window.location + '):', e)