govuk_publishing_components 23.13.1 → 24.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/govuk_publishing_components/take-action-amber.svg +4 -0
  3. data/app/assets/images/govuk_publishing_components/take-action-green.svg +4 -0
  4. data/app/assets/images/govuk_publishing_components/take-action-red.svg +4 -0
  5. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +286 -4
  6. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +0 -4
  7. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +23 -14
  8. data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/common.js +8 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -1
  10. data/app/assets/stylesheets/govuk_publishing_components/component_support.scss +0 -2
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +298 -14
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +34 -17
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss +14 -8
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_error-alert.scss +4 -4
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +35 -44
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +21 -5
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +105 -48
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +8 -8
  19. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_contact.scss +0 -5
  20. data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +17 -9
  21. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss +2 -2
  22. data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +1 -11
  23. data/app/models/govuk_publishing_components/audit_applications.rb +1 -1
  24. data/app/models/govuk_publishing_components/component_doc.rb +1 -1
  25. data/app/views/govuk_publishing_components/audit/show.html.erb +26 -26
  26. data/app/views/govuk_publishing_components/components/_accordion.html.erb +13 -20
  27. data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -3
  28. data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +2 -8
  29. data/app/views/govuk_publishing_components/components/_document_list.html.erb +12 -2
  30. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +9 -4
  31. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_document.svg → _thumbnail_document.html.erb} +0 -0
  32. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_generic.svg → _thumbnail_generic.html.erb} +0 -0
  33. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_spreadsheet.svg → _thumbnail_spreadsheet.html.erb} +0 -0
  34. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb +21 -0
  35. data/app/views/govuk_publishing_components/components/docs/accordion.yml +8 -3
  36. data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +65 -1
  37. data/app/views/govuk_publishing_components/components/docs/document_list.yml +50 -7
  38. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +3 -3
  39. data/app/views/govuk_publishing_components/components/docs/layout_header.yml +11 -0
  40. data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +1 -1
  41. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +9 -4
  42. data/config/initializers/assets.rb +3 -1
  43. data/config/locales/cy.yml +6 -1
  44. data/config/locales/en.yml +6 -1
  45. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +183 -2
  46. data/lib/govuk_publishing_components/version.rb +1 -1
  47. data/node_modules/govuk-frontend/govuk/all.js +1 -1
  48. data/node_modules/govuk-frontend/govuk/components/_all.scss +1 -0
  49. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +10 -10
  50. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/template.njk +2 -2
  51. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +2 -0
  52. data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +1 -0
  53. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +1 -1
  54. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +13 -0
  55. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_cookie-banner.scss +2 -0
  56. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +51 -0
  57. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +425 -0
  58. data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro-options.json +132 -0
  59. data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro.njk +3 -0
  60. data/node_modules/govuk-frontend/govuk/components/cookie-banner/template.njk +63 -0
  61. data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +2 -2
  62. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +18 -18
  63. data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -4
  64. data/node_modules/govuk-frontend/govuk/components/table/_index.scss +21 -0
  65. data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +2 -2
  66. data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
  67. data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +94 -0
  68. data/node_modules/govuk-frontend/package.json +1 -1
  69. metadata +16 -21
  70. data/app/assets/images/govuk_publishing_components/chevron-banner/chevron-banner-small-focus.svg +0 -4
  71. data/app/assets/images/govuk_publishing_components/chevron-banner/chevron-banner-small.svg +0 -4
  72. data/app/assets/javascripts/govuk_publishing_components/components/header.js +0 -8
  73. data/app/assets/javascripts/govuk_publishing_components/lib/auto-track-event.js +0 -31
  74. data/app/assets/stylesheets/govuk_publishing_components/components/_chevron-banner.scss +0 -138
  75. data/app/assets/stylesheets/govuk_publishing_components/components/_list.scss +0 -1
  76. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_variables.scss +0 -27
  77. data/app/assets/stylesheets/govuk_publishing_components/components/mixins/_back-arrow.scss +0 -13
  78. data/app/assets/stylesheets/govuk_publishing_components/components/mixins/_clearfix.scss +0 -8
  79. data/app/views/govuk_publishing_components/components/_chevron_banner.html.erb +0 -19
  80. data/app/views/govuk_publishing_components/components/_subscription-links.html.erb +0 -85
  81. data/app/views/govuk_publishing_components/components/_translation-nav.html.erb +0 -33
  82. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_related_links.html.erb +0 -6
  83. data/app/views/govuk_publishing_components/components/docs/chevron_banner.yml +0 -33
  84. data/app/views/govuk_publishing_components/components/docs/subscription-links.yml +0 -103
  85. data/app/views/govuk_publishing_components/components/docs/translation-nav.yml +0 -139
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8e84f4736eb11902079ff68c2a4a2acb1c328126a4024664414adb2aa8a67fd
4
- data.tar.gz: 693fabe38ddd9b79740a918e42bd1321a2f61b6abaca88e0b06e4360dcbb27fe
3
+ metadata.gz: 664f19b71a4b1ec65f49a7a14fa21d4a2a64465b2f593a3c75e2de132474417a
4
+ data.tar.gz: 8e734701d0d66817548de5855938a6cdad1f9b2ce2fa96437075e9058331785a
5
5
  SHA512:
6
- metadata.gz: 1b833ced5ea9b6a0ca211eb846b0018fd51920edf04babb7d38126ddb5d85df400600558f73e066e21634346045c7d9819983648ddf3664976ee4ba2a3cd4ae5
7
- data.tar.gz: 07132c1756b1ca69c9b674f39c393120679a61b62ee20c6e8c3ade957b4189cee7e9801b76f5c083d8f554d9c5360369dd6681e7f8724020576d3b084811b6cf
6
+ metadata.gz: 9073c4b0254a544f3a0f6da89889550786a3f0e7cc5611b6c89768be9c8d66ff27b8364d54525e677013c439e73acb7dd618289f2d72787d56b6f833d89df910
7
+ data.tar.gz: 2ed858269eee93ae2212110fd2aa4b4cee21106e5028a36508d3242982a8e60be387b1f31e8b7694f1b66b401707049865f4fda1338639d3b9ce5e702db99b05
@@ -0,0 +1,4 @@
1
+ <svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle cx="17.5" cy="17.5" r="17.5" fill="#FF5800"/>
3
+ <path d="M28.5 10L13.6739 24L6.5 17.2258" stroke="white" stroke-width="3"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle cx="17.5" cy="17.5" r="17.5" fill="#0EBA72"/>
3
+ <path d="M28.5 10L13.6739 24L6.5 17.2258" stroke="white" stroke-width="3"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle cx="17.5" cy="17.5" r="17.5" fill="#FF003B"/>
3
+ <path d="M28.5 10.5L13.6739 24.5L6.5 17.7258" stroke="white" stroke-width="3"/>
4
+ </svg>
@@ -1,5 +1,287 @@
1
- // This component relies on JavaScript from GOV.UK Frontend
2
- // = require govuk/components/accordion/accordion.js
1
+ /* global nodeListForEach */
2
+ // = require ../vendor/polyfills/closest.js
3
+ // = require ../vendor/polyfills/indexOf.js
4
+ // = require ../vendor/polyfills/common.js
5
+
3
6
  window.GOVUK = window.GOVUK || {}
4
- window.GOVUK.Modules = window.GOVUK.Modules || {}
5
- window.GOVUK.Modules.Accordion = window.GOVUKFrontend
7
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
8
+
9
+ (function (Modules) {
10
+ function GemAccordion () { }
11
+
12
+ GemAccordion.prototype.start = function ($module) {
13
+ this.$module = $module[0]
14
+ this.moduleId = this.$module.getAttribute('id')
15
+ this.sections = this.$module.querySelectorAll('.gem-c-accordion__section')
16
+ this.openAllButton = ''
17
+ this.browserSupportsSessionStorage = helper.checkForSessionStorage()
18
+ this.controlsClass = 'gem-c-accordion__controls'
19
+ this.openAllClass = 'gem-c-accordion__open-all'
20
+ this.openAllTextClass = 'gem-c-accordion__open-all-text'
21
+ this.sectionHeaderClass = 'gem-c-accordion__section-header'
22
+ this.sectionHeadingClass = 'gem-c-accordion__section-heading'
23
+ this.sectionSummaryClass = 'gem-c-accordion__section-summary'
24
+ this.sectionButtonClass = 'gem-c-accordion__section-button'
25
+ this.sectionExpandedClass = 'gem-c-accordion__section--expanded'
26
+ this.sectionInnerContent = 'gem-c-accordion__section-content'
27
+ this.toggleLinkClass = 'js-toggle-link'
28
+ this.sectionShowHideIconClass = 'gem-c-accordion__toggle-link'
29
+ this.sectionShowHideTextClass = 'gem-c-accordion__toggle-text'
30
+ this.upChevonIconClass = 'gem-c-accordion-nav__chevron'
31
+ this.downChevonIconClass = 'gem-c-accordion-nav__chevron--down'
32
+
33
+ // Indicate that js has worked
34
+ this.$module.classList.add('gem-c-accordion--active')
35
+
36
+ this.initControls()
37
+ this.initSectionHeaders()
38
+
39
+ // See if "Show all sections" button text should be updated
40
+ var areAllSectionsOpen = this.checkIfAllSectionsOpen()
41
+ this.updateOpenAllButton(areAllSectionsOpen)
42
+ }
43
+
44
+ // Initialise controls and set attributes
45
+ GemAccordion.prototype.initControls = function () {
46
+ // Create "Show all" button and set attributes
47
+ this.openAllButton = document.createElement('button')
48
+ this.openAllButton.setAttribute('class', this.openAllClass)
49
+ this.openAllButton.setAttribute('aria-expanded', 'false')
50
+
51
+ // Create icon, add to element
52
+ var icon = document.createElement('span')
53
+ icon.classList.add(this.upChevonIconClass)
54
+ this.openAllButton.appendChild(icon)
55
+
56
+ // Create control wrapper and add controls to it
57
+ var accordionControls = document.createElement('div')
58
+ accordionControls.setAttribute('class', this.controlsClass)
59
+ accordionControls.appendChild(this.openAllButton)
60
+ this.$module.insertBefore(accordionControls, this.$module.firstChild)
61
+
62
+ // Build addtional wrapper for open all toggle text, place icon after wrapped text.
63
+ var wrapperOpenAllText = document.createElement('span')
64
+ wrapperOpenAllText.classList.add(this.openAllTextClass)
65
+ this.openAllButton.insertBefore(wrapperOpenAllText, this.openAllButton.childNodes[0] || null)
66
+
67
+ // Handle events for the controls
68
+ this.openAllButton.addEventListener('click', this.onOpenOrCloseAllToggle.bind(this))
69
+ }
70
+
71
+ // Initialise section headers
72
+ GemAccordion.prototype.initSectionHeaders = function () {
73
+ // Loop through section headers
74
+ nodeListForEach(this.sections, function (section, i) {
75
+ // Set header attributes
76
+ var header = section.querySelector('.' + this.sectionHeaderClass)
77
+ this.initHeaderAttributes(header, i)
78
+ this.setExpanded(this.isExpanded(section), section)
79
+
80
+ // Handle events
81
+ header.addEventListener('click', this.onSectionToggle.bind(this, section))
82
+
83
+ // See if there is any state stored in sessionStorage and set the sections to
84
+ // open or closed.
85
+ this.setInitialState(section)
86
+ }.bind(this))
87
+ }
88
+
89
+ // Set individual header attributes
90
+ GemAccordion.prototype.initHeaderAttributes = function (headerWrapper, index) {
91
+ var span = headerWrapper.querySelector('.' + this.sectionButtonClass)
92
+ var heading = headerWrapper.querySelector('.' + this.sectionHeadingClass)
93
+ var summary = headerWrapper.querySelector('.' + this.sectionSummaryClass)
94
+
95
+ // Copy existing span element to an actual button element, for improved accessibility.
96
+ var button = document.createElement('button')
97
+ button.setAttribute('id', this.moduleId + '-heading-' + (index + 1))
98
+ button.setAttribute('aria-controls', this.moduleId + '-content-' + (index + 1))
99
+
100
+ // Create show / hide arrow icons with text.
101
+ var showIcons = document.createElement('span')
102
+ showIcons.classList.add(this.sectionShowHideIconClass, this.toggleLinkClass)
103
+
104
+ // Add pause after heading for assistive technology.
105
+ var srPause = document.createElement('span')
106
+ srPause.classList.add('govuk-visually-hidden')
107
+ srPause.innerHTML = ', '
108
+
109
+ // Build addtional copy for assistive technology
110
+ var srAddtionalCopy = document.createElement('span')
111
+ srAddtionalCopy.classList.add('govuk-visually-hidden')
112
+ srAddtionalCopy.innerHTML = ' this section'
113
+
114
+ // Build addtional wrapper for toggle text, place icon after wrapped text.
115
+ var wrapperShowHideIcon = document.createElement('span')
116
+ var icon = document.createElement('span')
117
+ icon.classList.add(this.upChevonIconClass)
118
+ showIcons.appendChild(icon)
119
+ wrapperShowHideIcon.classList.add(this.sectionShowHideTextClass)
120
+ showIcons.insertBefore(wrapperShowHideIcon, showIcons.childNodes[0] || null)
121
+
122
+ // Copy all attributes (https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes) from span to button
123
+ for (var i = 0; i < span.attributes.length; i++) {
124
+ var attr = span.attributes.item(i)
125
+ button.setAttribute(attr.nodeName, attr.nodeValue)
126
+ }
127
+
128
+ // span could contain HTML elements (see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content)
129
+ button.innerHTML = span.innerHTML
130
+ heading.removeChild(span)
131
+ heading.appendChild(button)
132
+ button.appendChild(srPause)
133
+
134
+ // If summary content exists add to DOM in correct order
135
+ if (typeof (summary) !== 'undefined' && summary !== null) {
136
+ button.setAttribute('aria-describedby', this.moduleId + '-summary-' + (index + 1))
137
+ button.appendChild(summary)
138
+ }
139
+
140
+ button.appendChild(showIcons)
141
+ button.appendChild(srAddtionalCopy)
142
+ }
143
+
144
+ // When section toggled, set and store state
145
+ GemAccordion.prototype.onSectionToggle = function (section) {
146
+ var expanded = this.isExpanded(section)
147
+ this.setExpanded(!expanded, section)
148
+
149
+ // Store the state in sessionStorage when a change is triggered
150
+ this.storeState(section)
151
+ }
152
+
153
+ // When Open/Close All toggled, set and store state
154
+ GemAccordion.prototype.onOpenOrCloseAllToggle = function () {
155
+ var module = this
156
+ var sections = this.sections
157
+ var nowExpanded = !this.checkIfAllSectionsOpen()
158
+
159
+ nodeListForEach(sections, function (section) {
160
+ module.setExpanded(nowExpanded, section)
161
+ // Store the state in sessionStorage when a change is triggered
162
+ module.storeState(section)
163
+ })
164
+
165
+ module.updateOpenAllButton(nowExpanded)
166
+ }
167
+
168
+ // Set section attributes when opened/closed
169
+ GemAccordion.prototype.setExpanded = function (expanded, section) {
170
+ var icon = section.querySelector('.' + this.upChevonIconClass)
171
+ var showHideText = section.querySelector('.' + this.sectionShowHideTextClass)
172
+ var button = section.querySelector('.' + this.sectionButtonClass)
173
+ var newButtonText = expanded ? 'Hide' : 'Show'
174
+
175
+ showHideText.innerHTML = newButtonText
176
+ button.setAttribute('aria-expanded', expanded)
177
+ button.classList.add(this.toggleLinkClass)
178
+
179
+ // Swap icon, change class
180
+ if (expanded) {
181
+ section.classList.add(this.sectionExpandedClass)
182
+ icon.classList.remove(this.downChevonIconClass)
183
+ } else {
184
+ section.classList.remove(this.sectionExpandedClass)
185
+ icon.classList.add(this.downChevonIconClass)
186
+ }
187
+
188
+ // See if "Show all sections" button text should be updated
189
+ var areAllSectionsOpen = this.checkIfAllSectionsOpen()
190
+ this.updateOpenAllButton(areAllSectionsOpen)
191
+ }
192
+
193
+ // Get state of section
194
+ GemAccordion.prototype.isExpanded = function (section) {
195
+ return section.classList.contains(this.sectionExpandedClass)
196
+ }
197
+
198
+ // Check if all sections are open
199
+ GemAccordion.prototype.checkIfAllSectionsOpen = function () {
200
+ // Get a count of all the Accordion sections
201
+ var sectionsCount = this.sections.length
202
+ // Get a count of all Accordion sections that are expanded
203
+ var expandedSectionCount = this.$module.querySelectorAll('.' + this.sectionExpandedClass).length
204
+ var areAllSectionsOpen = sectionsCount === expandedSectionCount
205
+
206
+ return areAllSectionsOpen
207
+ }
208
+
209
+ // Update "Show all sections" button
210
+ GemAccordion.prototype.updateOpenAllButton = function (expanded) {
211
+ var icon = this.openAllButton.querySelector('.' + this.upChevonIconClass)
212
+ var openAllCopy = this.openAllButton.querySelector('.' + this.openAllTextClass)
213
+ var newButtonText = expanded ? 'Hide all sections' : 'Show all sections'
214
+ this.openAllButton.setAttribute('aria-expanded', expanded)
215
+ openAllCopy.innerHTML = newButtonText
216
+
217
+ // Swap icon, toggle class
218
+ if (expanded) {
219
+ icon.classList.remove(this.downChevonIconClass)
220
+ } else {
221
+ icon.classList.add(this.downChevonIconClass)
222
+ }
223
+ }
224
+
225
+ var helper = {
226
+ checkForSessionStorage: function () {
227
+ var testString = 'this is the test string'
228
+ var result
229
+ try {
230
+ window.sessionStorage.setItem(testString, testString)
231
+ result = window.sessionStorage.getItem(testString) === testString.toString()
232
+ window.sessionStorage.removeItem(testString)
233
+ return result
234
+ } catch (exception) {
235
+ if ((typeof console === 'undefined' || typeof console.log === 'undefined')) {
236
+ console.log('Notice: sessionStorage not available.')
237
+ }
238
+ }
239
+ }
240
+ }
241
+
242
+ // Set the state of the accordions in sessionStorage
243
+ GemAccordion.prototype.storeState = function (section) {
244
+ if (this.browserSupportsSessionStorage) {
245
+ // We need a unique way of identifying each content in the GemAccordion. Since
246
+ // an `#id` should be unique and an `id` is required for `aria-` attributes
247
+ // `id` can be safely used.
248
+ var button = section.querySelector('.' + this.sectionButtonClass)
249
+
250
+ if (button) {
251
+ var contentId = button.getAttribute('aria-controls')
252
+ var contentState = button.getAttribute('aria-expanded')
253
+
254
+ if (typeof contentId === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
255
+ console.error(new Error('No aria controls present in accordion section heading.'))
256
+ }
257
+
258
+ if (typeof contentState === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
259
+ console.error(new Error('No aria expanded present in accordion section heading.'))
260
+ }
261
+
262
+ // Only set the state when both `contentId` and `contentState` are taken from the DOM.
263
+ if (contentId && contentState) {
264
+ window.sessionStorage.setItem(contentId, contentState)
265
+ }
266
+ }
267
+ }
268
+ }
269
+
270
+ // Read the state of the accordions from sessionStorage
271
+ GemAccordion.prototype.setInitialState = function (section) {
272
+ if (this.browserSupportsSessionStorage) {
273
+ var button = section.querySelector('.' + this.sectionButtonClass)
274
+
275
+ if (button) {
276
+ var contentId = button.getAttribute('aria-controls')
277
+ var contentState = contentId ? window.sessionStorage.getItem(contentId) : null
278
+
279
+ if (contentState !== null) {
280
+ this.setExpanded(contentState === 'true', section)
281
+ }
282
+ }
283
+ }
284
+ }
285
+
286
+ Modules.GemAccordion = GemAccordion
287
+ })(window.GOVUK.Modules)
@@ -85,10 +85,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
85
85
  this.$module.cookieBannerConfirmationMessage.style.display = 'block'
86
86
  }
87
87
 
88
- CookieBanner.prototype.listenForCrossOriginMessages = function () {
89
- window.addEventListener('message', this.receiveMessage.bind(this), false)
90
- }
91
-
92
88
  CookieBanner.prototype.isInCookiesPage = function () {
93
89
  return window.location.pathname === '/help/cookies'
94
90
  }
@@ -40,13 +40,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
40
40
  this.$module.sessionStoreLink = this.$module.sessionStoreLink + '_' + this.$module.uniqueId
41
41
  }
42
42
 
43
- this.$module.upChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="gem-c-step-nav__chevron">' +
44
- '<path d="M19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499998 10C0.499999 4.7533 4.7533 0.500001 10 0.500002C15.2467 0.500003 19.5 4.7533 19.5 10Z" stroke="#1D70B8"/>' +
45
- '<path d="M6.32617 12.3262L10 8.65234L13.6738 12.3262" stroke="#1D70B8" stroke-width="2"/>' +
43
+ this.$module.upChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">' +
44
+ '<path class="gem-c-step-nav__chevron-stroke" d="M19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499998 10C0.499999 4.7533 4.7533 0.500001 10 0.500002C15.2467 0.500003 19.5 4.7533 19.5 10Z" stroke="#1D70B8"/>' +
45
+ '<path class="gem-c-step-nav__chevron-stroke" d="M6.32617 12.3262L10 8.65234L13.6738 12.3262" stroke="#1D70B8" stroke-width="2"/>' +
46
46
  '</svg>'
47
- this.$module.downChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="gem-c-step-nav__chevron">' +
48
- '<path d="M0.499997 10C0.499998 4.75329 4.75329 0.499999 10 0.499999C15.2467 0.5 19.5 4.75329 19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499997 10Z" stroke="#1D70B8"/>' +
49
- '<path d="M13.6738 8.67383L10 12.3477L6.32617 8.67383" stroke="#1D70B8" stroke-width="2"/>' +
47
+ this.$module.downChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">' +
48
+ '<path class="gem-c-step-nav__chevron-stroke" d="M0.499997 10C0.499998 4.75329 4.75329 0.499999 10 0.499999C15.2467 0.5 19.5 4.75329 19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499997 10Z" stroke="#1D70B8"/>' +
49
+ '<path class="gem-c-step-nav__chevron-stroke" d="M13.6738 8.67383L10 12.3477L6.32617 8.67383" stroke="#1D70B8" stroke-width="2"/>' +
50
50
  '</svg>'
51
51
 
52
52
  var stepNavTracker = new this.StepNavTracker(this.$module.uniqueId, this.$module.totalSteps, this.$module.totalLinks)
@@ -76,8 +76,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
76
76
  var showall = document.createElement('div')
77
77
  showall.className = 'gem-c-step-nav__controls'
78
78
  showall.innerHTML = '<button aria-expanded="false" class="gem-c-step-nav__button gem-c-step-nav__button--controls js-step-controls-button">' +
79
- this.$module.downChevronSvg +
80
- this.$module.actions.showAllText +
79
+ '<span class="gem-c-step-nav__button-text gem-c-step-nav__button-text--all js-step-controls-button-text">' + this.$module.actions.showAllText + '</span>' +
80
+ '<span class="gem-c-step-nav__chevron js-step-controls-button-icon">' + this.$module.downChevronSvg + '</span>' +
81
81
  '</button>'
82
82
 
83
83
  var steps = this.$module.querySelectorAll('.gem-c-step-nav__steps')[0]
@@ -93,13 +93,20 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
93
93
  if (!thisel.querySelectorAll('.js-toggle-link').length) {
94
94
  var span = document.createElement('span')
95
95
  var showHideSpan = document.createElement('span')
96
+ var showHideSpanText = document.createElement('span')
97
+ var showHideSpanIcon = document.createElement('span')
96
98
  var commaSpan = document.createElement('span')
97
99
  var thisSectionSpan = document.createElement('span')
98
100
 
99
101
  showHideSpan.className = 'gem-c-step-nav__toggle-link js-toggle-link'
102
+ showHideSpanText.className = 'gem-c-step-nav__button-text js-toggle-link-text'
103
+ showHideSpanIcon.className = 'gem-c-step-nav__chevron js-toggle-link-icon'
100
104
  commaSpan.className = 'govuk-visually-hidden'
101
105
  thisSectionSpan.className = 'govuk-visually-hidden'
102
106
 
107
+ showHideSpan.appendChild(showHideSpanText)
108
+ showHideSpan.appendChild(showHideSpanIcon)
109
+
103
110
  commaSpan.innerHTML = ', '
104
111
  thisSectionSpan.innerHTML = ' this section'
105
112
 
@@ -351,12 +358,12 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
351
358
 
352
359
  Gemstepnav.prototype.setShowHideAllText = function () {
353
360
  var shownSteps = this.$module.querySelectorAll('.step-is-shown').length
361
+
354
362
  // Find out if the number of is-opens == total number of steps
355
- if (shownSteps === this.$module.totalSteps) {
356
- this.$module.showOrHideAllButton.innerHTML = this.$module.upChevronSvg + this.$module.actions.hideAllText
357
- } else {
358
- this.$module.showOrHideAllButton.innerHTML = this.$module.downChevronSvg + this.$module.actions.showAllText
359
- }
363
+ var shownStepsIsTotalSteps = shownSteps === this.$module.totalSteps
364
+
365
+ this.$module.showOrHideAllButton.querySelector('.js-step-controls-button-text').innerHTML = shownStepsIsTotalSteps ? this.$module.actions.hideAllText : this.$module.actions.showAllText
366
+ this.$module.showOrHideAllButton.querySelector('.js-step-controls-button-icon').innerHTML = shownStepsIsTotalSteps ? this.$module.upChevronSvg : this.$module.downChevronSvg
360
367
  }
361
368
 
362
369
  Gemstepnav.prototype.StepView = function (stepElement, $module) {
@@ -394,7 +401,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
394
401
 
395
402
  this.titleButton.setAttribute('aria-expanded', isShown)
396
403
  var showHideText = this.stepElement.querySelectorAll('.js-toggle-link')[0]
397
- showHideText.innerHTML = isShown ? this.upChevronSvg + this.hideText : this.downChevronSvg + this.showText
404
+
405
+ showHideText.querySelector('.js-toggle-link-text').innerHTML = isShown ? this.hideText : this.showText
406
+ showHideText.querySelector('.js-toggle-link-icon').innerHTML = isShown ? this.upChevronSvg : this.downChevronSvg
398
407
  }
399
408
 
400
409
  this.isShown = function () {
@@ -0,0 +1,8 @@
1
+ function nodeListForEach (nodes, callback) {
2
+ if (window.NodeList.prototype.forEach) {
3
+ return nodes.forEach(callback)
4
+ }
5
+ for (var i = 0; i < nodes.length; i++) {
6
+ callback.call(window, nodes[i], i, nodes);
7
+ }
8
+ }
@@ -17,7 +17,6 @@
17
17
  @import "components/button";
18
18
  @import "components/character-count";
19
19
  @import "components/checkboxes";
20
- @import "components/chevron-banner";
21
20
  @import "components/contents-list";
22
21
  @import "components/contextual-guidance";
23
22
  @import "components/contextual-sidebar";
@@ -6,12 +6,10 @@
6
6
  @import "govuk/utilities/all";
7
7
  @import "govuk/overrides/all";
8
8
 
9
- @import "govuk_publishing_components/components/helpers/variables";
10
9
  @import "govuk_publishing_components/components/helpers/brand-colours";
11
10
  @import "govuk_publishing_components/components/helpers/link";
12
11
  @import "govuk_publishing_components/components/helpers/px-to-em";
13
12
  @import "govuk_publishing_components/components/mixins/govuk-template-link-focus-override";
14
13
  @import "govuk_publishing_components/components/mixins/media-down";
15
14
  @import "govuk_publishing_components/components/mixins/margins";
16
- @import "govuk_publishing_components/components/mixins/clearfix";
17
15
  @import "govuk_publishing_components/components/mixins/css3";
@@ -1,25 +1,309 @@
1
- @import "govuk/components/accordion/accordion";
1
+ $gem-c-accordion-border-width: 3px;
2
+ $gem-c-accordion-bottom-border-width: 1px;
2
3
 
3
- .gem-c-accordion {
4
- .govuk-accordion__section-heading {
5
- // this is a temporary addition to fix the line height when it
6
- // is being overridden by styles from govuk-template in collections
7
- @include govuk-media-query($until: desktop) {
8
- @include govuk-font(24, $weight: bold, $line-height: 1.6);
4
+ // Buttons within the sections don’t need default styling
5
+ .gem-c-accordion__section-button {
6
+ display: inline-block;
7
+ margin-bottom: 0;
8
+ padding-top: govuk-spacing(3);
9
+ font-weight: bold;
10
+ @include govuk-font($size: 24, $weight: bold);
11
+ }
12
+
13
+ .gem-c-accordion__section-header {
14
+ padding-top: govuk-spacing(2) 0;
15
+ }
16
+
17
+ .gem-c-accordion__section-heading {
18
+ margin: govuk-spacing(1) 0;
19
+ }
20
+
21
+ .js-enabled {
22
+ .gem-c-accordion {
23
+ border-bottom: $gem-c-accordion-bottom-border-width solid $govuk-border-colour;
24
+ }
25
+
26
+ .gem-c-accordion__controls {
27
+ text-align: left;
28
+ }
29
+
30
+ .gem-c-accordion__open-all {
31
+ position: relative;
32
+ z-index: 1;
33
+ border-width: 0;
34
+ color: $govuk-link-colour;
35
+ background: none;
36
+ -webkit-appearance: none;
37
+ cursor: pointer;
38
+ margin-bottom: govuk-spacing(4);
39
+ padding: 0 govuk-spacing(1) govuk-spacing(1) 0;
40
+ @include govuk-font($size: 16);
41
+ @include govuk-link-common;
42
+ @include govuk-link-style-default;
43
+ // Remove default button focus outline in Firefox
44
+ &::-moz-focus-inner {
45
+ padding: 0;
46
+ border: 0;
9
47
  }
10
48
  }
11
- }
12
49
 
13
- .govuk-accordion--condensed {
14
- .govuk-accordion__section-button {
15
- @include govuk-media-query($from: tablet) {
16
- @include govuk-font($size: 19, $weight: bold);
50
+ .gem-c-accordion__open-all:hover,
51
+ .gem-c-accordion__open-all-text:hover {
52
+ text-decoration: underline;
53
+ color: $govuk-link-colour;
54
+ }
55
+
56
+ // Focus state, also to change chervon icon to black
57
+ .gem-c-accordion__open-all:focus {
58
+ .gem-c-accordion__open-all-text,
59
+ .gem-c-accordion-nav__chevron {
60
+ color: $govuk-focus-text-colour;
61
+ text-decoration: none;
17
62
  }
18
63
  }
19
64
 
20
- .govuk-accordion__section-summary {
65
+ // Create Chervon icon align with text
66
+ .gem-c-accordion-nav__chevron {
67
+ vertical-align: text-top;
68
+ display: inline-block;
69
+ box-sizing: border-box;
70
+ position: relative;
71
+ width: em(20, 14);
72
+ height: em(20, 14);
73
+ margin-left: em(5, 14);
74
+ border: em(1, 14) solid;
75
+ border-radius: em(100, 14);
76
+ // Main icon size across views, yet keep responsive for zoom
21
77
  @include govuk-media-query($from: tablet) {
22
- @include govuk-font($size: 16);
78
+ width: em(20, 16);
79
+ height: em(20, 16);
80
+ margin-left: em(5, 16);
81
+ border: em(1, 16) solid;
82
+ }
83
+
84
+ &:after {
85
+ content: "";
86
+ display: block;
87
+ box-sizing: border-box;
88
+ position: absolute;
89
+ overflow: visible;
90
+ width: em(6, 14);
91
+ height: em(6, 14);
92
+ border-top: em(2, 14) solid;
93
+ border-right: em(2, 14) solid;
94
+ transform: rotate(-45deg);
95
+ left: em(6, 14);
96
+ bottom: em(5, 14);
97
+ @include govuk-media-query($from: tablet) {
98
+ width: em(6, 16);
99
+ height: em(6, 16);
100
+ border-top: em(2, 16) solid;
101
+ border-right: em(2, 16) solid;
102
+ left: em(6, 16);
103
+ bottom: em(5, 16);
104
+ }
105
+ }
106
+ }
107
+
108
+ // Rotate icon to create "Down" version
109
+ .gem-c-accordion-nav__chevron--down {
110
+ transform: rotate(180deg);
111
+ }
112
+
113
+ .gem-c-accordion__section-heading {
114
+ // Override browser defaults to ensure consistent element height
115
+ margin-top: 0; // Override browser default
116
+ margin-bottom: 0; // Override browser default
117
+ @include govuk-font(24);
118
+ }
119
+
120
+ // Section headers have a pointer cursor as an additional affordance
121
+ .gem-c-accordion__section-header {
122
+ position: relative;
123
+ }
124
+
125
+ // For devices that can't hover such as touch devices,
126
+ // remove hover state as it can be stuck in that state (iOS).
127
+ @media (hover: none) {
128
+ .gem-c-accordion__section-header:hover {
129
+ border-top-color: $govuk-link-colour;
130
+ box-shadow: inset 0 $gem-c-accordion-border-width 0 0 $govuk-link-colour;
131
+
132
+ .gem-c-accordion__section-button {
133
+ border-top-color: $govuk-link-colour;
134
+ }
135
+ }
136
+ }
137
+
138
+ // Buttons within the headers don’t need default styling
139
+ .gem-c-accordion__section-button {
140
+ padding: govuk-spacing(2) 0 govuk-spacing(5);
141
+ position: relative;
142
+ margin: 0;
143
+ border-width: $gem-c-accordion-bottom-border-width 0 0 0;
144
+ border-top: $gem-c-accordion-bottom-border-width solid $govuk-border-colour;
145
+ color: $govuk-text-colour;
146
+ background: none;
147
+ text-align: left;
148
+ cursor: pointer;
149
+ -webkit-appearance: none;
150
+ @include govuk-typography-common;
151
+ width: 100%;
152
+
153
+ &:active {
154
+ z-index: 1;
155
+ color: $govuk-link-active-colour;
156
+ background: none;
157
+ }
158
+
159
+ // Remove default button focus outline in Firefox
160
+ &::-moz-focus-inner {
161
+ padding: 0;
162
+ border: 0;
163
+ }
164
+ }
165
+
166
+ .gem-c-accordion__section-button:hover {
167
+ color: $govuk-link-colour;
168
+ // On hover, add underline to toggle link
169
+ .gem-c-accordion__toggle-text {
170
+ text-decoration: underline;
171
+ color: $govuk-link-colour;
172
+ }
173
+ }
174
+
175
+ .gem-c-accordion__section-button:focus {
176
+ @include govuk-focused-text;
177
+ // Overwrite focus border to top
178
+ box-shadow: 0 0, 0 -4px;
179
+ border-top: 1px solid transparent;
180
+
181
+ // Focus state to change the toggle link within individual sections
182
+ .gem-c-accordion__toggle-text {
183
+ color: $govuk-focus-text-colour;
184
+ text-decoration: none;
185
+ }
186
+ // Focus state to change chervon icon colour within individual sections
187
+ .gem-c-accordion-nav__chevron {
188
+ color: $govuk-text-colour;
189
+ }
190
+ }
191
+
192
+ // Extend the touch area of the button to span the section header
193
+ .gem-c-accordion__section-button:after {
194
+ content: "";
195
+ position: absolute;
196
+ top: 0;
197
+ right: 0;
198
+ bottom: 0;
199
+ left: 0;
200
+ }
201
+
202
+ .gem-c-accordion__section-button:hover:not(:focus) {
203
+ text-decoration: none;
204
+ }
205
+
206
+ // For devices that can't hover such as touch devices,
207
+ // remove hover state as it can be stuck in that state (iOS).
208
+ @media (hover: none) {
209
+ .gem-c-accordion__section-button:hover {
210
+ text-decoration: none;
211
+ }
212
+ }
213
+
214
+ // Add toggle link with Chevron icon on right.
215
+ .gem-c-accordion__toggle-link {
216
+ display: block;
217
+ color: $govuk-link-colour;
218
+ text-transform: capitalize;
219
+ margin-top: govuk-spacing(1);
220
+ margin-bottom: govuk-spacing(1);
221
+ @include govuk-font($size: 16, $line-height: 1);
222
+
223
+ &:active {
224
+ background: $govuk-link-active-colour;
225
+ }
226
+ }
227
+
228
+ // Setting width of the text, so the icon doesn't shift (left / right) when toggled
229
+ .gem-c-accordion__toggle-text {
230
+ min-width: em(40, 16);
231
+ display: inline-block;
232
+ }
233
+
234
+ .gem-c-accordion__open-all-text {
235
+ min-width: em(120, 16);
236
+ display: inline-block;
237
+ text-align: left;
238
+ }
239
+
240
+ // Change the summary subheading size.
241
+ .gem-c-accordion__section-summary {
242
+ @include govuk-responsive-margin(1, "top");
243
+ @include govuk-responsive-margin(2, "bottom");
244
+ @include govuk-typography-common;
245
+ @include govuk-typography-responsive($size: 19);
246
+ }
247
+
248
+ // Hide body of expanded sections
249
+ .gem-c-accordion__section-content {
250
+ display: none;
251
+ @include govuk-responsive-padding(0, "top");
252
+ @include govuk-responsive-padding(8, "bottom");
253
+ }
254
+
255
+ // Show the body of expanded sections
256
+ .gem-c-accordion__section--expanded .gem-c-accordion__section-content {
257
+ display: block;
258
+ }
259
+
260
+ // Remove the bottom margin from the last item inside the content
261
+ .gem-c-accordion__section-content > :last-child {
262
+ margin-bottom: 0;
263
+ }
264
+
265
+ // Condensed layout
266
+ .gem-c-accordion--condensed {
267
+ .gem-c-accordion__open-all {
268
+ margin-bottom: govuk-spacing(5);
269
+ @include govuk-font($size: 14, $line-height: 1);
270
+ }
271
+
272
+ .gem-c-accordion__section-button {
273
+ @include govuk-typography-responsive($size: 19, $important: true);
274
+ padding-top: govuk-spacing(1);
275
+ padding-bottom: govuk-spacing(5);
276
+ }
277
+
278
+ // Reduce Chevron size
279
+ .gem-c-accordion-nav__chevron {
280
+ width: em(20, 14);
281
+ height: em(20, 14);
282
+ margin-left: em(5, 14);
283
+ border: em(1, 14) solid;
284
+ border-radius: em(100, 14);
285
+ transform: scale(.875);
286
+
287
+ &:after {
288
+ width: em(6, 14);
289
+ height: em(6, 14);
290
+ border-top: em(2, 14) solid;
291
+ border-right: em(2, 14) solid;
292
+ left: em(6, 14);
293
+ bottom: em(5, 14);
294
+ }
295
+ }
296
+
297
+ .gem-c-accordion-nav__chevron--down {
298
+ transform: scale(.875) rotate(180deg);
299
+ }
300
+
301
+ .gem-c-accordion__section-summary {
302
+ @include govuk-typography-responsive($size: 16, $important: true);
303
+ }
304
+
305
+ .gem-c-accordion__toggle-link {
306
+ @include govuk-font($size: 14, $line-height: 1);
23
307
  }
24
308
  }
25
309
  }