@ons/design-system 68.0.0 → 68.0.2
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.
- package/README.md +6 -0
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +2 -10
- package/components/access-code/access-code.dom.js +1 -1
- package/components/access-code/access-code.spec.js +2 -2
- package/components/access-code/example-access-code-error.njk +9 -14
- package/components/access-code/example-access-code.njk +3 -5
- package/components/accordion/accordion.js +4 -4
- package/components/address-input/_macro.spec.js +3 -15
- package/components/address-input/autosuggest.address.dom.js +1 -1
- package/components/address-input/autosuggest.address.js +3 -2
- package/components/address-input/autosuggest.address.setter.js +3 -3
- package/components/address-input/autosuggest.address.spec.js +66 -69
- package/components/address-output/_macro.spec.js +6 -30
- package/components/autosuggest/_autosuggest.scss +1 -1
- package/components/autosuggest/autosuggest.dom.js +1 -1
- package/components/autosuggest/autosuggest.helpers.js +1 -1
- package/components/back-to-top/_back-to-top.scss +34 -0
- package/components/back-to-top/_macro.njk +17 -0
- package/components/back-to-top/_macro.spec.js +60 -0
- package/components/back-to-top/back-to-top.dom.js +12 -0
- package/components/back-to-top/back-to-top.js +58 -0
- package/components/back-to-top/back-to-top.spec.js +117 -0
- package/components/back-to-top/example-back-to-top.njk +37 -0
- package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
- package/components/browser-banner/_macro.spec.js +4 -12
- package/components/button/_macro.njk +6 -6
- package/components/button/_macro.spec.js +1 -5
- package/components/button/button.js +7 -8
- package/components/button/button.spec.js +17 -39
- package/components/call-to-action/_macro.spec.js +2 -6
- package/components/card/_macro.njk +25 -25
- package/components/card/_macro.spec.js +10 -34
- package/components/char-check-limit/_macro.njk +1 -1
- package/components/char-check-limit/_macro.spec.js +3 -7
- package/components/char-check-limit/character-check.spec.js +24 -20
- package/components/checkboxes/_checkbox-macro.njk +1 -1
- package/components/checkboxes/_checkbox.scss +0 -3
- package/components/checkboxes/_macro.spec.js +1 -5
- package/components/checkboxes/checkbox-with-autoselect.js +3 -3
- package/components/checkboxes/checkbox-with-fieldset.js +2 -2
- package/components/checkboxes/checkboxes-with-reveal.js +4 -2
- package/components/checkboxes/checkboxes.dom.js +2 -2
- package/components/checkboxes/checkboxes.spec.js +13 -13
- package/components/content-pagination/_macro.spec.js +2 -2
- package/components/cookies-banner/cookies-banner.dom.js +1 -1
- package/components/cookies-banner/cookies-banner.js +1 -1
- package/components/cookies-banner/cookies-banner.spec.js +7 -7
- package/components/date-input/_macro.njk +71 -69
- package/components/date-input/_macro.spec.js +20 -5
- package/components/date-input/example-date-input-double-field.njk +27 -0
- package/components/date-input/example-date-input-single-field.njk +18 -0
- package/components/details/details.spec.js +12 -12
- package/components/details/example-details-with-warning.njk +5 -7
- package/components/document-list/_macro.spec.js +9 -27
- package/components/document-list/document-list.scss +1 -1
- package/components/document-list/example-document-list-downloads.njk +3 -3
- package/components/document-list/example-document-list-search-result-featured.njk +1 -1
- package/components/document-list/example-document-list-search-results.njk +3 -3
- package/components/download-resources/download-resources.js +54 -54
- package/components/download-resources/download-resources.spec.js +3 -1
- package/components/duration/_macro.njk +52 -48
- package/components/duration/_macro.spec.js +112 -4
- package/components/duration/example-duration-error-for-single-field.njk +1 -1
- package/components/duration/example-duration-single-field.njk +24 -0
- package/components/error/_macro.njk +1 -1
- package/components/error/_macro.spec.js +2 -6
- package/components/feedback/_macro.njk +1 -1
- package/components/feedback/_macro.spec.js +4 -20
- package/components/field/_field-group.scss +3 -4
- package/components/field/_macro.spec.js +1 -3
- package/components/fieldset/_fieldset.scss +1 -2
- package/components/fieldset/_macro.spec.js +3 -9
- package/components/footer/_footer.scss +8 -0
- package/components/footer/_macro.njk +8 -7
- package/components/footer/_macro.spec.js +14 -2
- package/components/header/_macro.njk +1 -1
- package/components/header/_macro.spec.js +1 -1
- package/components/helpers/grid.njk +15 -15
- package/components/icon/_macro.njk +17 -13
- package/components/icon/_macro.spec.js +8 -16
- package/components/image/_macro.spec.js +1 -5
- package/components/input/_macro.njk +22 -23
- package/components/input/_macro.spec.js +1 -1
- package/components/input/character-check.dom.js +1 -1
- package/components/input/input.spec.js +1 -4
- package/components/label/_label.scss +1 -0
- package/components/label/_macro.njk +3 -3
- package/components/label/_macro.spec.js +4 -13
- package/components/list/_macro.spec.js +4 -12
- package/components/message/_macro.njk +17 -17
- package/components/message/_macro.spec.js +9 -33
- package/components/message-list/_macro.spec.js +7 -39
- package/components/metadata/_macro.njk +10 -10
- package/components/modal/_macro.spec.js +3 -9
- package/components/modal/modal.dom.js +1 -1
- package/components/modal/modal.spec.js +5 -5
- package/components/multiple-input-fields/_macro.njk +49 -0
- package/components/mutually-exclusive/_macro.spec.js +2 -10
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +128 -14
- package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +129 -8
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.js +13 -13
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
- package/components/navigation/navigation.spec.js +0 -2
- package/components/pagination/_macro.spec.js +11 -53
- package/components/panel/_macro.njk +17 -17
- package/components/panel/_macro.spec.js +25 -25
- package/components/panel/_panel.scss +10 -9
- package/components/panel/example-panel-bare.njk +3 -4
- package/components/panel/example-panel-with-announcement.njk +6 -10
- package/components/panel/example-panel-with-error-summary.njk +2 -2
- package/components/panel/example-panel-with-information.njk +0 -1
- package/components/panel/example-panel-with-success-message.njk +1 -1
- package/components/panel/example-panel-with-warning.njk +2 -3
- package/components/password/password.dom.js +1 -1
- package/components/phase-banner/_macro.spec.js +3 -9
- package/components/question/_macro.njk +1 -1
- package/components/question/_macro.spec.js +5 -19
- package/components/question/_question.scss +1 -4
- package/components/question/example-question-interviewer-note.njk +1 -1
- package/components/quote/_macro.spec.js +2 -10
- package/components/radios/clear-radios.js +3 -3
- package/components/radios/radio-with-fieldset.js +4 -4
- package/components/radios/radios.dom.js +1 -1
- package/components/radios/radios.spec.js +26 -26
- package/components/related-content/_macro.spec.js +2 -4
- package/components/related-content/_section-macro.spec.js +2 -8
- package/components/relationships/example-relationships-error.njk +16 -18
- package/components/relationships/relationships.dom.js +1 -1
- package/components/relationships/relationships.js +2 -2
- package/components/reply/_macro.spec.js +3 -3
- package/components/reply/reply.dom.js +1 -1
- package/components/reply/reply.spec.js +3 -3
- package/components/section-navigation/_macro.njk +12 -12
- package/components/section-navigation/_macro.spec.js +13 -21
- package/components/select/_macro.spec.js +6 -6
- package/components/share-page/_macro.spec.js +6 -14
- package/components/skip-to-content/_macro.spec.js +3 -11
- package/components/skip-to-content/skip-to-content.dom.js +1 -1
- package/components/skip-to-content/skip-to-content.js +1 -1
- package/components/skip-to-content/skip-to-content.spec.js +2 -2
- package/components/status/_macro.njk +2 -2
- package/components/status/_macro.spec.js +5 -9
- package/components/status/example-status-dead.njk +1 -1
- package/components/status/example-status-error.njk +1 -1
- package/components/status/example-status-pending.njk +1 -1
- package/components/status/example-status-small.njk +1 -1
- package/components/status/example-status-success.njk +2 -2
- package/components/summary/_macro.njk +7 -8
- package/components/summary/_macro.spec.js +27 -9
- package/components/table/_macro.spec.js +6 -10
- package/components/table/scrollable-table.dom.js +1 -1
- package/components/table/scrollable-table.js +1 -1
- package/components/table/sortable-table.js +4 -4
- package/components/table/table.spec.js +21 -17
- package/components/table-of-contents/_macro.njk +31 -31
- package/components/table-of-contents/_macro.spec.js +3 -11
- package/components/table-of-contents/toc.dom.js +1 -1
- package/components/table-of-contents/toc.spec.js +36 -32
- package/components/tabs/example-tabs-details.njk +1 -1
- package/components/tabs/tabs.dom.js +1 -1
- package/components/tabs/tabs.js +8 -8
- package/components/text-indent/_macro.spec.js +2 -6
- package/components/textarea/textarea.dom.js +1 -1
- package/components/textarea/textarea.spec.js +8 -8
- package/components/timeout-modal/_macro.spec.js +1 -3
- package/components/timeout-modal/timeout-modal.dom.js +1 -1
- package/components/timeout-modal/timeout-modal.spec.js +10 -10
- package/components/timeout-panel/_macro.njk +16 -17
- package/components/timeout-panel/_macro.spec.js +1 -1
- package/components/timeout-panel/timeout-panel.dom.js +1 -1
- package/components/timeout-panel/timeout-panel.spec.js +8 -8
- package/components/video/_macro.spec.js +1 -5
- package/components/video/video.dom.js +1 -1
- package/components/video/video.spec.js +16 -12
- package/css/main.css +1 -1
- package/favicons/safari-pinned-tab.svg +23 -23
- package/js/analytics.js +12 -15
- package/js/cookies-settings.dom.js +1 -1
- package/js/cookies-settings.spec.js +19 -19
- package/js/domready.js +1 -1
- package/js/fetch.js +1 -1
- package/js/inpagelink.js +3 -3
- package/js/main.js +1 -0
- package/js/print-button.js +1 -1
- package/js/timeout.js +1 -1
- package/package.json +2 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_typography.scss +8 -2
- package/scss/main.scss +1 -0
- package/scss/overrides/hcm.scss +8 -1
- package/scss/vars/_colors.scss +2 -1
- package/components/date-field-input/_macro.njk +0 -86
|
@@ -11,6 +11,15 @@ const EXAMPLE_DURATION_INPUT_BASE = {
|
|
|
11
11
|
description: 'Enter “0” into the years field if you have lived at this address for less than a year',
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
const EXAMPLE_DURATION_INPUT_BASE_WITH_ERROR = {
|
|
15
|
+
id: 'duration',
|
|
16
|
+
legendOrLabel: 'How long have you lived at this address?',
|
|
17
|
+
description: 'Enter “0” into the years field if you have lived at this address for less than a year',
|
|
18
|
+
error: {
|
|
19
|
+
text: 'Enter how long you have lived at this address',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
14
23
|
const EXAMPLE_FIELD_1 = {
|
|
15
24
|
field1: {
|
|
16
25
|
id: 'address-duration-years',
|
|
@@ -35,6 +44,45 @@ const EXAMPLE_FIELD_2 = {
|
|
|
35
44
|
},
|
|
36
45
|
};
|
|
37
46
|
|
|
47
|
+
const EXAMPLE_FIELD_1_WITH_ERROR = {
|
|
48
|
+
field1: {
|
|
49
|
+
id: 'address-duration-years',
|
|
50
|
+
name: 'address-duration-years',
|
|
51
|
+
value: '0',
|
|
52
|
+
error: true,
|
|
53
|
+
suffix: {
|
|
54
|
+
text: 'Years',
|
|
55
|
+
id: 'address-duration-years-suffix',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const EXAMPLE_FIELD_2_WITH_ERROR = {
|
|
61
|
+
field2: {
|
|
62
|
+
id: 'address-duration-months',
|
|
63
|
+
name: 'address-duration-months',
|
|
64
|
+
value: '0',
|
|
65
|
+
error: true,
|
|
66
|
+
suffix: {
|
|
67
|
+
text: 'Months',
|
|
68
|
+
id: 'address-duration-months-suffix',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const EXAMPLE_FIELD_1_WITH_ERROR_FALSE = {
|
|
74
|
+
field1: {
|
|
75
|
+
id: 'address-duration-years',
|
|
76
|
+
name: 'address-duration-years',
|
|
77
|
+
value: '0',
|
|
78
|
+
error: false,
|
|
79
|
+
suffix: {
|
|
80
|
+
text: 'Years',
|
|
81
|
+
id: 'address-duration-years-suffix',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
38
86
|
const EXAMPLE_DURATION_SINGLE_FIELD = {
|
|
39
87
|
...EXAMPLE_DURATION_INPUT_BASE,
|
|
40
88
|
...EXAMPLE_FIELD_1,
|
|
@@ -46,6 +94,23 @@ const EXAMPLE_DURATION_MULTIPLE_FIELDS = {
|
|
|
46
94
|
...EXAMPLE_FIELD_2,
|
|
47
95
|
};
|
|
48
96
|
|
|
97
|
+
const EXAMPLE_DURATION_MULTIPLE_FIELDS_WITH_SINGLE_ERROR = {
|
|
98
|
+
...EXAMPLE_DURATION_INPUT_BASE_WITH_ERROR,
|
|
99
|
+
...EXAMPLE_FIELD_1,
|
|
100
|
+
...EXAMPLE_FIELD_2_WITH_ERROR,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const EXAMPLE_DURATION_MULTIPLE_FIELDS_WITH_ERROR = {
|
|
104
|
+
...EXAMPLE_DURATION_INPUT_BASE_WITH_ERROR,
|
|
105
|
+
...EXAMPLE_FIELD_1_WITH_ERROR,
|
|
106
|
+
...EXAMPLE_FIELD_2_WITH_ERROR,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const EXAMPLE_DURATION_MULTIPLE_FIELDS_WITH_ERROR_FALSE = {
|
|
110
|
+
...EXAMPLE_DURATION_INPUT_BASE,
|
|
111
|
+
...EXAMPLE_FIELD_1_WITH_ERROR_FALSE,
|
|
112
|
+
};
|
|
113
|
+
|
|
49
114
|
describe('macro: duration', () => {
|
|
50
115
|
describe('mode: multiple fields', () => {
|
|
51
116
|
it('passes jest-axe checks', async () => {
|
|
@@ -109,6 +174,12 @@ describe('macro: duration', () => {
|
|
|
109
174
|
expect($(div).hasClass('ons-field-group')).toBe(true);
|
|
110
175
|
});
|
|
111
176
|
|
|
177
|
+
it('has the correct number of inputs', () => {
|
|
178
|
+
const $ = cheerio.load(renderComponent('duration', EXAMPLE_DURATION_MULTIPLE_FIELDS));
|
|
179
|
+
const $inputs = $('.ons-input');
|
|
180
|
+
expect($inputs.length).toBe(2);
|
|
181
|
+
});
|
|
182
|
+
|
|
112
183
|
it('has the expected `fieldset` output', () => {
|
|
113
184
|
const faker = templateFaker();
|
|
114
185
|
const fieldsetSpy = faker.spy('fieldset');
|
|
@@ -141,10 +212,11 @@ describe('macro: duration', () => {
|
|
|
141
212
|
mutuallyExclusive: {
|
|
142
213
|
legendClasses: 'custom-legend-class',
|
|
143
214
|
dontWrap: true,
|
|
215
|
+
classes: undefined,
|
|
144
216
|
legendIsQuestionTitle: true,
|
|
145
217
|
error: false,
|
|
146
218
|
mutuallyExclusive: {
|
|
147
|
-
|
|
219
|
+
exclusiveOptions: {},
|
|
148
220
|
or: 'Or',
|
|
149
221
|
deselectMessage: 'Deselect message',
|
|
150
222
|
deselectGroupAdjective: 'Deselect group adjective',
|
|
@@ -166,10 +238,10 @@ describe('macro: duration', () => {
|
|
|
166
238
|
...EXAMPLE_DURATION_MULTIPLE_FIELDS,
|
|
167
239
|
legendClasses: 'custom-legend-class',
|
|
168
240
|
dontWrap: true,
|
|
241
|
+
classes: undefined,
|
|
169
242
|
legendIsQuestionTitle: true,
|
|
170
243
|
error: false,
|
|
171
244
|
mutuallyExclusive: {
|
|
172
|
-
checkbox: {},
|
|
173
245
|
or: 'Or',
|
|
174
246
|
deselectMessage: 'Deselect message',
|
|
175
247
|
deselectGroupAdjective: 'Deselect group adjective',
|
|
@@ -183,9 +255,9 @@ describe('macro: duration', () => {
|
|
|
183
255
|
description: 'Enter “0” into the years field if you have lived at this address for less than a year',
|
|
184
256
|
legendClasses: 'custom-legend-class',
|
|
185
257
|
dontWrap: true,
|
|
258
|
+
classes: undefined,
|
|
186
259
|
legendIsQuestionTitle: true,
|
|
187
260
|
error: false,
|
|
188
|
-
checkbox: {},
|
|
189
261
|
or: 'Or',
|
|
190
262
|
deselectMessage: 'Deselect message',
|
|
191
263
|
deselectGroupAdjective: 'Deselect group adjective',
|
|
@@ -215,7 +287,6 @@ describe('macro: duration', () => {
|
|
|
215
287
|
classes: '',
|
|
216
288
|
value: '0',
|
|
217
289
|
attributes: undefined,
|
|
218
|
-
classes: '',
|
|
219
290
|
error: undefined,
|
|
220
291
|
fieldId: 'duration',
|
|
221
292
|
label: {
|
|
@@ -226,10 +297,17 @@ describe('macro: duration', () => {
|
|
|
226
297
|
suffix: {
|
|
227
298
|
id: 'address-duration-years-suffix',
|
|
228
299
|
text: 'Years',
|
|
300
|
+
title: undefined,
|
|
229
301
|
},
|
|
230
302
|
});
|
|
231
303
|
});
|
|
232
304
|
|
|
305
|
+
it('has the correct number of inputs', () => {
|
|
306
|
+
const $ = cheerio.load(renderComponent('duration', EXAMPLE_DURATION_SINGLE_FIELD));
|
|
307
|
+
const $inputs = $('.ons-input');
|
|
308
|
+
expect($inputs.length).toBe(1);
|
|
309
|
+
});
|
|
310
|
+
|
|
233
311
|
it('has the expected `error` output', () => {
|
|
234
312
|
const faker = templateFaker();
|
|
235
313
|
const errorSpy = faker.spy('error');
|
|
@@ -244,4 +322,34 @@ describe('macro: duration', () => {
|
|
|
244
322
|
});
|
|
245
323
|
});
|
|
246
324
|
});
|
|
325
|
+
|
|
326
|
+
describe('mode: multiple fields with errors', () => {
|
|
327
|
+
it('passes jest-axe checks', async () => {
|
|
328
|
+
const $ = cheerio.load(renderComponent('duration', EXAMPLE_DURATION_MULTIPLE_FIELDS_WITH_SINGLE_ERROR));
|
|
329
|
+
|
|
330
|
+
const results = await axe($.html());
|
|
331
|
+
expect(results).toHaveNoViolations();
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('has the provided error class on one input', async () => {
|
|
335
|
+
const $ = cheerio.load(renderComponent('duration', EXAMPLE_DURATION_MULTIPLE_FIELDS_WITH_SINGLE_ERROR));
|
|
336
|
+
const $errorContent = $('.ons-input--error');
|
|
337
|
+
|
|
338
|
+
expect($errorContent.length).toBe(1);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('has the provided error class on multiple inputs', async () => {
|
|
342
|
+
const $ = cheerio.load(renderComponent('duration', EXAMPLE_DURATION_MULTIPLE_FIELDS_WITH_ERROR));
|
|
343
|
+
const $errorContent = $('.ons-input--error');
|
|
344
|
+
|
|
345
|
+
expect($errorContent.length).toBe(2);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it('does not provide error class when error parameter set to false', async () => {
|
|
349
|
+
const $ = cheerio.load(renderComponent('duration', EXAMPLE_DURATION_MULTIPLE_FIELDS_WITH_ERROR_FALSE));
|
|
350
|
+
const $errorContent = $('.ons-input--error');
|
|
351
|
+
|
|
352
|
+
expect($errorContent.length).toBe(0);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
247
355
|
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"legendOrLabel": 'How long do you spend travelling to and from work each day?',
|
|
7
7
|
"legendClasses": 'ons-u-vh',
|
|
8
8
|
"error": {
|
|
9
|
-
"text": "Enter a number that is less than 60",
|
|
9
|
+
"text": "Enter a number of minutes that is less than 60",
|
|
10
10
|
"id": "duration-error"
|
|
11
11
|
},
|
|
12
12
|
"field1": {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{% from "components/question/_macro.njk" import onsQuestion %}
|
|
2
|
+
{% from "components/duration/_macro.njk" import onsDuration %}
|
|
3
|
+
|
|
4
|
+
{% call onsQuestion({
|
|
5
|
+
"title": "How many years have you lived at this address?",
|
|
6
|
+
"description": "<p>Enter “0” into the years field if you have lived at this address for less than a year</p>",
|
|
7
|
+
"legendIsQuestionTitle": true
|
|
8
|
+
}) %}
|
|
9
|
+
{{ onsDuration({
|
|
10
|
+
"id": "address-duration-example-single",
|
|
11
|
+
"dontWrap": true,
|
|
12
|
+
"field1": {
|
|
13
|
+
"id": "address-duration-years-example",
|
|
14
|
+
"name": "address-duration-years",
|
|
15
|
+
"suffix": {
|
|
16
|
+
"text": "Years",
|
|
17
|
+
"id": "address-duration-years-suffix-example"
|
|
18
|
+
},
|
|
19
|
+
"attributes": {
|
|
20
|
+
"autocomplete": "off"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}) }}
|
|
24
|
+
{% endcall %}
|
|
@@ -36,11 +36,7 @@ describe('macro: error', () => {
|
|
|
36
36
|
),
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
expect(
|
|
40
|
-
$('.ons-panel__error')
|
|
41
|
-
.text()
|
|
42
|
-
.trim(),
|
|
43
|
-
).toBe('Example error text.');
|
|
39
|
+
expect($('.ons-panel__error').text().trim()).toBe('Example error text.');
|
|
44
40
|
});
|
|
45
41
|
|
|
46
42
|
it('applies the provided `attributes` to the error content paragraph', () => {
|
|
@@ -76,7 +72,7 @@ describe('macro: error', () => {
|
|
|
76
72
|
FAKE_NESTED_CONTENT,
|
|
77
73
|
);
|
|
78
74
|
|
|
79
|
-
expect(panelSpy.occurrences[0].
|
|
75
|
+
expect(panelSpy.occurrences[0].variant).toBe('error');
|
|
80
76
|
expect(panelSpy.occurrences[0].id).toBe('example-error');
|
|
81
77
|
});
|
|
82
78
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{% macro onsFeedback(params) %}
|
|
2
|
-
{% set headingLevel = params.headingLevel | default(
|
|
2
|
+
{% set headingLevel = params.headingLevel | default(2) %}
|
|
3
3
|
<div {% if params.id %} id="{{ params.id }}"{% endif %} class="ons-feedback{% if params.classes %} {{ params.classes }}{% endif %}">
|
|
4
4
|
<h{{ headingLevel }} class="ons-feedback__heading{{ ' ' + params.headingClasses if params.headingClasses }}">
|
|
5
5
|
{{ params.heading }}
|
|
@@ -70,21 +70,13 @@ describe('macro: feedback', () => {
|
|
|
70
70
|
}),
|
|
71
71
|
);
|
|
72
72
|
|
|
73
|
-
expect(
|
|
74
|
-
$(`${expectedTitleTag}.ons-feedback__heading`)
|
|
75
|
-
.text()
|
|
76
|
-
.trim(),
|
|
77
|
-
).toBe('Feedback heading');
|
|
73
|
+
expect($(`${expectedTitleTag}.ons-feedback__heading`).text().trim()).toBe('Feedback heading');
|
|
78
74
|
});
|
|
79
75
|
|
|
80
76
|
it('has a default `headingLevel` of 2', () => {
|
|
81
77
|
const $ = cheerio.load(renderComponent('feedback', EXAMPLE_FEEDBACK_MINIMAL));
|
|
82
78
|
|
|
83
|
-
expect(
|
|
84
|
-
$(`h2.ons-feedback__heading`)
|
|
85
|
-
.text()
|
|
86
|
-
.trim(),
|
|
87
|
-
).toBe('Feedback heading');
|
|
79
|
+
expect($(`h2.ons-feedback__heading`).text().trim()).toBe('Feedback heading');
|
|
88
80
|
});
|
|
89
81
|
|
|
90
82
|
it('has additional heading style classes', () => {
|
|
@@ -97,11 +89,7 @@ describe('macro: feedback', () => {
|
|
|
97
89
|
it('has a paragraph with the provided `content`', () => {
|
|
98
90
|
const $ = cheerio.load(renderComponent('feedback', EXAMPLE_FEEDBACK_MINIMAL));
|
|
99
91
|
|
|
100
|
-
expect(
|
|
101
|
-
$('p')
|
|
102
|
-
.text()
|
|
103
|
-
.trim(),
|
|
104
|
-
).toBe('Feedback content...');
|
|
92
|
+
expect($('p').text().trim()).toBe('Feedback content...');
|
|
105
93
|
});
|
|
106
94
|
|
|
107
95
|
it('has a link with the provided `url`', () => {
|
|
@@ -113,10 +101,6 @@ describe('macro: feedback', () => {
|
|
|
113
101
|
it('has a link with the provided `linkText`', () => {
|
|
114
102
|
const $ = cheerio.load(renderComponent('feedback', EXAMPLE_FEEDBACK_MINIMAL));
|
|
115
103
|
|
|
116
|
-
expect(
|
|
117
|
-
$('.ons-feedback__link')
|
|
118
|
-
.text()
|
|
119
|
-
.trim(),
|
|
120
|
-
).toBe('Feedback link text');
|
|
104
|
+
expect($('.ons-feedback__link').text().trim()).toBe('Feedback link text');
|
|
121
105
|
});
|
|
122
106
|
});
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
.ons-field-group {
|
|
2
2
|
font-size: 0;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
gap: 1rem;
|
|
3
6
|
|
|
4
7
|
.ons-field {
|
|
5
8
|
display: inline-block;
|
|
6
9
|
font-size: 1rem;
|
|
7
10
|
margin-top: 0;
|
|
8
11
|
vertical-align: top;
|
|
9
|
-
|
|
10
|
-
&:not(:last-child) {
|
|
11
|
-
margin-right: 1rem;
|
|
12
|
-
}
|
|
13
12
|
}
|
|
14
13
|
}
|
|
@@ -75,9 +75,7 @@ describe('macro: field', () => {
|
|
|
75
75
|
it('calls with content', () => {
|
|
76
76
|
const $ = cheerio.load(renderComponent('field', EXAMPLE_FIELD_BASIC, 'Example content...'));
|
|
77
77
|
|
|
78
|
-
const content = $('.ons-field')
|
|
79
|
-
.html()
|
|
80
|
-
.trim();
|
|
78
|
+
const content = $('.ons-field').html().trim();
|
|
81
79
|
expect(content).toEqual(expect.stringContaining('Example content...'));
|
|
82
80
|
});
|
|
83
81
|
|
|
@@ -42,9 +42,7 @@ describe('macro: fieldset', () => {
|
|
|
42
42
|
it('has the `description` text', () => {
|
|
43
43
|
const $ = cheerio.load(renderComponent('fieldset', EXAMPLE_FIELDSET_BASIC));
|
|
44
44
|
|
|
45
|
-
const title = $('.ons-fieldset__description')
|
|
46
|
-
.html()
|
|
47
|
-
.trim();
|
|
45
|
+
const title = $('.ons-fieldset__description').html().trim();
|
|
48
46
|
expect(title).toBe('A fieldset description');
|
|
49
47
|
});
|
|
50
48
|
|
|
@@ -122,9 +120,7 @@ describe('macro: fieldset', () => {
|
|
|
122
120
|
it('calls with content', () => {
|
|
123
121
|
const $ = cheerio.load(renderComponent('fieldset', EXAMPLE_FIELDSET_BASIC, 'Example content...'));
|
|
124
122
|
|
|
125
|
-
const content = $('.ons-fieldset')
|
|
126
|
-
.html()
|
|
127
|
-
.trim();
|
|
123
|
+
const content = $('.ons-fieldset').html().trim();
|
|
128
124
|
expect(content).toEqual(expect.stringContaining('Example content...'));
|
|
129
125
|
});
|
|
130
126
|
|
|
@@ -179,9 +175,7 @@ describe('macro: fieldset', () => {
|
|
|
179
175
|
}),
|
|
180
176
|
);
|
|
181
177
|
|
|
182
|
-
const title = $('.ons-fieldset__legend-title')
|
|
183
|
-
.html()
|
|
184
|
-
.trim();
|
|
178
|
+
const title = $('.ons-fieldset__legend-title').html().trim();
|
|
185
179
|
expect(title).toBe('Fieldset legend');
|
|
186
180
|
});
|
|
187
181
|
|
|
@@ -36,10 +36,9 @@
|
|
|
36
36
|
<div class="ons-footer__warning">
|
|
37
37
|
<div class="ons-container">
|
|
38
38
|
{% call onsPanel({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
%}
|
|
39
|
+
"variant": "warn",
|
|
40
|
+
"classes": "ons-panel--warn--footer"
|
|
41
|
+
}) %}
|
|
43
42
|
{{ params.footerWarning | safe }}
|
|
44
43
|
{% endcall %}
|
|
45
44
|
</div>
|
|
@@ -158,9 +157,11 @@
|
|
|
158
157
|
</div>
|
|
159
158
|
{% endif %}
|
|
160
159
|
{% if not params.poweredBy %}
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
<a class="ons-footer__poweredBy-link" {% if lang == "cy" %}href="https://cy.ons.gov.uk/"{% else %}href="https://www.ons.gov.uk/"{% endif %}>
|
|
161
|
+
<div class="ons-footer__poweredby-logo ons-u-mb-m">
|
|
162
|
+
{{ onsLogo | safe }}
|
|
163
|
+
</div>
|
|
164
|
+
</a>
|
|
164
165
|
{% endif %}
|
|
165
166
|
</div>
|
|
166
167
|
{% if params.crest %}
|
|
@@ -225,7 +225,7 @@ describe('macro: footer', () => {
|
|
|
225
225
|
|
|
226
226
|
expect(panelSpy.occurrences).toContainEqual(
|
|
227
227
|
expect.objectContaining({
|
|
228
|
-
|
|
228
|
+
variant: 'warn',
|
|
229
229
|
classes: 'ons-panel--warn--footer',
|
|
230
230
|
}),
|
|
231
231
|
);
|
|
@@ -278,7 +278,7 @@ describe('macro: footer', () => {
|
|
|
278
278
|
it('renders expected column titles', () => {
|
|
279
279
|
const $ = cheerio.load(renderComponent('footer', params));
|
|
280
280
|
|
|
281
|
-
const titleHeadings = mapAll($('.ons-footer__heading'), node => node.text().trim());
|
|
281
|
+
const titleHeadings = mapAll($('.ons-footer__heading'), (node) => node.text().trim());
|
|
282
282
|
expect(titleHeadings).toEqual(['First column', 'Second column']);
|
|
283
283
|
});
|
|
284
284
|
|
|
@@ -411,6 +411,18 @@ describe('macro: footer', () => {
|
|
|
411
411
|
});
|
|
412
412
|
});
|
|
413
413
|
});
|
|
414
|
+
describe('correct link for language', () => {
|
|
415
|
+
it('has the Welsh lang link when the default Welsh lang ons icon is present', () => {
|
|
416
|
+
const $ = cheerio.load(renderComponent('footer', { lang: 'cy' }));
|
|
417
|
+
|
|
418
|
+
expect($('.ons-footer__poweredBy-link').attr('href')).toBe('https://cy.ons.gov.uk/');
|
|
419
|
+
});
|
|
420
|
+
it('has the English lang link when the default English lang ons icon is present', () => {
|
|
421
|
+
const $ = cheerio.load(renderComponent('footer', { lang: 'en' }));
|
|
422
|
+
|
|
423
|
+
expect($('.ons-footer__poweredBy-link').attr('href')).toBe('https://www.ons.gov.uk/');
|
|
424
|
+
});
|
|
425
|
+
});
|
|
414
426
|
describe('provided poweredBy logo', () => {
|
|
415
427
|
describe.each([
|
|
416
428
|
[
|
|
@@ -275,7 +275,7 @@ describe('macro: header', () => {
|
|
|
275
275
|
|
|
276
276
|
faker.renderComponent('header', EXAMPLE_HEADER_BASIC);
|
|
277
277
|
|
|
278
|
-
expect(iconsSpy.occurrences[0].altText).toBe('Office for National Statistics
|
|
278
|
+
expect(iconsSpy.occurrences[0].altText).toBe('Office for National Statistics homepage');
|
|
279
279
|
});
|
|
280
280
|
|
|
281
281
|
it('has the default masthead mobile logo icon alt text', () => {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{% macro patternLibExampleGrid(params) %}
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
{% if params.container -%}
|
|
3
|
+
<div class="ons-container">
|
|
4
|
+
{% endif -%}
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
{% if params.container -%}
|
|
6
|
+
<div class="ons-grid">
|
|
7
|
+
{% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) -%}
|
|
8
|
+
{% for i in range(0, item.repeat | default(1) ) -%}
|
|
9
|
+
<div class="ons-grid__col ons-col-{{ item.col }}@m {{ item.classes }}">
|
|
10
|
+
<div class="ons-pl-grid-col">{{ item.col }} col</div>
|
|
11
|
+
</div>
|
|
12
|
+
{%- endfor %}
|
|
13
|
+
{%- endfor %}
|
|
17
14
|
</div>
|
|
18
|
-
|
|
15
|
+
|
|
16
|
+
{% if params.container -%}
|
|
17
|
+
</div>
|
|
18
|
+
{% endif -%}
|
|
19
19
|
{% endmacro %}
|