@ons/design-system 56.0.2 → 57.0.1

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 (52) hide show
  1. package/components/button/_macro.njk +1 -1
  2. package/components/button/_macro.spec.js +0 -10
  3. package/components/checkboxes/_checkbox-macro.njk +2 -2
  4. package/components/checkboxes/_checkbox-macro.spec.js +2 -2
  5. package/components/checkboxes/checkbox-with-fieldset.js +7 -9
  6. package/components/checkboxes/checkboxes.dom.js +3 -3
  7. package/components/date-input/_macro.spec.js +1 -2
  8. package/components/duration/_macro.spec.js +1 -2
  9. package/components/error/_macro.njk +1 -2
  10. package/components/navigation/_macro.njk +6 -6
  11. package/components/navigation/_macro.spec.js +39 -20
  12. package/components/panel/_macro.njk +1 -1
  13. package/components/panel/_macro.spec.js +14 -7
  14. package/components/radios/_macro.njk +2 -2
  15. package/components/radios/_macro.spec.js +2 -2
  16. package/components/radios/radio-with-fieldset.js +29 -0
  17. package/components/radios/radios.dom.js +7 -8
  18. package/components/radios/radios.spec.js +185 -77
  19. package/components/section-navigation/_macro.njk +1 -1
  20. package/css/census.css +243 -3
  21. package/css/error.css +1 -1
  22. package/css/ids.css +243 -2
  23. package/css/main.css +243 -1
  24. package/css/print.css +1 -1
  25. package/img/UKOpenGovernmentLicence-grey.svg +4 -1
  26. package/img/UKOpenGovernmentLicence.svg +13 -1
  27. package/img/card-placeholder.svg +14 -1
  28. package/img/census-landscape.svg +4514 -1
  29. package/img/census-logo-stacked-pos-billingual.png +0 -0
  30. package/img/census-logo-stacked-pos-cy.png +0 -0
  31. package/img/census-logo-stacked-pos-en.png +0 -0
  32. package/img/census-promo-banner.svg +489 -1
  33. package/img/circle-lines.svg +31 -1
  34. package/img/dummy-brand-logo.svg +6 -1
  35. package/img/icons--check.svg +3 -1
  36. package/img/icons--chevron-down.svg +3 -1
  37. package/img/its-about-us--dark.svg +4 -1
  38. package/img/its-about-us--light.svg +4 -1
  39. package/img/logo.svg +77 -1
  40. package/img/ni-syn-cyfrif--dark.svg +3 -1
  41. package/img/ni-syn-cyfrif--light.svg +3 -1
  42. package/img/nisra-logo-black-en.svg +4 -1
  43. package/img/ogl.svg +10 -1
  44. package/img/ons-logo-black-cy.svg +4 -1
  45. package/img/ons-logo-black-en.svg +4 -1
  46. package/img/people-mob.png +0 -0
  47. package/img/people.png +0 -0
  48. package/img/rehearsal-areas.svg +11 -1
  49. package/package.json +1 -4
  50. package/scripts/main.es5.js +1 -1
  51. package/scripts/main.js +1 -1
  52. package/scss/settings/_ids.scss +5 -5
@@ -58,123 +58,231 @@ const EXAMPLE_RADIOS_PARAMS = {
58
58
  };
59
59
 
60
60
  describe('script: radios', () => {
61
- beforeEach(async () => {
62
- await setTestPage('/test', renderComponent('radios', EXAMPLE_RADIOS_PARAMS));
63
- });
64
-
65
- it('radios with other options should be given aria-expanded attributes', async () => {
66
- const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
67
- expect(ariaExpandedOption1).toBe('false');
68
- const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
69
- expect(ariaExpandedOption2).toBe('false');
70
- });
71
-
72
- it('radios with "open" other options should not be given aria-expanded attributes', async () => {
73
- const hasAriaExpandedOption3 = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
74
- expect(hasAriaExpandedOption3).toBe(false);
75
- });
76
-
77
- describe('a radio checked', () => {
61
+ describe('other options', () => {
78
62
  beforeEach(async () => {
79
- await page.click('#email');
63
+ await setTestPage('/test', renderComponent('radios', EXAMPLE_RADIOS_PARAMS));
80
64
  });
81
65
 
82
- it('then the checked radio aria-expanded attribute should be set to true', async () => {
66
+ it('radios with other options should be given aria-expanded attributes', async () => {
83
67
  const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
84
- expect(ariaExpandedOption1).toBe('true');
85
- });
86
-
87
- it('then the unchecked radio aria-expanded attribute should be set to false', async () => {
68
+ expect(ariaExpandedOption1).toBe('false');
88
69
  const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
89
70
  expect(ariaExpandedOption2).toBe('false');
90
71
  });
91
72
 
92
- it('then the unchecked radio aria-expanded attribute of "open" radio should not be set', async () => {
93
- const hasAriaExpanded = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
94
- expect(hasAriaExpanded).toBe(false);
73
+ it('radios with "open" other options should not be given aria-expanded attributes', async () => {
74
+ const hasAriaExpandedOption3 = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
75
+ expect(hasAriaExpandedOption3).toBe(false);
95
76
  });
96
77
 
97
- it('then the clear button should be visible', async () => {
98
- const isHidden = await page.$eval('.ons-js-clear-btn', node => node.classList.contains('ons-u-db-no-js_enabled'));
99
- expect(isHidden).toBe(false);
100
- });
101
-
102
- it('then the aria live message should announce that the answer can be cleared', async () => {
103
- const alertText = await page.$eval('.ons-js-clear-radio-alert', node => node.innerHTML);
104
- expect(alertText).toBe('You can clear your answer by clicking the clear selection button under the radio buttons');
105
- });
106
-
107
- describe('and the radio selection is changed', () => {
78
+ describe('a radio checked', () => {
108
79
  beforeEach(async () => {
109
- await page.click('#phone');
80
+ await page.click('#email');
110
81
  });
111
82
 
112
83
  it('then the checked radio aria-expanded attribute should be set to true', async () => {
113
- const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
114
- expect(ariaExpandedOption2).toBe('true');
84
+ const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
85
+ expect(ariaExpandedOption1).toBe('true');
115
86
  });
116
87
 
117
88
  it('then the unchecked radio aria-expanded attribute should be set to false', async () => {
118
- const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
119
- expect(ariaExpandedOption1).toBe('false');
89
+ const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
90
+ expect(ariaExpandedOption2).toBe('false');
120
91
  });
121
92
 
122
93
  it('then the unchecked radio aria-expanded attribute of "open" radio should not be set', async () => {
123
94
  const hasAriaExpanded = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
124
95
  expect(hasAriaExpanded).toBe(false);
125
96
  });
126
- });
127
- });
128
97
 
129
- describe('the clear button is clicked', () => {
130
- beforeEach(async () => {
131
- await page.$eval('.ons-js-clear-btn', node => node.click());
132
- });
98
+ it('then the clear button should be visible', async () => {
99
+ const isHidden = await page.$eval('.ons-js-clear-btn', node => node.classList.contains('ons-u-db-no-js_enabled'));
100
+ expect(isHidden).toBe(false);
101
+ });
102
+
103
+ it('then the aria live message should announce that the answer can be cleared', async () => {
104
+ const alertText = await page.$eval('.ons-js-clear-radio-alert', node => node.innerHTML);
105
+ expect(alertText).toBe('You can clear your answer by clicking the clear selection button under the radio buttons');
106
+ });
107
+
108
+ describe('and the radio selection is changed', () => {
109
+ beforeEach(async () => {
110
+ await page.click('#phone');
111
+ });
133
112
 
134
- it('then the clear button should not be visible', async () => {
135
- const isHidden = await page.$eval('.ons-js-clear-btn', node => node.classList.contains('ons-u-db-no-js_enabled'));
136
- expect(isHidden).toBe(true);
113
+ it('then the checked radio aria-expanded attribute should be set to true', async () => {
114
+ const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
115
+ expect(ariaExpandedOption2).toBe('true');
116
+ });
117
+
118
+ it('then the unchecked radio aria-expanded attribute should be set to false', async () => {
119
+ const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
120
+ expect(ariaExpandedOption1).toBe('false');
121
+ });
122
+
123
+ it('then the unchecked radio aria-expanded attribute of "open" radio should not be set', async () => {
124
+ const hasAriaExpanded = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
125
+ expect(hasAriaExpanded).toBe(false);
126
+ });
127
+ });
137
128
  });
138
129
 
139
- it('then the aria live message should announce that the answer has been cleared', async () => {
140
- const alertText = await page.$eval('.ons-js-clear-radio-alert', node => node.innerHTML);
141
- expect(alertText).toBe('You have cleared your answer');
130
+ describe('the clear button is clicked', () => {
131
+ beforeEach(async () => {
132
+ await page.$eval('.ons-js-clear-btn', node => node.click());
133
+ });
134
+
135
+ it('then the clear button should not be visible', async () => {
136
+ const isHidden = await page.$eval('.ons-js-clear-btn', node => node.classList.contains('ons-u-db-no-js_enabled'));
137
+ expect(isHidden).toBe(true);
138
+ });
139
+
140
+ it('then the aria live message should announce that the answer has been cleared', async () => {
141
+ const alertText = await page.$eval('.ons-js-clear-radio-alert', node => node.innerHTML);
142
+ expect(alertText).toBe('You have cleared your answer');
143
+ });
144
+
145
+ it('then all radios should not be checked', async () => {
146
+ const checkedRadios = await page.$$eval('.ons-js-radio', nodes => nodes.map(node => node.checked));
147
+ expect(checkedRadios).not.toContain(true);
148
+ });
149
+
150
+ it('then all other input fields should be empty', async () => {
151
+ const emailOtherValue = await page.$eval('#email-other', node => node.value);
152
+ expect(emailOtherValue).toBe('');
153
+ const telOtherValue = await page.$eval('#tel-other', node => node.value);
154
+ expect(telOtherValue).toBe('');
155
+ const textOtherValue = await page.$eval('#text-other', node => node.value);
156
+ expect(textOtherValue).toBe('');
157
+ });
142
158
  });
143
159
 
144
- it('then all radios should not be checked', async () => {
145
- const checkedRadios = await page.$$eval('.ons-js-radio', nodes => nodes.map(node => node.checked));
146
- expect(checkedRadios).not.toContain(true);
160
+ describe('there is a visible input which is focused', () => {
161
+ beforeEach(async () => {
162
+ await page.focus('#text-other');
163
+ });
164
+
165
+ it('then the radio button should be checked', async () => {
166
+ const isRadioChecked = await page.$eval('#text', node => node.checked);
167
+ expect(isRadioChecked).toBe(true);
168
+ });
147
169
  });
148
170
 
149
- it('then all other input fields should be empty', async () => {
150
- const emailOtherValue = await page.$eval('#email-other', node => node.value);
151
- expect(emailOtherValue).toBe('');
152
- const telOtherValue = await page.$eval('#tel-other', node => node.value);
153
- expect(telOtherValue).toBe('');
154
- const textOtherValue = await page.$eval('#text-other', node => node.value);
155
- expect(textOtherValue).toBe('');
171
+ describe('there is a visible input and the radio is checked', () => {
172
+ beforeEach(async () => {
173
+ await page.click('#text');
174
+ });
175
+
176
+ it('then the input should have a tab index of 0', async () => {
177
+ const tabIndex = await page.$eval('#text-other', node => node.getAttribute('tabindex'));
178
+ expect(tabIndex).toBe('0');
179
+ });
156
180
  });
157
181
  });
158
182
 
159
- describe('there is a visible input which is focused', () => {
183
+ describe('reveal and fieldset', function() {
184
+ const params = {
185
+ legend: 'What are your favourite pizza toppings?',
186
+ name: 'food-other',
187
+ radios: [
188
+ {
189
+ id: 'bacon-other',
190
+ label: {
191
+ text: 'Bacon',
192
+ },
193
+ value: 'bacon',
194
+ },
195
+ {
196
+ id: 'olives-other',
197
+ label: {
198
+ text: 'Olives',
199
+ },
200
+ value: 'olives',
201
+ },
202
+ {
203
+ id: 'other-radio',
204
+ label: {
205
+ text: 'Other',
206
+ description: 'An answer is required',
207
+ },
208
+ value: 'other',
209
+ other: {
210
+ id: 'other-textbox',
211
+ name: 'other-answer',
212
+ legend: 'Please specify other',
213
+ otherType: 'checkboxes',
214
+ checkboxes: [
215
+ {
216
+ id: 'inner-bacon-other',
217
+ label: {
218
+ text: 'Bacon',
219
+ },
220
+ value: 'bacon',
221
+ },
222
+ {
223
+ id: 'inner-olives-other',
224
+ label: {
225
+ text: 'Olives',
226
+ },
227
+ value: 'olives',
228
+ },
229
+ ],
230
+ },
231
+ },
232
+ ],
233
+ };
234
+
160
235
  beforeEach(async () => {
161
- await page.focus('#text-other');
236
+ await setTestPage('/test', renderComponent('radios', params));
162
237
  });
163
238
 
164
- it('then the radio button should be checked', async () => {
165
- const isRadioChecked = await page.$eval('#text', node => node.checked);
166
- expect(isRadioChecked).toBe(true);
239
+ it('radios with other options should be given aria-expanded attributes', async () => {
240
+ const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
241
+ expect(ariaExpanded).toBe('false');
167
242
  });
168
- });
169
243
 
170
- describe('there is a visible input and the radio is checked', () => {
171
- beforeEach(async () => {
172
- await page.click('#text');
173
- });
244
+ describe('and a radio with an other input is checked', () => {
245
+ beforeEach(async () => {
246
+ await page.click('#other-radio');
247
+ });
248
+
249
+ it('has aria-expanded attribute should be set to true', async () => {
250
+ const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
251
+ expect(ariaExpanded).toBe('true');
252
+ });
174
253
 
175
- it('then the input should have a tab index of 0', async () => {
176
- const tabIndex = await page.$eval('#text-other', node => node.getAttribute('tabindex'));
177
- expect(tabIndex).toBe('0');
254
+ describe('and any other radio is changed', () => {
255
+ beforeEach(async () => {
256
+ await page.click('#bacon-other');
257
+ });
258
+
259
+ it('the radio with an other input aria-expanded attribute changes', async () => {
260
+ const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
261
+ expect(ariaExpanded).toBe('false');
262
+ });
263
+ });
264
+
265
+ describe('and a child of other radio is checked', () => {
266
+ beforeEach(async () => {
267
+ await page.click('#inner-bacon-other');
268
+ });
269
+
270
+ describe('and another radio is checked', () => {
271
+ beforeEach(async () => {
272
+ await page.click('#olives-other');
273
+ });
274
+
275
+ it('the other radio aria-expanded attribute should be set to false', async () => {
276
+ const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
277
+ expect(ariaExpanded).toBe('false');
278
+ });
279
+
280
+ it('the child of other checkbox should be unchecked', async () => {
281
+ const innerInputChecked = await page.$eval('#inner-bacon-other', node => node.checked);
282
+ expect(innerInputChecked).toBe(false);
283
+ });
284
+ });
285
+ });
178
286
  });
179
287
  });
180
288
  });
@@ -2,7 +2,7 @@
2
2
  <nav class="ons-section-nav{% if params.variants == 'vertical' %} ons-section-nav--vertical{% endif %}" id="{{ params.id }}" aria-label="{{ params.ariaLabel | default("Section menu") }}">
3
3
  <ul class="ons-section-nav__list">
4
4
  {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
5
- {% if (params.currentPath and (item.url == params.currentPath or item.url in params.currentPath)) or (params.tabQuery and params.tabQuery == item.title|lower) %}
5
+ {% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.title|lower) %}
6
6
  {% set isCurrent = true %}
7
7
  {% else %}
8
8
  {% set isCurrent = false %}