govuk_publishing_components 62.3.0 → 63.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/add-another.js +141 -10
  3. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -1
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_add-another.scss +18 -0
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_figure.scss +10 -32
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +0 -47
  7. data/app/assets/stylesheets/govuk_publishing_components/components/{_previous-and-next-navigation.scss → _pagination.scss} +1 -1
  8. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_images.scss +10 -8
  9. data/app/views/govuk_publishing_components/components/_add_another.html.erb +10 -0
  10. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +2 -1
  11. data/app/views/govuk_publishing_components/components/_figure.html.erb +1 -0
  12. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -2
  13. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +15 -9
  14. data/app/views/govuk_publishing_components/components/_pagination.html.erb +21 -0
  15. data/app/views/govuk_publishing_components/components/docs/add_another.yml +46 -0
  16. data/app/views/govuk_publishing_components/components/docs/figure.yml +16 -15
  17. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +2 -0
  18. data/app/views/govuk_publishing_components/components/docs/image_card.yml +0 -23
  19. data/app/views/govuk_publishing_components/components/docs/{previous_and_next_navigation.yml → pagination.yml} +68 -13
  20. data/config/locales/ar.yml +1 -1
  21. data/config/locales/az.yml +1 -1
  22. data/config/locales/be.yml +1 -1
  23. data/config/locales/bg.yml +1 -1
  24. data/config/locales/bn.yml +1 -1
  25. data/config/locales/cs.yml +1 -1
  26. data/config/locales/cy.yml +2 -2
  27. data/config/locales/da.yml +1 -1
  28. data/config/locales/de.yml +1 -1
  29. data/config/locales/dr.yml +1 -1
  30. data/config/locales/el.yml +1 -1
  31. data/config/locales/en.yml +1 -1
  32. data/config/locales/es-419.yml +1 -1
  33. data/config/locales/es.yml +1 -1
  34. data/config/locales/et.yml +1 -1
  35. data/config/locales/fa.yml +1 -1
  36. data/config/locales/fi.yml +1 -1
  37. data/config/locales/fr.yml +1 -1
  38. data/config/locales/gd.yml +1 -1
  39. data/config/locales/gu.yml +1 -1
  40. data/config/locales/he.yml +1 -1
  41. data/config/locales/hi.yml +1 -1
  42. data/config/locales/hr.yml +1 -1
  43. data/config/locales/hu.yml +1 -1
  44. data/config/locales/hy.yml +1 -1
  45. data/config/locales/id.yml +1 -1
  46. data/config/locales/is.yml +1 -1
  47. data/config/locales/it.yml +1 -1
  48. data/config/locales/ja.yml +1 -1
  49. data/config/locales/ka.yml +1 -1
  50. data/config/locales/kk.yml +1 -1
  51. data/config/locales/ko.yml +1 -1
  52. data/config/locales/ku.yml +1 -1
  53. data/config/locales/ky.yml +1 -1
  54. data/config/locales/lt.yml +1 -1
  55. data/config/locales/lv.yml +1 -1
  56. data/config/locales/ms.yml +1 -1
  57. data/config/locales/mt.yml +1 -1
  58. data/config/locales/ne.yml +1 -1
  59. data/config/locales/nl.yml +1 -1
  60. data/config/locales/no.yml +1 -1
  61. data/config/locales/pa-pk.yml +1 -1
  62. data/config/locales/pa.yml +1 -1
  63. data/config/locales/pl.yml +1 -1
  64. data/config/locales/ps.yml +1 -1
  65. data/config/locales/pt.yml +1 -1
  66. data/config/locales/ro.yml +1 -1
  67. data/config/locales/ru.yml +1 -1
  68. data/config/locales/si.yml +1 -1
  69. data/config/locales/sk.yml +1 -1
  70. data/config/locales/sl.yml +1 -1
  71. data/config/locales/so.yml +1 -1
  72. data/config/locales/sq.yml +1 -1
  73. data/config/locales/sr.yml +1 -1
  74. data/config/locales/sv.yml +1 -1
  75. data/config/locales/sw.yml +1 -1
  76. data/config/locales/ta.yml +1 -1
  77. data/config/locales/th.yml +1 -1
  78. data/config/locales/ti.yml +1 -1
  79. data/config/locales/tk.yml +1 -1
  80. data/config/locales/tr.yml +1 -1
  81. data/config/locales/uk.yml +1 -1
  82. data/config/locales/ur.yml +1 -1
  83. data/config/locales/uz.yml +1 -1
  84. data/config/locales/vi.yml +1 -1
  85. data/config/locales/zh-hk.yml +1 -1
  86. data/config/locales/zh-tw.yml +1 -1
  87. data/config/locales/zh.yml +1 -1
  88. data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +3 -0
  89. data/lib/govuk_publishing_components/presenters/image_card_helper.rb +8 -68
  90. data/lib/govuk_publishing_components/presenters/pagination_helper.rb +130 -0
  91. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +16 -4
  92. data/lib/govuk_publishing_components/version.rb +1 -1
  93. data/lib/govuk_publishing_components.rb +1 -0
  94. metadata +6 -8
  95. data/app/assets/images/govuk_publishing_components/youtube-play-icon.png +0 -0
  96. data/app/assets/images/govuk_publishing_components/youtube-play-icon.svg +0 -4
  97. data/app/assets/javascripts/govuk_publishing_components/components/image-card.js +0 -19
  98. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 877d3b494b073557d9eb1ead7a807dd6a1b669ede799d5cc14646f5b7dfe9e27
4
- data.tar.gz: f5b477c3685c7405690997f8668477d65e45be54976e5115ff62e9b035e160be
3
+ metadata.gz: 6d7be3bd8faf1d55b317bda8101dce15b87de9bc7ef96a090e8394d8f174442f
4
+ data.tar.gz: 77796278e71f2963c5898e84f587ea9ba08bf599ff24a9a7a785aeda2d3d5226
5
5
  SHA512:
6
- metadata.gz: 32838e5c58c4ccbe1c076cc94d210fac0d58a3d9573bb1f05dfba29d06c448a53b312fe8c8cebfb4b0737ffac4885520e2ea4894d5b22fd801ebf70c0ee80b38
7
- data.tar.gz: ae7fbc9735a2e96482c6098a8c1e3f1f370e700f1da77f93ba5c11cd67bb51eb7e0e924fdf436f3666eed64d213006f8adfac19a3f1f0a7775917b32c04b95d3
6
+ metadata.gz: 61d1ad004cbfbcc2eee95cfc4a17930fcb7d38c7bb20b7cbec01861d0aaf35975af38e08d91216a339a1cee6efb0a628acc658439518eb5225c05acf1182907e
7
+ data.tar.gz: a2d709fbe8a6a84a7b0773db6f276d4a02595853039a6c0085a85c9536c048f47faf97ef7356ce7294e7f3e563b0f393505792b55c8dddcad59ac92580af535d
@@ -1,3 +1,4 @@
1
+ //= require sortablejs/Sortable.js
1
2
  window.GOVUK = window.GOVUK || {}
2
3
  window.GOVUK.Modules = window.GOVUK.Modules || {};
3
4
 
@@ -27,6 +28,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
27
28
  this.createAddAnotherButton()
28
29
  this.createRemoveButtons()
29
30
  this.removeEmptyFieldset()
31
+ if (this.module.dataset.sortable === 'true') {
32
+ this.makeSortable()
33
+ }
30
34
  this.updateFieldsetsAndButtons()
31
35
  }
32
36
 
@@ -102,12 +106,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
102
106
  visibleFields.forEach(function (field, index) {
103
107
  field.querySelector('legend').textContent = this.module.dataset.fieldsetLegend + ' ' + (index + 1)
104
108
 
105
- var trackedRemoveButton = field.parentNode.querySelector('.js-add-another__remove-button[data-ga4-event]')
109
+ var trackedButtons = field.parentNode.querySelectorAll(
110
+ '.js-add-another__remove-button[data-ga4-event], .gem-c-add-another__move-button[data-ga4-event]'
111
+ )
106
112
 
107
- if (trackedRemoveButton) {
108
- trackedRemoveButton.dataset.indexSection = this.startIndex + index
109
- trackedRemoveButton.dataset.indexSectionCount = this.indexSectionCount || visibleFields.length
110
- }
113
+ trackedButtons.forEach(function (button) {
114
+ button.dataset.indexSection = this.startIndex + index
115
+ button.dataset.indexSectionCount = this.indexSectionCount || visibleFields.length
116
+ }.bind(this))
111
117
  }.bind(this))
112
118
 
113
119
  if (this.module.dataset.emptyFields === 'false') {
@@ -117,6 +123,10 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
117
123
  )
118
124
  }
119
125
 
126
+ if (this.module.dataset.sortable === 'true') {
127
+ this.disableTopAndBottomButtons()
128
+ }
129
+
120
130
  var trackedAddAnotherButton = this.module.querySelector('.js-add-another__add-button[data-ga4-event]')
121
131
 
122
132
  if (trackedAddAnotherButton) {
@@ -125,15 +135,30 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
125
135
  }
126
136
  }
127
137
 
138
+ // Disable the top "Move up" and bottom "Move down" buttons when the list is sortable.
139
+ AddAnother.prototype.disableTopAndBottomButtons = function () {
140
+ this.module.querySelectorAll('.gem-c-add-another__move-button').forEach(function (button) {
141
+ button.removeAttribute('disabled')
142
+ })
143
+
144
+ var topMoveUpButton = this.module.querySelector('.js-add-another__fieldset:first-of-type .gem-c-add-another__move-button[data-action="move-up"]')
145
+ topMoveUpButton.setAttribute('disabled', true)
146
+
147
+ var bottomMoveDownButton = this.module.querySelector('.js-add-another__fieldset:last-of-type .gem-c-add-another__move-button[data-action="move-down"]')
148
+ bottomMoveDownButton.setAttribute('disabled', true)
149
+ }
150
+
128
151
  AddAnother.prototype.addNewFieldset = function (event) {
129
- var button = event.target
130
152
  var newFieldsetTemplate = this.module.querySelector('.js-add-another__empty-template')
131
153
  var newFieldset = newFieldsetTemplate.content.cloneNode(true).children[0]
132
154
  newFieldset.classList.add('js-add-another__fieldset')
133
155
  this.createRemoveButton(newFieldset, this.removeNewFieldset.bind(this))
134
- button.before(newFieldset)
156
+ newFieldsetTemplate.before(newFieldset)
135
157
 
136
- this.incrementAttributes(newFieldsetTemplate.content)
158
+ this.updateAttributes(newFieldsetTemplate.content)
159
+ if (this.module.dataset.sortable === 'true') {
160
+ this.makeSortable()
161
+ }
137
162
  this.updateFieldsetsAndButtons()
138
163
 
139
164
  // Initialise any modules included in new fieldset
@@ -160,7 +185,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
160
185
  }
161
186
 
162
187
  // Set attribute values for id, for and name of supplied fieldset
163
- AddAnother.prototype.incrementAttributes = function (fieldset) {
188
+ AddAnother.prototype.updateAttributes = function (fieldset, newIndex = null) {
164
189
  var matcher = /(.*[_[])([0-9]+)([_\]].*?)$/
165
190
  fieldset
166
191
  .querySelectorAll('label, input, select, textarea')
@@ -169,11 +194,117 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
169
194
  var value = element.getAttribute(attribute)
170
195
  var matched = matcher.exec(value)
171
196
  if (!matched) return
172
- var index = parseInt(matched[2], 10) + 1
197
+ var index = newIndex == null ? (parseInt(matched[2], 10) + 1) : newIndex
173
198
  element.setAttribute(attribute, matched[1] + index + matched[3])
174
199
  })
175
200
  })
176
201
  }
177
202
 
203
+ AddAnother.prototype.makeSortable = function () {
204
+ this.removeMoveButtons()
205
+ this.addMoveButtons()
206
+ this.hideOrderInputs()
207
+ this.sortableList = window.Sortable.create(this.module, {
208
+ dataIdAttr: 'data-sortable-id',
209
+ disabled: true
210
+ })
211
+ }
212
+
213
+ AddAnother.prototype.getOrderInputs = function () {
214
+ return this.module.querySelectorAll('.js-add-another__fieldset:not([hidden]) .js-add-another__order-input input')
215
+ }
216
+
217
+ AddAnother.prototype.hideOrderInputs = function () {
218
+ this.getOrderInputs().forEach(function (orderInput) {
219
+ orderInput.closest('.js-add-another__order-input').hidden = true
220
+ })
221
+ }
222
+
223
+ AddAnother.prototype.addMoveButtons = function () {
224
+ var visibleFields = this.module.querySelectorAll('.js-add-another__fieldset:not([hidden])')
225
+ visibleFields.forEach(function (field, index) {
226
+ field.dataset.sortableId = 'js-add-another__sortable-' + index + '-fieldset'
227
+ var wrapper = document.createElement('div')
228
+ wrapper.className = 'gem-c-add-another__move-button-wrapper'
229
+ this.addButton(wrapper, 'move-up')
230
+ this.addButton(wrapper, 'move-down')
231
+ field.prepend(wrapper)
232
+ }.bind(this))
233
+ }
234
+
235
+ AddAnother.prototype.addButton = function (wrapper, action) {
236
+ var button = document.createElement('button')
237
+ button.className = 'govuk-button gem-c-button--secondary-quiet gem-c-add-another__move-button'
238
+ button.innerText = action === 'move-up' ? 'Move up' : 'Move down'
239
+ button.dataset.action = action
240
+ if (!this.disableGa4) {
241
+ button.dataset.ga4Event = this.createEventData({ action: action })
242
+ }
243
+
244
+ button.addEventListener('click', this.moveFieldset.bind(this))
245
+ wrapper.prepend(button)
246
+ }
247
+
248
+ AddAnother.prototype.moveFieldset = function (event) {
249
+ event.preventDefault()
250
+
251
+ var button = event.currentTarget
252
+ var action = button.dataset.action
253
+ var fieldset = button.closest('.js-add-another__fieldset')
254
+
255
+ var sortableId = fieldset.dataset.sortableId
256
+
257
+ var order = this.sortableList.toArray()
258
+ var index = order.indexOf(sortableId)
259
+
260
+ // pull the item we're moving out of the order
261
+ order.splice(index, 1)
262
+
263
+ // put it back in at the correct position
264
+ if (action === 'move-down') {
265
+ order.splice(index + 1, 0, sortableId)
266
+ } else if (action === 'move-up') {
267
+ order.splice(index - 1, 0, sortableId)
268
+ }
269
+
270
+ this.sortableList.sort(order, true)
271
+ this.updateFieldsetsAndButtons()
272
+
273
+ var visibleFields = this.module.querySelectorAll('.js-add-another__fieldset:not([hidden])')
274
+ visibleFields.forEach(function (field, index) {
275
+ this.updateAttributes(field, index)
276
+ }.bind(this))
277
+
278
+ var triggeredByKeyboard = event.detail === 0
279
+ if (triggeredByKeyboard) {
280
+ this.preserveElementFocus(button, fieldset, action, visibleFields)
281
+ }
282
+
283
+ this.updateOrderInputs()
284
+ }
285
+
286
+ AddAnother.prototype.preserveElementFocus = function (button, fieldset, action, visibleFields) {
287
+ let target = button
288
+ if (action === 'move-up' && fieldset === visibleFields[0]) {
289
+ target = button.parentNode.querySelector('button[data-action="move-down"]')
290
+ } else if (action === 'move-down' && fieldset === visibleFields[visibleFields.length - 1]) {
291
+ target = button.parentNode.querySelector('button[data-action="move-up"]')
292
+ }
293
+ target.focus()
294
+ }
295
+
296
+ AddAnother.prototype.removeMoveButtons = function () {
297
+ var wrappers = this.module.querySelectorAll('.gem-c-add-another__move-button-wrapper')
298
+ wrappers.forEach((button) => {
299
+ button.remove()
300
+ })
301
+ }
302
+
303
+ AddAnother.prototype.updateOrderInputs = function () {
304
+ this.getOrderInputs().forEach(function (orderInput, index) {
305
+ orderInput.value = index + 1
306
+ })
307
+ }
308
+
178
309
  Modules.AddAnother = AddAnother
179
310
  })(window.GOVUK.Modules)
@@ -65,7 +65,7 @@
65
65
  @import "components/panel";
66
66
  @import "components/password-input";
67
67
  @import "components/phase-banner";
68
- @import "components/previous-and-next-navigation";
68
+ @import "components/pagination";
69
69
  @import "components/print-link";
70
70
  @import "components/published-dates";
71
71
  @import "components/radio";
@@ -11,4 +11,22 @@
11
11
  .js-add-another__remove-button--hidden {
12
12
  display: none;
13
13
  }
14
+
15
+ .gem-c-fieldset {
16
+ position: relative;
17
+ }
18
+
19
+ .gem-c-add-another__move-button[disabled] {
20
+ display: none;
21
+ }
22
+
23
+ .gem-c-add-another__move-button-wrapper {
24
+ position: absolute;
25
+ top: 0;
26
+ right: 0;
27
+ }
28
+
29
+ .gem-c-add-another__move-button {
30
+ margin-left: govuk-spacing(2);
31
+ }
14
32
  }
@@ -1,46 +1,24 @@
1
1
  @import "govuk_publishing_components/individual_component_support";
2
2
 
3
+ $gap: govuk-spacing(1);
4
+
3
5
  .gem-c-figure {
4
- border-top: 1px solid $govuk-border-colour;
5
- padding-top: govuk-spacing(3);
6
6
  margin: 0;
7
- margin-bottom: govuk-spacing(8);
8
- @include govuk-clearfix;
9
-
10
- @include govuk-media-query($until: tablet) {
11
- margin-bottom: govuk-spacing(6);
12
- }
7
+ display: table;
13
8
  }
14
9
 
15
10
  .gem-c-figure__image {
16
- display: block;
17
- width: 100%;
18
-
19
- @include govuk-media-query($from: tablet) {
20
- float: inline-start;
21
- width: 50%;
22
- }
11
+ max-width: 100%;
12
+ display: table-row;
23
13
  }
24
14
 
25
15
  .gem-c-figure__figcaption {
26
- @include govuk-font(16);
27
-
28
- @include govuk-media-query($from: tablet) {
29
- display: block;
30
- vertical-align: top;
31
- box-sizing: border-box;
32
- float: inline-end;
33
- padding-inline-start: govuk-spacing(3);
34
- width: 50%;
35
- }
36
-
37
- @include govuk-media-query($until: tablet) {
38
- margin-top: govuk-spacing(2);
39
- }
16
+ display: table-caption;
17
+ caption-side: bottom;
40
18
  }
41
19
 
42
20
  .gem-c-figure__figcaption-text {
43
- margin: 0;
44
- margin-bottom: govuk-spacing(2);
45
- @include govuk-font(16);
21
+ margin: govuk-spacing(2) 0 0 0;
22
+ color: $govuk-secondary-text-colour;
23
+ @include govuk-font(19);
46
24
  }
@@ -170,53 +170,6 @@
170
170
  }
171
171
  }
172
172
 
173
- // Ensure the YouTube video has a fluid width
174
- // https://alistapart.com/article/creating-intrinsic-ratios-for-video/
175
- .gem-c-image-card__youtube-video-embed {
176
- position: relative;
177
- padding-bottom: 56.25%; /* 16:9 */
178
- height: 0;
179
- }
180
-
181
- .gem-c-image-card__youtube-video-embed iframe {
182
- position: absolute;
183
- top: 0;
184
- left: 0;
185
- width: 100%;
186
- height: 100%;
187
- }
188
-
189
- .gem-c-image-card__youtube-thumbnail-image-container {
190
- position: relative;
191
-
192
- &::before {
193
- background: url("govuk_publishing_components/youtube-play-icon.png");
194
- background: url("govuk_publishing_components/youtube-play-icon.svg"), linear-gradient(transparent, transparent);
195
- background-repeat: no-repeat;
196
- background-position: 50%;
197
- background-size: 75px auto;
198
- content: "";
199
- height: 100%;
200
- left: 0;
201
- position: absolute;
202
- top: 0;
203
- width: 100%;
204
- z-index: 1;
205
- }
206
- }
207
-
208
- .gem-c-image-card__youtube-thumbnail-image {
209
- filter: brightness(.9);
210
- }
211
-
212
- .gem-c-image-card__youtube-thumbnail-container-text {
213
- margin-top: 10px;
214
- }
215
-
216
- .gem-c-image-card__youtube-thumbnail-container:focus .gem-c-image-card__youtube-thumbnail-container-text {
217
- @include govuk-focused-text;
218
- }
219
-
220
173
  // stylelint-disable declaration-no-important
221
174
  @include govuk-media-query($media-type: print) {
222
175
  .gem-c-image-card__title[class*="govuk-heading-"] {
@@ -3,7 +3,7 @@
3
3
 
4
4
  // stylelint-disable declaration-no-important
5
5
  @include govuk-media-query($media-type: print) {
6
- .govuk-pagination * {
6
+ .gem-c-pagination * {
7
7
  color: $govuk-print-text-colour !important;
8
8
  }
9
9
  }
@@ -13,21 +13,23 @@
13
13
  }
14
14
 
15
15
  figure {
16
- width: 100%;
17
- clear: both;
18
- overflow: hidden;
19
16
  margin: 0 0 govuk-spacing(4) 0;
17
+ display: table;
20
18
 
21
19
  img {
22
- display: inline;
23
- text-align: center;
24
- width: auto;
25
- height: auto;
26
20
  max-width: 100%;
21
+ display: table-row;
27
22
  }
28
23
 
29
24
  figcaption {
30
- @include govuk-font($size: 16);
25
+ display: table-caption;
26
+ caption-side: bottom;
27
+ }
28
+
29
+ figcaption p {
30
+ margin: govuk-spacing(2) 0 0 0;
31
+ color: $govuk-secondary-text-colour;
32
+ @include govuk-font(19);
31
33
  }
32
34
  }
33
35
  }
@@ -6,6 +6,7 @@
6
6
  add_button_text ||= "Add another"
7
7
  empty_fields ||= false
8
8
  disable_ga4 ||= nil
9
+ sortable ||= false
9
10
 
10
11
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
11
12
  component_helper.add_class("gem-c-add-another")
@@ -15,6 +16,7 @@
15
16
  fieldset_legend:,
16
17
  empty_fields:,
17
18
  disable_ga4:,
19
+ sortable:,
18
20
  })
19
21
  %>
20
22
 
@@ -26,6 +28,14 @@
26
28
  legend_text: "#{fieldset_legend} #{index + 1}",
27
29
  heading_size: "m",
28
30
  } do %>
31
+ <% if sortable %>
32
+ <div class="js-add-another__order-input">
33
+ <label class="gem-c-label govuk-label">
34
+ Position<span class='govuk-visually-hidden'> for <%= fieldset_legend %></span>
35
+ <%= item[:order_input] %>
36
+ </label>
37
+ </div>
38
+ <% end %>
29
39
  <div class="js-add-another__destroy-checkbox">
30
40
  <%= item[:destroy_checkbox] %>
31
41
  </div>
@@ -5,6 +5,8 @@
5
5
  breadcrumbs ||= []
6
6
  collapse_on_mobile ||= false
7
7
  inverse ||= false
8
+ local_assigns[:aria] ||= {}
9
+ local_assigns[:aria][:label] ||= "Breadcrumb"
8
10
 
9
11
  breadcrumb_presenter = GovukPublishingComponents::Presenters::Breadcrumbs.new(breadcrumbs)
10
12
 
@@ -15,7 +17,6 @@
15
17
 
16
18
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
17
19
  component_helper.add_class(classes.join(" "))
18
- component_helper.add_aria_attribute({ label: "Breadcrumb" })
19
20
  component_helper.add_data_attribute({ module: "ga4-link-tracker" })
20
21
  %>
21
22
 
@@ -5,6 +5,7 @@
5
5
  credit ||= ""
6
6
  src ||= nil
7
7
  local_assigns[:lang] ||= "en"
8
+ local_assigns[:margin_bottom] ||= 8
8
9
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
9
10
  component_helper.add_class("gem-c-figure")
10
11
  %>
@@ -5,7 +5,7 @@
5
5
  brand ||= false
6
6
 
7
7
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
8
- card_helper = GovukPublishingComponents::Presenters::ImageCardHelper.new(local_assigns, brand_helper)
8
+ card_helper = GovukPublishingComponents::Presenters::ImageCardHelper.new(local_assigns)
9
9
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
10
10
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
11
11
  component_helper.add_class("gem-c-image-card")
@@ -33,7 +33,6 @@
33
33
  ]
34
34
  extra_link_classes << brand_helper.color_class
35
35
 
36
- component_helper.add_data_attribute({ module: "image-card" }) if card_helper.youtube_video_id
37
36
  component_helper.set_lang(card_helper.lang)
38
37
  %>
39
38
  <% if card_helper.href || card_helper.extra_details.any? %>
@@ -71,10 +71,12 @@
71
71
  <%= javascript_tag nonce: true do -%>
72
72
  document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');
73
73
  <% end %>
74
- <%= render "govuk_publishing_components/components/cookie_banner", layout_helper.cookie_banner_data %>
75
- <%= render "govuk_publishing_components/components/skip_link", {
76
- href: "#content",
77
- } %>
74
+ <% I18n.with_locale(:en) do %>
75
+ <%= render "govuk_publishing_components/components/cookie_banner", layout_helper.cookie_banner_data %>
76
+ <%= render "govuk_publishing_components/components/skip_link", {
77
+ href: "#content",
78
+ } %>
79
+ <% end %>
78
80
  <% unless omit_header %>
79
81
  <% if show_cross_service_header %>
80
82
  <%= render "govuk_publishing_components/components/cross_service_header", {
@@ -121,15 +123,19 @@
121
123
 
122
124
  <% unless omit_feedback_form %>
123
125
  <div class="govuk-width-container">
124
- <%= render "govuk_publishing_components/components/feedback" %>
126
+ <% I18n.with_locale(:en) do %>
127
+ <%= render "govuk_publishing_components/components/feedback" %>
128
+ <% end %>
125
129
  </div>
126
130
  <% end %>
127
131
 
128
132
  <% unless local_assigns[:hide_footer_links] %>
129
- <%= render "govuk_publishing_components/components/layout_footer", {
130
- navigation: omit_footer_navigation ? nil : layout_helper.footer_navigation,
131
- meta: layout_helper.footer_meta,
132
- } %>
133
+ <% I18n.with_locale(:en) do %>
134
+ <%= render "govuk_publishing_components/components/layout_footer", {
135
+ navigation: omit_footer_navigation ? nil : layout_helper.footer_navigation,
136
+ meta: layout_helper.footer_meta,
137
+ } %>
138
+ <% end %>
133
139
  <% end %>
134
140
  <%= javascript_include_tag "application", type: "module" %>
135
141
  <% if GovukPublishingComponents::Config.use_es6_components %>
@@ -0,0 +1,21 @@
1
+ <%
2
+ add_gem_component_stylesheet("pagination")
3
+ disable_ga4 ||= false
4
+ items ||= nil
5
+
6
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
7
+ component_helper.add_class("gem-c-pagination govuk-pagination")
8
+ component_helper.add_class("govuk-pagination--block") if items.blank?
9
+ component_helper.add_aria_attribute({ label: t("components.pagination.pagination") })
10
+ component_helper.add_data_attribute({ module: "ga4-link-tracker" }) unless disable_ga4
11
+
12
+ pagination_helper = GovukPublishingComponents::Presenters::PaginationHelper.new(local_assigns)
13
+
14
+ if pagination_helper.has_links?
15
+ %>
16
+ <%= tag.nav(**component_helper.all_attributes) do %>
17
+ <%= pagination_helper.prev_link %>
18
+ <%= pagination_helper.page_links %>
19
+ <%= pagination_helper.next_link %>
20
+ <% end %>
21
+ <% end %>
@@ -121,3 +121,49 @@ examples:
121
121
  <option value="92bbe2da-8d5f-480b-8da1-50b18e317654">Accelerated Capability Environment</option>
122
122
  </select>
123
123
  <div class="govuk-form-group">
124
+ sortable:
125
+ description: |
126
+ Adding `sortable` to the component will allow users to rearrange the items in the list.
127
+
128
+ This component uses SortableJS. When JavaScript is disabled a set of inputs will be shown allowing users to
129
+ provide an order index for each item.
130
+
131
+ For this to work, each field must have an `order_index` input provided.
132
+ data:
133
+ fieldset_legend: "Person"
134
+ add_button_text: "Add another person"
135
+ sortable: true
136
+ items:
137
+ - fields: >
138
+ <div class="govuk-form-group">
139
+ <label for="sortable_person_0_name" class="gem-c-label govuk-label">Full name</label>
140
+ <input class="gem-c-input govuk-input" id="sortable_person_0_name" name="person[0]name" value="Person A">
141
+ </div>
142
+ destroy_checkbox: >
143
+ <div class="govuk-checkboxes" data-module="govuk-checkboxes">
144
+ <div class="govuk-checkboxes__item">
145
+ <input type="checkbox" name="person[0][_destroy]" id="sortable_person_0__destroy" class="govuk-checkboxes__input">
146
+ <label for="sortable_person_0__destroy" class="govuk-label govuk-checkboxes__label">Delete</label>
147
+ </div>
148
+ </div>
149
+ order_input: >
150
+ <input class="gem-c-input govuk-input govuk-input--width-2" id="sortable_person_0_order" name="person[0]order" value="1">
151
+ - fields: >
152
+ <div class="govuk-form-group">
153
+ <label for="sortable_person_1_name" class="gem-c-label govuk-label">Full name</label>
154
+ <input class="gem-c-input govuk-input" id="sortable_person_1_name" name="person[1]name" value="Person B">
155
+ </div>
156
+ destroy_checkbox: >
157
+ <div class="govuk-checkboxes" data-module="govuk-checkboxes">
158
+ <div class="govuk-checkboxes__item">
159
+ <input type="checkbox" name="person[1][_destroy]" id="sortable_person_1__destroy" class="govuk-checkboxes__input">
160
+ <label for="sortable_person_1__destroy" class="govuk-label govuk-checkboxes__label">Delete</label>
161
+ </div>
162
+ </div>
163
+ order_input: >
164
+ <input class="gem-c-input govuk-input govuk-input--width-2" id="sortable_person_1_order" name="person[1]order" value="2">
165
+ empty:
166
+ <div class="govuk-form-group">
167
+ <label for="sortable_person_2_name" class="gem-c-label govuk-label">Full name</label>
168
+ <input class="gem-c-input govuk-input" id="sortable_person_2_name" name="person[2]name">
169
+ </div>
@@ -1,5 +1,5 @@
1
1
  name: Figure
2
- description: A figure containing an image that never exceeds the component’s width
2
+ description: A figure containing an image and optional caption.
3
3
  body: |
4
4
  A figure should be used for images that are referenced within a page, but which can be moved around without affecting the flow of the page [(see guidance here)](https://developer.mozilla.org/en/docs/Web/HTML/Element/figure)
5
5
 
@@ -15,29 +15,30 @@ uses_component_wrapper_helper: true
15
15
  examples:
16
16
  default:
17
17
  data:
18
- src: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg'
18
+ src: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg
19
19
  figure_with_alt_text:
20
20
  data:
21
- src: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg'
22
- alt: 'An image of the lords chamber'
21
+ src: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg
22
+ alt: An image of the lords chamber
23
23
  figure_with_caption:
24
+ description: The image will fill the available space but not exceed the width of the container or its own width. The caption will always be the same width as the image.
24
25
  data:
25
- src: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg'
26
- alt: 'An image of the lords chamber'
27
- caption: 'The Lords Chamber'
26
+ src: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg
27
+ alt: An image of the lords chamber
28
+ caption: The Lords Chamber on the 14th of August. A large number of people are in attendance, filling the seats in the lower and upper areas. Several people are wearing hats.
28
29
  right_to_left_with_caption:
29
30
  data:
30
- src: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/image_data/file/31637/s300_Visas_-_Website.jpg'
31
- alt: 'تأشيرات'
32
- caption: 'تأشيرات'
31
+ src: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/image_data/file/31637/s300_Visas_-_Website.jpg
32
+ alt: تأشيرات
33
+ caption: تأشيرات
33
34
  context:
34
35
  right_to_left: true
35
36
  figure_with_credit:
36
37
  data:
37
- src: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg'
38
- credit: Wallis Crankled
38
+ src: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg
39
+ credit: Roger Harris
39
40
  figure_with_caption_and_credit:
40
41
  data:
41
- src: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg'
42
- caption: The Lords Chamber
43
- credit: Wallis Crankled
42
+ src: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg
43
+ caption: The Lords Chamber on the 14th of August. A large number of people are in attendance, filling the seats in the lower and upper areas. Several people are wearing hats.
44
+ credit: Roger Harris
@@ -849,6 +849,7 @@ examples:
849
849
  <h5>This is a h5 title</h5>
850
850
  <h6>This is a h6 title</h6>
851
851
  image:
852
+ description: Govspeak images are styled to mimic the [figure component](/component-guide/figure).
852
853
  data:
853
854
  block: |
854
855
  <figure class="image embedded">
@@ -859,6 +860,7 @@ examples:
859
860
  <p>Deforested area. Credit: Blue Ventures-Garth Cripps</p>
860
861
  </figcaption>
861
862
  </figure>
863
+ <p>This is a regular paragraph of text to demonstrate the spacing between it and the image above.</p>
862
864
  lists:
863
865
  data:
864
866
  block: |