@ons/design-system 72.5.0 → 72.6.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/chart/_chart.scss +51 -0
- package/components/chart/_macro.njk +27 -3
- package/components/chart/_macro.spec.js +388 -0
- package/components/chart/annotations-options.js +78 -0
- package/components/chart/bar-chart.js +6 -2
- package/components/chart/chart.js +111 -26
- package/components/chart/column-chart.js +2 -2
- package/components/chart/common-chart-options.js +97 -50
- 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 +3 -1
- package/components/chart/example-column-chart-with-annotations.njk +62 -0
- package/components/chart/example-column-chart.njk +3 -1
- package/components/chart/example-column-with-line-chart.njk +62 -0
- package/components/chart/example-line-chart-with-annotations.njk +235 -0
- package/components/chart/example-line-chart.njk +4 -2
- package/components/chart/example-stacked-column-chart.njk +3 -1
- package/components/chart/line-chart.js +2 -7
- package/components/hero/_hero.scss +31 -0
- package/components/hero/_macro.njk +20 -9
- package/components/hero/_macro.spec.js +94 -0
- package/components/hero/example-hero-grey.njk +8 -0
- package/components/icon/_macro.njk +1 -1
- package/components/pagination/_pagination.scss +7 -1
- package/components/summary/_macro.njk +1 -1
- package/components/summary/_macro.spec.js +6 -0
- 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
|
@@ -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
|
+
-}}
|