@ons/design-system 72.5.0 → 72.8.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.
- package/components/breadcrumbs/_breadcrumbs.scss +1 -0
- package/components/chart/_chart.scss +56 -0
- package/components/chart/_macro.njk +43 -5
- package/components/chart/_macro.spec.js +420 -0
- package/components/chart/annotations-options.js +78 -0
- package/components/chart/bar-chart.js +15 -2
- package/components/chart/chart.js +119 -27
- package/components/chart/column-chart.js +2 -2
- package/components/chart/common-chart-options.js +104 -51
- package/components/chart/example-bar-chart-with-annotations.njk +62 -0
- package/components/chart/example-bar-chart.njk +1 -0
- package/components/chart/example-bar-with-line-chart.njk +64 -0
- package/components/chart/example-clustered-column-chart.njk +5 -2
- package/components/chart/example-column-chart-with-annotations.njk +63 -0
- package/components/chart/example-column-chart.njk +5 -2
- package/components/chart/example-column-with-line-chart.njk +63 -0
- package/components/chart/example-line-chart-with-annotations.njk +235 -0
- package/components/chart/example-line-chart.njk +7 -3
- package/components/chart/example-stacked-column-chart.njk +3 -1
- package/components/chart/line-chart.js +2 -7
- package/components/details/details.js +5 -0
- package/components/details-panel/_details-panel.scss +107 -0
- package/components/details-panel/_macro.njk +41 -0
- package/components/details-panel/_macro.spec.js +54 -0
- package/components/details-panel/example-details-panel-open.njk +29 -0
- package/components/details-panel/example-details-panel.njk +28 -0
- package/components/hero/_hero.scss +101 -43
- package/components/hero/_macro.njk +21 -10
- package/components/hero/_macro.spec.js +94 -0
- package/components/hero/example-hero-dark.njk +1 -1
- package/components/hero/example-hero-grey.njk +8 -0
- package/components/icon/_macro.njk +1 -1
- package/components/pagination/_macro.njk +1 -1
- package/components/pagination/_pagination.scss +6 -0
- package/components/summary/_macro.njk +2 -2
- package/components/summary/_macro.spec.js +43 -21
- package/components/summary/_summary.scss +5 -1
- package/components/summary/example-summary-grouped.njk +0 -12
- package/components/table-of-contents/_macro.njk +40 -0
- package/components/table-of-contents/_macro.spec.js +72 -0
- package/components/table-of-contents/_table-of-contents.scss +11 -0
- package/components/table-of-contents/example-table-of-contents-related-links-with-button.njk +60 -0
- package/css/main.css +1 -1
- package/js/cookies-functions.js +11 -6
- package/js/cookies-functions.spec.js +44 -0
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +1 -0
- package/scss/vars/_colors.scss +1 -0
|
@@ -196,20 +196,10 @@ const EXAMPLE_SUMMARY_HOUSEHOLD_GROUP = {
|
|
|
196
196
|
itemsList: [
|
|
197
197
|
{
|
|
198
198
|
title: 'row item 4',
|
|
199
|
-
valueList: [
|
|
200
|
-
{
|
|
201
|
-
text: 'list item 4',
|
|
202
|
-
},
|
|
203
|
-
],
|
|
204
199
|
actions: [
|
|
205
200
|
{
|
|
206
201
|
text: 'Change',
|
|
207
|
-
visuallyHiddenText: 'change
|
|
208
|
-
url: '#0',
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
text: 'Remove',
|
|
212
|
-
visuallyHiddenText: 'remove list item',
|
|
202
|
+
visuallyHiddenText: 'change list item',
|
|
213
203
|
url: '#0',
|
|
214
204
|
},
|
|
215
205
|
],
|
|
@@ -221,13 +211,6 @@ const EXAMPLE_SUMMARY_HOUSEHOLD_GROUP = {
|
|
|
221
211
|
text: 'list item 5',
|
|
222
212
|
},
|
|
223
213
|
],
|
|
224
|
-
actions: [
|
|
225
|
-
{
|
|
226
|
-
text: 'Change',
|
|
227
|
-
visuallyHiddenText: 'change list item',
|
|
228
|
-
url: '#0',
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
214
|
},
|
|
232
215
|
{
|
|
233
216
|
title: 'row item 6',
|
|
@@ -304,6 +287,21 @@ const EXAMPLE_SUMMARY_MULTIPLE_GROUPS = {
|
|
|
304
287
|
],
|
|
305
288
|
};
|
|
306
289
|
|
|
290
|
+
const EXAMPLE_SUMMARY_SINGLE_GROUP = {
|
|
291
|
+
summaries: [
|
|
292
|
+
{
|
|
293
|
+
title: 'summary title',
|
|
294
|
+
groups: [
|
|
295
|
+
{
|
|
296
|
+
id: 'group-id-1',
|
|
297
|
+
title: 'group title',
|
|
298
|
+
...EXAMPLE_SUMMARY_HOUSEHOLD_GROUP,
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
},
|
|
302
|
+
],
|
|
303
|
+
};
|
|
304
|
+
|
|
307
305
|
// To address a DAC issue, we've disabled specific axe definition list rules causing test failures.
|
|
308
306
|
// While resolving it would require a significant refactor, the failures are deemed non-critical for accessibility,
|
|
309
307
|
// leading to their removal in this context. [https://github.com/ONSdigital/design-system/issues/3027]
|
|
@@ -411,9 +409,9 @@ describe('macro: summary', () => {
|
|
|
411
409
|
it('displays the row `title` text', () => {
|
|
412
410
|
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
413
411
|
|
|
414
|
-
expect(
|
|
415
|
-
'
|
|
416
|
-
);
|
|
412
|
+
expect(
|
|
413
|
+
$('.ons-summary__items .ons-summary__item:nth-of-type(1) .ons-summary__item--text:nth-of-type(1)').text().trim(),
|
|
414
|
+
).toBe('row title 1');
|
|
417
415
|
});
|
|
418
416
|
|
|
419
417
|
it('has a custom icon `iconType`', () => {
|
|
@@ -473,6 +471,16 @@ describe('macro: summary', () => {
|
|
|
473
471
|
|
|
474
472
|
expect($('.ons-summary__items .ons-summary__item:nth-of-type(3) .ons-summary__values ul').length).toBe(1);
|
|
475
473
|
});
|
|
474
|
+
|
|
475
|
+
it('adds the `ons-summary__column-size--2` class if no `valueList` is provided', () => {
|
|
476
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_SINGLE_GROUP));
|
|
477
|
+
|
|
478
|
+
expect(
|
|
479
|
+
$('.ons-summary__items .ons-summary__item:nth-of-type(2) .ons-summary__actions').hasClass(
|
|
480
|
+
'ons-summary__column-size--2',
|
|
481
|
+
),
|
|
482
|
+
).toBe(true);
|
|
483
|
+
});
|
|
476
484
|
});
|
|
477
485
|
|
|
478
486
|
describe('part: item action', () => {
|
|
@@ -514,6 +522,12 @@ describe('macro: summary', () => {
|
|
|
514
522
|
).toBe('Action 2');
|
|
515
523
|
});
|
|
516
524
|
|
|
525
|
+
it('has the correct `id` added to the actions', () => {
|
|
526
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
527
|
+
|
|
528
|
+
expect($('.ons-summary__items .ons-summary__item:nth-of-type(2) .ons-summary__actions').attr('id')).toBe('item-id-2');
|
|
529
|
+
});
|
|
530
|
+
|
|
517
531
|
it('has the correct visually hidden <span> text', () => {
|
|
518
532
|
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
519
533
|
|
|
@@ -543,6 +557,14 @@ describe('macro: summary', () => {
|
|
|
543
557
|
),
|
|
544
558
|
).toBe('def');
|
|
545
559
|
});
|
|
560
|
+
|
|
561
|
+
it('adds the `ons-summary__column-size--2` class if no action is provided', () => {
|
|
562
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_SINGLE_GROUP));
|
|
563
|
+
|
|
564
|
+
expect(
|
|
565
|
+
$('.ons-summary__items .ons-summary__item:nth-of-type(2) .ons-summary__values').hasClass('ons-summary__column-size--2'),
|
|
566
|
+
).toBe(true);
|
|
567
|
+
});
|
|
546
568
|
});
|
|
547
569
|
});
|
|
548
570
|
|
|
@@ -192,10 +192,14 @@ $hub-row-spacing: 1.3rem;
|
|
|
192
192
|
text-align: right;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
&
|
|
195
|
+
&__column-size--2 {
|
|
196
196
|
flex: 10.5 1 66%;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
&__actions ~ &__values.ons-summary__column-size--2 {
|
|
200
|
+
padding-right: 33%;
|
|
201
|
+
}
|
|
202
|
+
|
|
199
203
|
&--hub & {
|
|
200
204
|
&__item-title,
|
|
201
205
|
&__values,
|
|
@@ -284,11 +284,6 @@
|
|
|
284
284
|
"itemsList": [
|
|
285
285
|
{
|
|
286
286
|
"title": "Food",
|
|
287
|
-
"valueList": [
|
|
288
|
-
{
|
|
289
|
-
"text": "£50.00"
|
|
290
|
-
}
|
|
291
|
-
],
|
|
292
287
|
"actions": [
|
|
293
288
|
{
|
|
294
289
|
"text": "Change",
|
|
@@ -333,13 +328,6 @@
|
|
|
333
328
|
{
|
|
334
329
|
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
|
|
335
330
|
}
|
|
336
|
-
],
|
|
337
|
-
"actions": [
|
|
338
|
-
{
|
|
339
|
-
"text": "Change",
|
|
340
|
-
"visuallyHiddenText": "Change answer",
|
|
341
|
-
"url": "#0"
|
|
342
|
-
}
|
|
343
331
|
]
|
|
344
332
|
}
|
|
345
333
|
]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{% macro onsTableOfContents(params) %}
|
|
2
2
|
{% from "components/list/_macro.njk" import onsList %}
|
|
3
3
|
{% from "components/skip-to-content/_macro.njk" import onsSkipToContent %}
|
|
4
|
+
{% from "components/button/_macro.njk" import onsButton %}
|
|
4
5
|
|
|
5
6
|
<aside class="ons-table-of-contents-container" role="complementary">
|
|
6
7
|
{% if params.skipLink %}
|
|
@@ -41,5 +42,44 @@
|
|
|
41
42
|
}}
|
|
42
43
|
{% endif %}
|
|
43
44
|
</nav>
|
|
45
|
+
|
|
46
|
+
{% if params.relatedLinks %}
|
|
47
|
+
<nav
|
|
48
|
+
class="ons-table-of-contents__related-links ons-u-pb-s ons-u-pt-l ons-u-mt-s"
|
|
49
|
+
aria-label="{{ params.relatedLinks.ariaLabel | default('Related links') }}"
|
|
50
|
+
>
|
|
51
|
+
<h2 class="ons-table-of-contents__title ons-u-fs-r--b ons-u-mb-s">{{ params.relatedLinks.title }}</h2>
|
|
52
|
+
|
|
53
|
+
{{
|
|
54
|
+
onsList({
|
|
55
|
+
"variants": 'bare',
|
|
56
|
+
"itemsList": params.relatedLinks.itemsList
|
|
57
|
+
})
|
|
58
|
+
}}
|
|
59
|
+
</nav>
|
|
60
|
+
{% endif %}
|
|
61
|
+
|
|
62
|
+
{% if params.button %}
|
|
63
|
+
<div class="ons-table-of-contents__button ons-u-pt-l">
|
|
64
|
+
{% set allVariants = ['small', 'secondary'] %}
|
|
65
|
+
|
|
66
|
+
{% if params.button.variants %}
|
|
67
|
+
{% if params.button.variants is string %}
|
|
68
|
+
{% set allVariants = (allVariants.push(params.button.variants), allVariants) %}
|
|
69
|
+
{% else %}
|
|
70
|
+
{% for variant in params.button.variants %}
|
|
71
|
+
{% set allVariants = (allVariants.push(variant), allVariants) %}
|
|
72
|
+
{% endfor %}
|
|
73
|
+
{% endif %}
|
|
74
|
+
{% endif %}
|
|
75
|
+
|
|
76
|
+
{{
|
|
77
|
+
onsButton({
|
|
78
|
+
"text": params.button.text | default('Save or print this page'),
|
|
79
|
+
"variants": allVariants
|
|
80
|
+
})
|
|
81
|
+
}}
|
|
82
|
+
</div>
|
|
83
|
+
{% endif %}
|
|
44
84
|
</aside>
|
|
45
85
|
{% endmacro %}
|
|
@@ -55,6 +55,33 @@ const EXAMPLE_TABLE_OF_CONTENTS_MULTIPLE = {
|
|
|
55
55
|
],
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
const EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON = {
|
|
59
|
+
title: 'Contents',
|
|
60
|
+
itemsList: [
|
|
61
|
+
{
|
|
62
|
+
url: '#overview',
|
|
63
|
+
text: 'Overview',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
url: '#who-should-take-part-and-why',
|
|
67
|
+
text: 'Who should take part and why',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
relatedLinks: {
|
|
71
|
+
title: 'Related publications',
|
|
72
|
+
itemsList: [
|
|
73
|
+
{
|
|
74
|
+
url: '#0',
|
|
75
|
+
text: 'Example publication title',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
button: {
|
|
80
|
+
text: 'Save or print this page',
|
|
81
|
+
variants: ['print'],
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
58
85
|
describe('macro: table-of-contents', () => {
|
|
59
86
|
it('renders a default aria label', () => {
|
|
60
87
|
const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_SINGLE));
|
|
@@ -167,4 +194,49 @@ describe('macro: table-of-contents', () => {
|
|
|
167
194
|
});
|
|
168
195
|
});
|
|
169
196
|
});
|
|
197
|
+
|
|
198
|
+
describe('related links and button', () => {
|
|
199
|
+
it('passes jest-axe checks with related links and button', async () => {
|
|
200
|
+
const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON));
|
|
201
|
+
|
|
202
|
+
const results = await axe($.html());
|
|
203
|
+
expect(results).toHaveNoViolations();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('renders related links section with correct title', () => {
|
|
207
|
+
const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON));
|
|
208
|
+
|
|
209
|
+
expect($('.ons-table-of-contents__related-links h2').text().trim()).toBe('Related publications');
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('outputs `lists` component for related links with expected parameters', () => {
|
|
213
|
+
const faker = templateFaker();
|
|
214
|
+
const listsSpy = faker.spy('list');
|
|
215
|
+
|
|
216
|
+
faker.renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON);
|
|
217
|
+
|
|
218
|
+
expect(listsSpy.occurrences[1]).toEqual({
|
|
219
|
+
variants: 'bare',
|
|
220
|
+
itemsList: EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON.relatedLinks.itemsList,
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('renders button with correct text', () => {
|
|
225
|
+
const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON));
|
|
226
|
+
|
|
227
|
+
expect($('.ons-table-of-contents__button .ons-btn').text().trim()).toBe('Save or print this page');
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('outputs `button` component with expected parameters', () => {
|
|
231
|
+
const faker = templateFaker();
|
|
232
|
+
const buttonSpy = faker.spy('button');
|
|
233
|
+
|
|
234
|
+
faker.renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON);
|
|
235
|
+
|
|
236
|
+
expect(buttonSpy.occurrences[0]).toEqual({
|
|
237
|
+
text: 'Save or print this page',
|
|
238
|
+
variants: ['small', 'secondary', 'print'],
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
170
242
|
});
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
.ons-table-of-contents {
|
|
2
|
+
$root: &;
|
|
3
|
+
|
|
2
4
|
&-container {
|
|
3
5
|
border-bottom: 1px solid var(--ons-color-grey-15);
|
|
4
6
|
margin-bottom: 2rem;
|
|
5
7
|
padding-bottom: 1rem;
|
|
8
|
+
|
|
9
|
+
&:has(:where(#{$root}__related-links, #{$root}__button)) {
|
|
10
|
+
border-bottom: 0;
|
|
11
|
+
}
|
|
6
12
|
}
|
|
7
13
|
|
|
8
14
|
&__link-active {
|
|
9
15
|
color: var(--ons-color-text-link-hover);
|
|
10
16
|
text-decoration: underline solid var(--ons-color-text-link-hover) 2px;
|
|
11
17
|
}
|
|
18
|
+
|
|
19
|
+
&__related-links,
|
|
20
|
+
&__button {
|
|
21
|
+
border-top: 4px solid var(--ons-color-ocean-blue);
|
|
22
|
+
}
|
|
12
23
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{% from "components/table-of-contents/_macro.njk" import onsTableOfContents %}
|
|
2
|
+
|
|
3
|
+
{{-
|
|
4
|
+
onsTableOfContents({
|
|
5
|
+
"title": 'Contents',
|
|
6
|
+
"ariaLabel": 'Pages in this guide',
|
|
7
|
+
"skipLink": {
|
|
8
|
+
"url": "#0",
|
|
9
|
+
"text": 'Skip to guide content'
|
|
10
|
+
},
|
|
11
|
+
"lists": [
|
|
12
|
+
{
|
|
13
|
+
"itemsList": [
|
|
14
|
+
{
|
|
15
|
+
"url": '#0',
|
|
16
|
+
"text": 'Overview',
|
|
17
|
+
"current": true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"url": '#0',
|
|
21
|
+
"text": 'Who should take part and why'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"url": '#0',
|
|
25
|
+
"text": 'How your information is used'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"url": '#0',
|
|
29
|
+
"text": 'The 2019 Census Rehearsal'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"url": '#0',
|
|
33
|
+
"text": 'Online census'
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"relatedLinks": {
|
|
39
|
+
"title": 'Related publications',
|
|
40
|
+
"itemsList": [
|
|
41
|
+
{
|
|
42
|
+
"url": '#0',
|
|
43
|
+
"text": 'Example publication title'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"url": '#0',
|
|
47
|
+
"text": 'Example publication title 2'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"url": '#0',
|
|
51
|
+
"text": 'Example publication title 3'
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"button": {
|
|
56
|
+
"text": 'Save or print this page',
|
|
57
|
+
"variants": 'print'
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
-}}
|