govuk_publishing_components 21.63.1 → 21.65.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (21) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/govuk_publishing_components/action-link-arrow--transparent.svg +1 -0
  3. data/app/assets/javascripts/govuk_publishing_components/components/govspeak.js +17 -15
  4. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js +18 -11
  5. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +423 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +8 -2
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +1 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +1 -4
  9. data/app/views/govuk_publishing_components/components/_action_link.html.erb +2 -0
  10. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -4
  11. data/app/views/govuk_publishing_components/components/_radio.html.erb +3 -1
  12. data/app/views/govuk_publishing_components/components/_search.html.erb +6 -2
  13. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +2 -2
  14. data/app/views/govuk_publishing_components/components/docs/action_link.yml +8 -0
  15. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +3 -1
  16. data/lib/govuk_publishing_components/presenters/breadcrumbs.rb +0 -4
  17. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +19 -5
  18. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +1 -1
  19. data/lib/govuk_publishing_components/version.rb +1 -1
  20. metadata +4 -3
  21. data/app/assets/javascripts/govuk_publishing_components/vendor/magna-charta.min.js +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3ed71c773cb4f6409dd9cc3d66bd408cb33ab8863f5ee57dbe7fa90826e1441
4
- data.tar.gz: 8ce3c6af6d3b1ba38890d11edbebb59e7c3895fae29f2794351e23ea9fad4697
3
+ metadata.gz: 00cb9ed2b1890ec679368a5b6565f425ab630a8c7576e36ec05572f7b82def5e
4
+ data.tar.gz: c252f946b8c435ff7dcfc4a4f68453cbf653b1e3cc71d1fe85c1060c2e6a0df9
5
5
  SHA512:
6
- metadata.gz: e670252b190a6866a5018c4f951e1e2ddf84dfde4e8049bcc3bf415bfb286c4985cb3fa8d6dd81fade33f4ecaed467cd6dede70e8044fe82f59dbfd42e6656dd
7
- data.tar.gz: d955747b6ceac131a320b9d9ebadcb78e1937e3fab2cae1e339cbf48355525a18b6285210c0f889a8cd7004e2a026960e3f0edd03cf56b5b16ad1717ac4bbb0f
6
+ metadata.gz: 88c4f14857cdab94770e04b4ca84f9733f10855b43bc6706f87960d6ff552c8de581071c1aa80da8460e34de43ded3534cbed2c76a371f4c50d62edff361f994
7
+ data.tar.gz: ffad88268390f0a57eeb6eb31b77c8f88b53d21eb0cff4fa6ed399899ff32ca8519f4c1f7bccc2e2fc5e161ee95d91ff749e7356c9bc9ff25288aef71b66a85f
@@ -0,0 +1 @@
1
+ <svg width="39" height="39" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.01 6.818l-2.828 2.828 7.853 7.854-22 .066L0 21.5h22.035l-7.853 7.854 2.828 2.828L29.69 19.5zM39 19.5C39 30.27 30.27 39 19.5 39 9.373 39 1.05 31.28.092 21.405A19.737 19.737 0 010 19.5C0 8.73 8.73 0 19.5 0S39 8.73 39 19.5z" fill="#fff500"/></svg>
@@ -2,25 +2,27 @@ window.GOVUK = window.GOVUK || {}
2
2
  window.GOVUK.Modules = window.GOVUK.Modules || {};
3
3
 
4
4
  (function (Modules) {
5
- 'use strict'
5
+ function Govspeak () { }
6
6
 
7
- Modules.Govspeak = function () {
8
- this.start = function ($element) {
9
- if (!$element.hasClass('disable-youtube')) {
10
- this.embedYoutube($element)
11
- }
7
+ Govspeak.prototype.start = function ($module) {
8
+ this.$module = $module[0]
12
9
 
13
- this.createBarcharts($element)
10
+ if (this.$module.className.indexOf('disable-youtube') === -1) {
11
+ this.embedYoutube()
14
12
  }
15
13
 
16
- this.embedYoutube = function ($jqElement) {
17
- var enhancement = new window.GOVUK.GovspeakYoutubeLinkEnhancement($jqElement[0])
18
- enhancement.init()
19
- }
14
+ this.createBarcharts()
15
+ }
20
16
 
21
- this.createBarcharts = function ($element) {
22
- var enhancement = new window.GOVUK.GovspeakBarchartEnhancement($element)
23
- enhancement.init()
24
- }
17
+ Govspeak.prototype.embedYoutube = function () {
18
+ var enhancement = new window.GOVUK.GovspeakYoutubeLinkEnhancement(this.$module)
19
+ enhancement.init()
25
20
  }
21
+
22
+ Govspeak.prototype.createBarcharts = function () {
23
+ var enhancement = new window.GOVUK.GovspeakBarchartEnhancement(this.$module)
24
+ enhancement.init()
25
+ }
26
+
27
+ Modules.Govspeak = Govspeak
26
28
  })(window.GOVUK.Modules)
@@ -1,4 +1,4 @@
1
- // = require govuk_publishing_components/vendor/magna-charta.min
1
+ // = require govuk_publishing_components/lib/govspeak/magna-charta
2
2
 
3
3
  window.GOVUK = window.GOVUK || {};
4
4
 
@@ -10,16 +10,23 @@ window.GOVUK = window.GOVUK || {};
10
10
  }
11
11
 
12
12
  BarchartEnhancement.prototype.init = function () {
13
- // the not selectors are protection against initialising twice since that
14
- // causes quite a mess. The not .mc-chart is because it creates a second
15
- // .js-barchart-table element with .mc-chart and then the
16
- // .js-barchart-table-init is given when we initialise
17
- var $barcharts = this.$element.find('.js-barchart-table:not(.mc-chart):not(.js-barchart-table-init)')
18
- $barcharts.each(function () {
19
- var $table = $(this)
20
- $.magnaCharta($table, { toggleText: 'Change between chart and table' })
21
- $table.addClass('js-barchart-table-init')
22
- })
13
+ var $barchartsOriginal = this.$element.querySelectorAll('.js-barchart-table')
14
+ var $barcharts = []
15
+
16
+ for (var j = 0; j < $barchartsOriginal.length; j++) {
17
+ // this prevents the code from initialising more than once
18
+ // we'd use :not selectors for $barchartsOriginal but for lack of IE8 support
19
+ var styles = $barchartsOriginal[j].className
20
+ if (styles.indexOf('mc-chart') === -1 && styles.indexOf('js-barchart-table-init') === -1) {
21
+ $barcharts.push($barchartsOriginal[j])
22
+ }
23
+ }
24
+
25
+ for (var i = 0; i < $barcharts.length; i++) {
26
+ var $table = $barcharts[i]
27
+ new GOVUK.Modules.MagnaCharta().start($table, { toggleText: 'Change between chart and table' })
28
+ $table.className = $table.className + ' js-barchart-table-init'
29
+ }
23
30
  }
24
31
 
25
32
  GOVUK.GovspeakBarchartEnhancement = BarchartEnhancement
@@ -0,0 +1,423 @@
1
+ //= require govuk/vendor/polyfills/Element/prototype/classList.js
2
+ // This is a non-jQuery version of Magna Charta: https://github.com/alphagov/magna-charta
3
+ window.GOVUK = window.GOVUK || {}
4
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
5
+
6
+ (function (Modules) {
7
+ function MagnaCharta () { }
8
+
9
+ MagnaCharta.prototype.start = function ($module, options) {
10
+ this.$module = $module[0]
11
+ this.options = {
12
+ outOf: 65,
13
+ applyOnInit: true,
14
+ toggleText: 'Toggle between chart and table',
15
+ autoOutdent: false,
16
+ outdentAll: false,
17
+ toggleAfter: false, // BOOL set TRUE to append the toggle link
18
+ returnReference: false // for testing purposes
19
+ }
20
+
21
+ for (var k in options) this.options[k] = options[k]
22
+ this.detectIEVersion()
23
+
24
+ // Magna Charta doesn't work in IE7 or less - so plain tables are shown to those browsers
25
+ this.ENABLED = !(this.ie && this.ie < 8)
26
+
27
+ // store a reference to the table in the object
28
+ this.$table = $module
29
+
30
+ // lets make what will become the new graph
31
+ this.$graph = document.createElement('div')
32
+
33
+ // set the graph to aria-hidden, which isn't changed at any point
34
+ // the graph is totally inaccessible, so we let screen readers navigate the table
35
+ // and ignore the graph entirely
36
+ this.$graph.setAttribute('aria-hidden', 'true')
37
+
38
+ // copy over classes from the table, and add the extra one
39
+ this.$graph.setAttribute('class', this.$table.className)
40
+ this.$graph.classList.add('mc-chart')
41
+
42
+ // set the stacked option based on
43
+ // giving the table a class of mc-stacked
44
+ this.options.stacked = this.$table.classList.contains('mc-stacked')
45
+
46
+ // set the negative option based on
47
+ // giving the table a class of mc-negative
48
+ this.options.negative = this.$table.classList.contains('mc-negative')
49
+
50
+ // true if it's a 'multiple' table
51
+ // this means multiple bars per rows, but not stacked.
52
+ var moreThanTwoTDs = this.$table.querySelectorAll('tbody tr')[0].querySelectorAll('td').length > 2
53
+ this.options.multiple = !this.options.stacked && (this.$table.classList.contains('mc-multiple') || moreThanTwoTDs)
54
+
55
+ // set the outdent options
56
+ // which can be set via classes or overriden by setting the value to true
57
+ // in the initial options object that's passed in
58
+ this.options.autoOutdent = this.options.autoOutdent || this.$table.classList.contains('mc-auto-outdent')
59
+
60
+ this.options.outdentAll = this.options.outdentAll || this.$table.classList.contains('mc-outdented')
61
+
62
+ // add a mc-multiple class if it is
63
+ if (this.options.multiple) {
64
+ this.$graph.classList.add('mc-multiple')
65
+ }
66
+
67
+ this.options.hasCaption = !!this.$table.querySelectorAll('caption').length
68
+
69
+ if (this.ENABLED) {
70
+ this.apply()
71
+ // if applyOnInit is false, toggle immediately to show the table and hide the graph
72
+ if (!this.options.applyOnInit) {
73
+ this.toggleLink.click()
74
+ }
75
+ }
76
+
77
+ if (this.options.returnReference) {
78
+ return this
79
+ }
80
+ }
81
+
82
+ MagnaCharta.prototype.detectIEVersion = function () {
83
+ // detect IE version: James Padolsey, https://gist.github.com/527683
84
+ this.ie = (function () {
85
+ var undef
86
+ var v = 3
87
+ var div = document.createElement('div')
88
+ var all = div.getElementsByTagName('i')
89
+
90
+ do {
91
+ div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->'
92
+ } while (v < 10 && all[0])
93
+
94
+ return (v > 4) ? v : undef
95
+ })()
96
+ }
97
+
98
+ MagnaCharta.prototype.apply = function () {
99
+ if (this.ENABLED) {
100
+ this.constructChart()
101
+ this.addClassesToHeader()
102
+ this.applyWidths()
103
+ this.insert()
104
+ this.$table.classList.add('visually-hidden')
105
+ this.applyOutdent()
106
+ }
107
+ }
108
+
109
+ // methods for constructing the chart
110
+ MagnaCharta.prototype.construct = {}
111
+
112
+ // constructs the header
113
+ MagnaCharta.prototype.construct.thead = function () {
114
+ var thead = document.createElement('div')
115
+ thead.classList.add('mc-thead')
116
+
117
+ var tr = document.createElement('div')
118
+ tr.classList.add('mc-tr')
119
+
120
+ var output = ''
121
+ var allTheTHs = this.$table.querySelectorAll('th')
122
+
123
+ for (var i = 0; i < allTheTHs.length; i++) {
124
+ output += '<div class="mc-th">'
125
+ output += allTheTHs[i].innerHTML
126
+ output += '</div>'
127
+ }
128
+
129
+ tr.innerHTML = output
130
+ thead.appendChild(tr)
131
+
132
+ return thead
133
+ }
134
+
135
+ MagnaCharta.prototype.construct.tbody = function () {
136
+ var tbody = document.createElement('div')
137
+ tbody.classList.add('mc-tbody')
138
+
139
+ var allTheTbodyTrs = this.$table.querySelectorAll('tbody tr')
140
+
141
+ for (var i = 0; i < allTheTbodyTrs.length; i++) {
142
+ var tr = document.createElement('div')
143
+ tr.classList.add('mc-tr')
144
+
145
+ var cellsOutput = ''
146
+ var allTheTds = allTheTbodyTrs[i].querySelectorAll('td')
147
+
148
+ for (var j = 0; j < allTheTds.length; j++) {
149
+ cellsOutput += '<div class="mc-td">'
150
+ cellsOutput += allTheTds[j].innerHTML
151
+ cellsOutput += '</div>'
152
+ }
153
+ tr.innerHTML = cellsOutput
154
+ tbody.appendChild(tr)
155
+ }
156
+
157
+ return tbody
158
+ }
159
+
160
+ MagnaCharta.prototype.construct.caption = function () {
161
+ var cap = this.$table.querySelector('caption')
162
+ return cap.cloneNode(true)
163
+ }
164
+
165
+ // construct a link to allow the user to toggle between chart and table
166
+ MagnaCharta.prototype.construct.toggleLink = function (toggleText) {
167
+ var link = document.createElement('a')
168
+ link.setAttribute('href', '#')
169
+ link.classList.add('mc-toggle-link')
170
+ link.innerHTML = toggleText
171
+ link.setAttribute('aria-hidden', 'true')
172
+
173
+ return link
174
+ }
175
+
176
+ // toggles between showing the table and showing the chart
177
+ MagnaCharta.prototype.addToggleClick = function () {
178
+ var that = this
179
+
180
+ this.toggleLink.addEventListener('click', function (e) {
181
+ e.preventDefault()
182
+ that.$graph.classList.toggle('visually-hidden')
183
+ that.$table.classList.toggle('visually-hidden')
184
+ })
185
+ }
186
+
187
+ MagnaCharta.prototype.constructChart = function () {
188
+ // turn every element in the table into divs with appropriate classes
189
+ // call them and define this as scope so it's easier to
190
+ // get at options and properties
191
+ var thead = this.construct.thead.call(this)
192
+ var tbody = this.construct.tbody.call(this)
193
+ this.toggleLink = this.construct.toggleLink(this.options.toggleText)
194
+ this.addToggleClick(this.toggleLink)
195
+
196
+ if (this.options.hasCaption) {
197
+ var caption = this.construct.caption.call(this)
198
+ this.$graph.appendChild(caption)
199
+ }
200
+
201
+ if (this.options.toggleAfter) {
202
+ this.$table.insertAdjacentElement('afterend', this.toggleLink)
203
+ } else {
204
+ this.$table.insertAdjacentElement('beforebegin', this.toggleLink)
205
+ }
206
+
207
+ this.$graph.appendChild(thead)
208
+ this.$graph.appendChild(tbody)
209
+ }
210
+
211
+ // some handy utility methods
212
+ MagnaCharta.prototype.utils = {
213
+ isFloat: function (val) {
214
+ return !isNaN(parseFloat(val))
215
+ },
216
+ stripValue: function (val) {
217
+ var re = new RegExp('\\,|£|%|[a-z]', 'gi')
218
+ return val.replace(re, '')
219
+ },
220
+ returnMax: function (values) {
221
+ var max = 0
222
+ for (var i = 0; i < values.length; i++) {
223
+ if (values[i] > max) { max = values[i] }
224
+ }
225
+ return max
226
+ },
227
+ isNegative: function (value) {
228
+ return (value < 0)
229
+ }
230
+ }
231
+
232
+ MagnaCharta.prototype.addClassesToHeader = function () {
233
+ var headerCells = this.$graph.querySelectorAll('.mc-th')
234
+ var looplength = headerCells.length
235
+
236
+ if (this.options.stacked) {
237
+ var last = looplength - 1
238
+ headerCells[last].classList.add('mc-stacked-header', 'mc-header-total')
239
+ looplength -= 1
240
+ }
241
+
242
+ // we deliberately don't apply this to the first cell
243
+ for (var i = 1; i < looplength; i++) {
244
+ headerCells[i].classList.add('mc-key-header')
245
+ if (!headerCells[i].classList.contains('mc-stacked-header')) {
246
+ headerCells[i].classList.add('mc-key-' + i)
247
+ }
248
+ }
249
+ }
250
+
251
+ MagnaCharta.prototype.calculateMaxWidth = function () {
252
+ // store the cell values in here so we can figure out the maximum value later
253
+ var values = []
254
+
255
+ // var to store the maximum negative value (used only for negative charts)
256
+ var maxNegativeValue = 0
257
+
258
+ // loop through every tr in the table
259
+ var trs = this.$graph.querySelectorAll('.mc-tr')
260
+ for (var i = 0; i < trs.length; i++) {
261
+ var $this = trs[i]
262
+
263
+ // the first td is going to be the key, so ignore it
264
+ // we'd use $this.querySelectorAll('.mc-td:not(:first-child)') but for IE8
265
+ var $bodyCellsOriginal = $this.querySelectorAll('.mc-td')
266
+ var $bodyCells = []
267
+ for (var k = 1; k < $bodyCellsOriginal.length; k++) {
268
+ $bodyCells.push($bodyCellsOriginal[k])
269
+ }
270
+
271
+ var bodyCellsLength = $bodyCells.length
272
+
273
+ // might be the row containing th elements, so we need to check
274
+ if (bodyCellsLength) {
275
+ // if it's stacked, the last column is a totals
276
+ // so we don't want that in our calculations
277
+ if (this.options.stacked) {
278
+ $bodyCells[bodyCellsLength - 1].classList.add('mc-stacked-total')
279
+ bodyCellsLength -= 1
280
+ }
281
+
282
+ // first td in each row is key
283
+ var firstCell = $this.querySelector('.mc-td')
284
+ if (firstCell) {
285
+ firstCell.classList.add('mc-key-cell')
286
+ }
287
+
288
+ // store the total value of the bar cells in a row
289
+ // for anything but stacked, this is just the value of one <td>
290
+ var cellsTotalValue = 0
291
+
292
+ for (var j = 0; j < bodyCellsLength; j++) {
293
+ var $cell = $bodyCells[j]
294
+ $cell.classList.add('mc-bar-cell')
295
+ $cell.classList.add('mc-bar-' + (j + 1))
296
+ var cellVal = this.utils.stripValue($cell.innerText)
297
+
298
+ if (this.utils.isFloat(cellVal)) {
299
+ var parsedVal = parseFloat(cellVal, 10)
300
+ var absParsedVal = Math.abs(parsedVal)
301
+ if (parsedVal === 0) {
302
+ $cell.classList.add('mc-bar-zero')
303
+ }
304
+
305
+ if (this.options.negative) {
306
+ if (this.utils.isNegative(parsedVal)) {
307
+ $cell.classList.add('mc-bar-negative')
308
+ if (absParsedVal > maxNegativeValue) {
309
+ maxNegativeValue = absParsedVal
310
+ }
311
+ } else {
312
+ $cell.classList.add('mc-bar-positive')
313
+ }
314
+ }
315
+ // now we are done with our negative calculations
316
+ // set parsedVal to absParsedVal
317
+ parsedVal = absParsedVal
318
+
319
+ if (!this.options.stacked) {
320
+ cellsTotalValue = parsedVal
321
+ values.push(parsedVal)
322
+ } else {
323
+ cellsTotalValue += parsedVal
324
+ }
325
+ }
326
+ }
327
+ }
328
+
329
+ // if stacked, we need to push the total value of the row to the values array
330
+ if (this.options.stacked) { values.push(cellsTotalValue) }
331
+ }
332
+
333
+ var resp = {}
334
+ resp.max = parseFloat(this.utils.returnMax(values), 10)
335
+ resp.single = parseFloat(this.options.outOf / resp.max, 10)
336
+
337
+ if (this.options.negative) {
338
+ resp.marginLeft = parseFloat(maxNegativeValue, 10) * resp.single
339
+ resp.maxNegative = parseFloat(maxNegativeValue, 10)
340
+ }
341
+
342
+ return resp
343
+ }
344
+
345
+ MagnaCharta.prototype.applyWidths = function () {
346
+ this.dimensions = this.calculateMaxWidth()
347
+ var trs = this.$graph.querySelectorAll('.mc-tr')
348
+
349
+ for (var i = 0; i < trs.length; i++) {
350
+ var cells = trs[i].querySelectorAll('.mc-bar-cell')
351
+
352
+ for (var j = 0; j < cells.length; j++) {
353
+ var $cell = cells[j]
354
+ var parsedCellVal = parseFloat(this.utils.stripValue($cell.innerText), 10)
355
+ var parsedVal = parsedCellVal * this.dimensions.single
356
+ var absParsedCellVal = Math.abs(parsedCellVal)
357
+ var absParsedVal = Math.abs(parsedVal)
358
+
359
+ // apply the left margin to the positive bars
360
+ if (this.options.negative) {
361
+ if ($cell.classList.contains('mc-bar-positive')) {
362
+ $cell.style.marginLeft = this.dimensions.marginLeft + '%'
363
+ } else {
364
+ // if its negative but not the maximum negative
365
+ // we need to give it enough margin to push it further right to align
366
+ if (absParsedCellVal < this.dimensions.maxNegative) {
367
+ // left margin needs to be (largestNegVal - thisNegVal) * single
368
+ var leftMarg = (this.dimensions.maxNegative - absParsedCellVal) * this.dimensions.single
369
+ $cell.style.marginLeft = leftMarg + '%'
370
+ }
371
+ }
372
+ }
373
+
374
+ // wrap the cell value in a span tag
375
+ $cell.innerHTML = '<span>' + $cell.innerHTML + '</span>'
376
+ $cell.style.width = absParsedVal + '%'
377
+ }
378
+ }
379
+ }
380
+
381
+ MagnaCharta.prototype.insert = function () {
382
+ this.$table.insertAdjacentElement('afterend', this.$graph)
383
+ }
384
+
385
+ MagnaCharta.prototype.applyOutdent = function () {
386
+ /*
387
+ * this figures out if a cell needs an outdent and applies it
388
+ * it needs an outdent if the width of the text is greater than the width of the bar
389
+ * if this is the case, wrap the value in a span, and use absolute positioning
390
+ * to push it out (the bar is styled to be relative)
391
+ * unfortunately this has to be done once the chart has been inserted
392
+ */
393
+ var cells = this.$graph.querySelectorAll('.mc-bar-cell')
394
+
395
+ for (var i = 0; i < cells.length; i++) {
396
+ var $cell = cells[i]
397
+ var cellVal = parseFloat(this.utils.stripValue($cell.innerText), 10)
398
+ var $cellSpan = $cell.querySelector('span')
399
+ var spanWidth = parseFloat(window.getComputedStyle($cellSpan, null).width.replace('px', '')) + 10 // +10 just for extra padding
400
+ var cellWidth = parseFloat(window.getComputedStyle($cell, null).width.replace('px', ''))
401
+
402
+ if (!this.options.stacked) {
403
+ // if it's 0, it is effectively outdented
404
+ if (cellVal === 0) { $cell.classList.add('mc-bar-outdented') }
405
+
406
+ if ((this.options.autoOutdent && spanWidth > cellWidth) || this.options.outdentAll) {
407
+ $cell.classList.add('mc-bar-outdented')
408
+ $cellSpan.style.marginLeft = '100%'
409
+ $cellSpan.style.display = 'inline-block'
410
+ } else {
411
+ $cell.classList.add('mc-bar-indented')
412
+ }
413
+ } else {
414
+ // if it's a stacked graph
415
+ if (spanWidth > cellWidth && cellVal > 0) {
416
+ $cell.classList.add('mc-value-overflow')
417
+ }
418
+ }
419
+ }
420
+ }
421
+
422
+ Modules.MagnaCharta = MagnaCharta
423
+ })(window.GOVUK.Modules)
@@ -4,13 +4,13 @@
4
4
  &:before {
5
5
  content: "";
6
6
  display: table-cell;
7
- width: 50px;
7
+ width: 60px;
8
8
  height: 45px;
9
9
  background: image-url("govuk_publishing_components/action-link-arrow.png");
10
10
  background: image-url("govuk_publishing_components/action-link-arrow.svg"), linear-gradient(transparent, transparent);
11
11
  background-repeat: no-repeat;
12
12
  background-position: 0 50%;
13
- background-size: 37px auto;
13
+ background-size: 45px auto;
14
14
  }
15
15
 
16
16
  @include govuk-media-query($until: tablet) {
@@ -141,6 +141,12 @@
141
141
  }
142
142
  }
143
143
 
144
+ .gem-c-action-link--transparent-icon {
145
+ &:before {
146
+ background-image: image-url("govuk_publishing_components/action-link-arrow--transparent.svg");
147
+ }
148
+ }
149
+
144
150
  .gem-c-action-link--nhs {
145
151
  &:before {
146
152
  width: 80px;
@@ -12,6 +12,7 @@
12
12
  margin: 0;
13
13
  min-width: 0;
14
14
  padding: govuk-spacing(1);
15
+ box-sizing: border-box;
15
16
 
16
17
  &.gem-c-input--search-icon {
17
18
  padding-left: govuk-spacing(6);
@@ -10,6 +10,7 @@ $large-input-size: 50px;
10
10
  @include govuk-font($size: 19, $line-height: $input-size);
11
11
  display: block;
12
12
  background: govuk-colour("white");
13
+ color: $govuk-text-colour;
13
14
 
14
15
  h1 {
15
16
  @include govuk-font($size: 19, $line-height: $input-size);
@@ -129,10 +130,6 @@ $large-input-size: 50px;
129
130
  }
130
131
 
131
132
  .gem-c-search--on-govuk-blue {
132
- .gem-c-search__label {
133
- color: govuk-colour("white");
134
- }
135
-
136
133
  .gem-c-search__input {
137
134
  border-width: 0;
138
135
 
@@ -13,6 +13,7 @@
13
13
  dark_icon ||= false
14
14
  small_icon ||= false
15
15
  nhs_icon ||= false
16
+ transparent_icon ||= false
16
17
  data ||= nil
17
18
  classes ||= nil
18
19
 
@@ -20,6 +21,7 @@
20
21
  css_classes << "gem-c-action-link--light-text" if light_text
21
22
  css_classes << "gem-c-action-link--dark-icon" if dark_icon
22
23
  css_classes << "gem-c-action-link--small-icon" if small_icon
24
+ css_classes << "gem-c-action-link--transparent-icon" if transparent_icon
23
25
  css_classes << "gem-c-action-link--nhs" if nhs_icon
24
26
  css_classes << "gem-c-action-link--simple" if simple
25
27
  css_classes << "gem-c-action-link--with-subtext" if subtext
@@ -17,16 +17,13 @@
17
17
  <ol class="govuk-breadcrumbs__list">
18
18
  <% breadcrumbs.each_with_index do |crumb, index| %>
19
19
  <% breadcrumb = GovukPublishingComponents::Presenters::Breadcrumb.new(crumb, index) %>
20
- <li class="govuk-breadcrumbs__list-item" aria-current="<%= breadcrumb.aria_current %>">
20
+ <li class="govuk-breadcrumbs__list-item">
21
21
  <% if breadcrumb.is_link? %>
22
22
  <%= link_to(
23
23
  breadcrumb[:title],
24
24
  breadcrumb.path,
25
25
  data: breadcrumb.tracking_data(breadcrumbs.length),
26
26
  class: "govuk-breadcrumbs__link",
27
- aria: {
28
- current: breadcrumb.aria_current,
29
- }
30
27
  ) %>
31
28
  <% else %>
32
29
  <%= breadcrumb[:title] %>
@@ -53,7 +53,9 @@
53
53
  <%= tag.h1 heading, class: "gem-c-radio__heading-text govuk-fieldset__heading" %>
54
54
  <% end %>
55
55
  <% else %>
56
- <%= tag.legend heading, class: legend_classes %>
56
+ <%= tag.legend class: legend_classes do %>
57
+ <%= tag.h2 heading, class: "govuk-fieldset__heading" %>
58
+ <% end %>
57
59
  <% end %>
58
60
  <% end %>
59
61
 
@@ -2,12 +2,16 @@
2
2
  size ||= ""
3
3
  no_border ||= false
4
4
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
5
- classes = %w(gem-c-search gem-c-search--on-white)
5
+ classes = %w(gem-c-search)
6
6
  classes << (shared_helper.get_margin_top)
7
7
  classes << (shared_helper.get_margin_bottom) if local_assigns[:margin_bottom]
8
8
  classes << "gem-c-search--large" if size == 'large'
9
9
  classes << "gem-c-search--no-border" if no_border
10
- classes << "gem-c-search--on-govuk-blue" if local_assigns[:on_govuk_blue].eql?(true)
10
+ if local_assigns[:on_govuk_blue].eql?(true)
11
+ classes << "gem-c-search--on-govuk-blue"
12
+ else
13
+ classes << "gem-c-search--on-white"
14
+ end
11
15
  classes << "gem-c-search--separate-label" if local_assigns.include?(:inline_label)
12
16
 
13
17
  value ||= ""
@@ -28,7 +28,7 @@
28
28
  <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
29
29
  </script>
30
30
 
31
- <div class="<%= classes %>" data-module="track-click">
31
+ <h2 class="<%= classes %>" data-module="track-click">
32
32
  <span class="gem-c-step-nav-header__part-of">Part of</span>
33
33
  <% if path %>
34
34
  <a href="<%= path %>"
@@ -51,5 +51,5 @@
51
51
  <%= title %>
52
52
  </span>
53
53
  <% end %>
54
- </div>
54
+ </h2>
55
55
  <% end %>
@@ -36,6 +36,14 @@ examples:
36
36
  light_text: true
37
37
  context:
38
38
  dark_background: true
39
+ with_transparent_svg:
40
+ data:
41
+ text: Find out what you need to do
42
+ href: "/page"
43
+ light_text: true
44
+ transparent_icon: true
45
+ context:
46
+ dark_background: true
39
47
  with_subtext:
40
48
  data:
41
49
  text: Emergency something
@@ -3,7 +3,9 @@ description: Shows that a content page is part of a step by step navigation
3
3
  body: |
4
4
  The component indicates to the user that the current page is part of a [step by step navigation](/component-guide/step_by_step_nav), and can provide a link to it.
5
5
  accessibility_criteria: |
6
- The component is designed to go into the top of an existing content page and should not interfere with the heading structure of the page, so therefore should not contain a heading tag.
6
+ The component is designed to go into the top of an existing content page. This component looks like a heading so uses a heading level 2 element.
7
+
8
+ An earlier version of the component did not use a heading element &ndash; this failed WCAG 2.1 Success Criterion 1.3.1 ("Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text.")
7
9
 
8
10
  An early version of the component contained a hidden skip link for keyboard and screen reader users, that jumped to the step by step navigation component in the sidebar (similiar to the 'skip to content' link at the top of all GOV.UK pages). User testing suggested that rather than helping users it confused them, so this has been removed.
9
11
  shared_accessibility_criteria:
@@ -49,10 +49,6 @@ module GovukPublishingComponents
49
49
  crumb[:url]
50
50
  end
51
51
 
52
- def aria_current
53
- "false"
54
- end
55
-
56
52
  def tracking_data(breadcrumbs_length)
57
53
  data = {
58
54
  track_category: "breadcrumbClicked",
@@ -12,18 +12,22 @@ module GovukPublishingComponents
12
12
  }.freeze
13
13
 
14
14
  # Returns the highest priority taxon that has a content_id matching those in PRIORITY_TAXONS
15
- def self.call(content_item)
16
- new(content_item).breadcrumbs
15
+ def self.call(content_item, query_parameters = nil)
16
+ new(content_item, query_parameters).breadcrumbs
17
17
  end
18
18
 
19
- attr_reader :content_item
19
+ attr_reader :content_item, :query_parameters
20
20
 
21
- def initialize(content_item)
21
+ def initialize(content_item, query_parameters = nil)
22
22
  @content_item = content_item
23
+ @query_parameters = query_parameters
23
24
  end
24
25
 
25
26
  def taxon
26
- @taxon ||= priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
27
+ @taxon ||= begin
28
+ default_taxon = priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
29
+ preferred_taxon || default_taxon
30
+ end
27
31
  end
28
32
 
29
33
  def breadcrumbs
@@ -39,6 +43,12 @@ module GovukPublishingComponents
39
43
 
40
44
  private
41
45
 
46
+ def preferred_taxon
47
+ if preferred_priority_taxon
48
+ priority_taxons.find { |t| t["content_id"] == preferred_priority_taxon }
49
+ end
50
+ end
51
+
42
52
  def priority_taxons
43
53
  return [] unless content_item["links"].is_a?(Hash)
44
54
 
@@ -57,6 +67,10 @@ module GovukPublishingComponents
57
67
  def priority_taxon?(taxon)
58
68
  PRIORITY_TAXONS.values.include?(taxon["content_id"])
59
69
  end
70
+
71
+ def preferred_priority_taxon
72
+ query_parameters["priority-taxon"] if query_parameters
73
+ end
60
74
  end
61
75
  end
62
76
  end
@@ -30,7 +30,7 @@ module GovukPublishingComponents
30
30
  end
31
31
 
32
32
  def priority_breadcrumbs
33
- @priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item)
33
+ @priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item, query_parameters)
34
34
  end
35
35
 
36
36
  def topic_breadcrumbs
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.63.1".freeze
2
+ VERSION = "21.65.1".freeze
3
3
  end
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: 21.63.1
4
+ version: 21.65.1
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: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -320,6 +320,7 @@ files:
320
320
  - app/assets/images/govuk_publishing_components/action-link-arrow--dark.svg
321
321
  - app/assets/images/govuk_publishing_components/action-link-arrow--simple.png
322
322
  - app/assets/images/govuk_publishing_components/action-link-arrow--simple.svg
323
+ - app/assets/images/govuk_publishing_components/action-link-arrow--transparent.svg
323
324
  - app/assets/images/govuk_publishing_components/action-link-arrow.png
324
325
  - app/assets/images/govuk_publishing_components/action-link-arrow.svg
325
326
  - app/assets/images/govuk_publishing_components/chevron-banner/chevron-banner-small-focus.svg
@@ -419,6 +420,7 @@ files:
419
420
  - app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js
420
421
  - app/assets/javascripts/govuk_publishing_components/lib/current-location.js
421
422
  - app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
423
+ - app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js
422
424
  - app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js
423
425
  - app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
424
426
  - app/assets/javascripts/govuk_publishing_components/lib/primary-links.js
@@ -428,7 +430,6 @@ files:
428
430
  - app/assets/javascripts/govuk_publishing_components/modules.js
429
431
  - app/assets/javascripts/govuk_publishing_components/vendor/html5shiv-printshiv.js
430
432
  - app/assets/javascripts/govuk_publishing_components/vendor/json2.js
431
- - app/assets/javascripts/govuk_publishing_components/vendor/magna-charta.min.js
432
433
  - app/assets/javascripts/govuk_publishing_components/vendor/modernizr.js
433
434
  - app/assets/javascripts/govuk_publishing_components/vendor/polyfills/closest.js
434
435
  - app/assets/javascripts/govuk_publishing_components/vendor/polyfills/indexOf.js
@@ -1,4 +0,0 @@
1
- /*! Magna Charta - v3.0.0 - 2012-12-04
2
- * https://github.com/alphagov/magna-charta
3
- */
4
- (function(e){var t=function(){this.init=function(t,n){var r={outOf:65,applyOnInit:!0,toggleText:"Toggle between chart and table",autoOutdent:!1,outdentAll:!1};this.options=e.extend({},r,n);var i=function(){var e,t=3,n=document.createElement("div"),r=n.getElementsByTagName("i");do n.innerHTML="<!--[if gt IE "+ ++t+"]><i></i><![endif]-->";while(t<10&&r[0]);return t>4?t:e}();return this.ENABLED=!(i&&i<8),this.$table=t,this.$graph=e("<div/>").attr("aria-hidden","true"),this.$graph.attr("class",this.$table.attr("class")).addClass("mc-chart"),this.options.stacked=this.$table.hasClass("mc-stacked"),this.options.negative=this.$table.hasClass("mc-negative"),this.options.multiple=!this.options.stacked&&(this.$table.hasClass("mc-multiple")||this.$table.find("tbody tr").first().find("td").length>2),this.options.autoOutdent=this.options.autoOutdent||this.$table.hasClass("mc-auto-outdent"),this.options.outdentAll=this.options.outdentAll||this.$table.hasClass("mc-outdented"),this.options.multiple&&this.$graph.addClass("mc-multiple"),this.options.hasCaption=!!this.$table.find("caption").length,this.ENABLED&&(this.apply(),this.options.applyOnInit||this.toggle()),this}};t.prototype.construct={},t.prototype.construct.thead=function(){var t=e("<div />",{"class":"mc-thead"}),n=e("<div />",{"class":"mc-tr"}),r="";return this.$table.find("th").each(function(t,n){r+='<div class="mc-th">',r+=e(n).html(),r+="</div>"}),n.append(r),t.append(n),t},t.prototype.construct.tbody=function(){var t=e("<div />",{"class":"mc-tbody"}),n="";return this.$table.find("tbody tr").each(function(n,r){var i=e("<div />",{"class":"mc-tr"}),s="";e(r).find("td").each(function(t,n){s+='<div class="mc-td">',s+=e(n).html(),s+="</div>"}),i.append(s),t.append(i)}),t},t.prototype.construct.caption=function(){var e=this.$table.find("caption");return e.clone()},t.prototype.construct.toggleLink=function(){var t=this;return e("<a />",{href:"#","class":"mc-toggle-link",text:this.options.toggleText}).on("click",function(e){t.toggle(e)})},t.prototype.constructChart=function(){var e=this.construct.thead.call(this),t=this.construct.tbody.call(this),n=this.construct.toggleLink.call(this);if(this.options.hasCaption){var r=this.construct.caption.call(this);this.$graph.append(r)}this.$table.before(n),this.$graph.append(e),this.$graph.append(t)},t.prototype.apply=function(){this.ENABLED&&(this.constructChart(),this.addClassesToHeader(),this.calculateMaxWidth(),this.applyWidths(),this.insert(),this.$table.addClass("visually-hidden"),this.applyOutdent())},t.prototype.toggle=function(e){this.$graph.toggle(),this.$table.toggleClass("visually-hidden"),e&&e.preventDefault()},t.prototype.utils={isFloat:function(e){return!isNaN(parseFloat(e))},stripValue:function(e){var t=new RegExp("\\,|£|%|[a-z]","gi");return e.replace(t,"")},returnMax:function(e){var t=0;for(var n=0;n<e.length;n++)e[n]>t&&(t=e[n]);return t},isNegative:function(e){return e<0}},t.prototype.addClassesToHeader=function(){var t=this.$graph.find(".mc-th").filter(":not(:first)");this.options.stacked&&(t.last().addClass("mc-stacked-header mc-header-total"),t=t.filter(":not(:last)")),t.addClass("mc-key-header").filter(":not(.mc-stacked-header)").each(function(t,n){e(n).addClass("mc-key-"+(t+1))})},t.prototype.calculateMaxWidth=function(){var t=this,n=[],r=0;this.$graph.find(".mc-tr").each(function(i,s){var o=e(s),u=o.find(".mc-td:not(:first)");if(t.options.stacked){var a=u.last().addClass("mc-stacked-total");u=u.filter(":not(:last)")}o.find(".mc-td:first").addClass("mc-key-cell");var f=0;u.each(function(i,s){var o=e(s).addClass("mc-bar-cell").addClass("mc-bar-"+(i+1)),u=t.utils.stripValue(o.text());if(t.utils.isFloat(u)){var a=parseFloat(u,10),l=Math.abs(a);a===0&&o.addClass("mc-bar-zero"),t.options.negative&&(t.utils.isNegative(a)?(o.addClass("mc-bar-negative"),l>r&&(r=l)):o.addClass("mc-bar-positive")),a=l,t.options.stacked?f+=a:(f=a,n.push(a))}}),t.options.stacked&&n.push(f)});var i={};return i.max=parseFloat(t.utils.returnMax(n),10),i.single=parseFloat(this.options.outOf/i.max,10),this.options.negative&&(i.marginLeft=parseFloat(r,10)*i.single,i.maxNegative=parseFloat(r,10)),i},t.prototype.applyWidths=function(){this.dimensions=this.calculateMaxWidth();var t=this;this.$graph.find(".mc-tr").each(function(n,r){var i=e(r),s=i.find(".mc-bar-cell:not(.mc-bar-zero)").length;i.find(".mc-bar-cell").each(function(n,r){var i=e(r),s=parseFloat(t.utils.stripValue(i.text()),10),o=s*t.dimensions.single,u=Math.abs(s),a=Math.abs(o);if(t.options.negative)if(i.hasClass("mc-bar-positive"))i.css("margin-left",t.dimensions.marginLeft+"%");else if(u<t.dimensions.maxNegative){var f=(t.dimensions.maxNegative-u)*t.dimensions.single;i.css("margin-left",f+"%")}i.wrapInner("<span />"),i.css("width",a+"%")})})},t.prototype.insert=function(){this.$table.after(this.$graph)},t.prototype.applyOutdent=function(){var t=this,n=this.$graph.find(".mc-bar-cell");this.$graph.find(".mc-bar-cell").each(function(n,r){var i=e(r),s=parseFloat(t.utils.stripValue(i.text()),10),o=i.children("span"),u=o.width()+10,a=i.width(),f=parseFloat(i[0].style.width,10),l=i.height();t.options.stacked?u>a&&s>0&&i.addClass("mc-value-overflow"):(s===0&&i.addClass("mc-bar-outdented"),t.options.autoOutdent&&u>a||t.options.outdentAll?(i.addClass("mc-bar-outdented"),o.css({"margin-left":"100%",display:"inline-block"})):i.addClass("mc-bar-indented"))})},e.magnaCharta=function(e,n){return(new t).init(e,n)}})(jQuery);