@ons/design-system 70.0.15 → 70.0.17
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 +10 -1
- package/components/access-code/_macro.spec.js +2 -2
- package/components/accordion/_macro.spec.js +161 -90
- package/components/accordion/_test_examples.js +13 -0
- package/components/address-input/autosuggest.address.spec.js +2 -0
- package/components/back-to-top/_macro.spec.js +1 -1
- package/components/breadcrumbs/_macro.spec.js +121 -115
- package/components/breadcrumbs/_test_examples.js +36 -0
- package/components/browser-banner/_macro.spec.js +92 -93
- package/components/button/_macro.njk +2 -2
- package/components/button/_macro.spec.js +2 -2
- package/components/header/_macro.spec.js +2 -2
- package/components/list/_list.scss +2 -0
- package/components/list/example-summary-list.njk +3 -1
- package/components/summary/_summary.scss +1 -4
- package/components/text-indent/example-text-indent.njk +1 -1
- package/css/main.css +1 -1
- package/package.json +3 -2
- package/components/header/_test_examples.js +0 -157
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS = {
|
|
2
|
+
itemsList: [
|
|
3
|
+
{
|
|
4
|
+
url: 'https://example.com/',
|
|
5
|
+
text: 'Home',
|
|
6
|
+
},
|
|
7
|
+
],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const EXAMPLE_BREADCRUMBS_ALL_PARAMS = {
|
|
11
|
+
classes: 'extra-class another-extra-class',
|
|
12
|
+
ariaLabel: 'Breadcrumbs label',
|
|
13
|
+
id: 'example-breadcrumbs',
|
|
14
|
+
itemsList: [
|
|
15
|
+
{
|
|
16
|
+
itemClasses: 'item-extra-class item-another-extra-class',
|
|
17
|
+
linkClasses: 'link-extra-class link-another-extra-class',
|
|
18
|
+
url: 'https://example.com/',
|
|
19
|
+
text: 'Home',
|
|
20
|
+
attributes: {
|
|
21
|
+
'data-a': '123',
|
|
22
|
+
'data-b': '456',
|
|
23
|
+
},
|
|
24
|
+
id: 'first-breadcrumb',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
url: 'https://example.com/guide/',
|
|
28
|
+
text: 'Guide',
|
|
29
|
+
id: 'second-breadcrumb',
|
|
30
|
+
attributes: {
|
|
31
|
+
'data-a': '789',
|
|
32
|
+
'data-b': 'ABC',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
@@ -5,102 +5,101 @@ import * as cheerio from 'cheerio';
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
6
|
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe('
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
8
|
+
describe('FOR: Macro: Browser-banner', () => {
|
|
9
|
+
describe('GIVEN: Params: default', () => {
|
|
10
|
+
describe('WHEN: params are at default state', () => {
|
|
11
|
+
const $ = cheerio.load(renderComponent('browser-banner', {}));
|
|
12
|
+
|
|
13
|
+
it('THEN: passes jest-axe checks', async () => {
|
|
14
|
+
const results = await axe($.html());
|
|
15
|
+
expect(results).toHaveNoViolations();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('THEN: has the english default bannerLeadingText', () => {
|
|
19
|
+
const bannerLeadingText = $('.ons-browser-banner__lead').text().trim();
|
|
20
|
+
expect(bannerLeadingText).toBe('This website no longer supports your browser.');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('THEN: has the english default bannerCTA', () => {
|
|
24
|
+
const bannerCtaHtml = $('.ons-browser-banner__cta').text().trim();
|
|
25
|
+
expect(bannerCtaHtml).toBe('You can upgrade your browser to the latest version.');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('THEN: has the english default bannerLinkUrl', () => {
|
|
29
|
+
expect($('.ons-browser-banner__link').attr('href')).toBe('https://www.ons.gov.uk/help/browsers');
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('WHEN: params are at default and language is set to welsh', () => {
|
|
34
|
+
const $ = cheerio.load(renderComponent('browser-banner', { lang: 'cy' }));
|
|
35
|
+
|
|
36
|
+
it('THEN: has the welsh default bannerLeadingText', () => {
|
|
37
|
+
const bannerLeadingText = $('.ons-browser-banner__lead').text().trim();
|
|
38
|
+
expect(bannerLeadingText).toBe('Nid yw’r wefan hon yn cefnogi eich porwr mwyach.');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('THEN: has the welsh default bannerCTA', () => {
|
|
42
|
+
const bannerCtaHtml = $('.ons-browser-banner__cta').text().trim();
|
|
43
|
+
expect(bannerCtaHtml).toBe('Gallwch ddiweddaru eich porwr i’r fersiwn ddiweddaraf.');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('THEN: has the welsh default bannerLinkUrl', () => {
|
|
47
|
+
expect($('.ons-browser-banner__link').attr('href')).toBe('https://cy.ons.gov.uk/help/browsers');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
47
50
|
});
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}),
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
expect($('.ons-container').hasClass('ons-container--full-width')).toBe(false);
|
|
52
|
+
describe('GIVEN: Params: wide', () => {
|
|
53
|
+
describe('WHEN: wide is set to true', () => {
|
|
54
|
+
it('THEN: has container--wide class', () => {
|
|
55
|
+
const $ = cheerio.load(
|
|
56
|
+
renderComponent('browser-banner', {
|
|
57
|
+
...{},
|
|
58
|
+
wide: true,
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('WHEN: wide is not set', () => {
|
|
67
|
+
it('THEN: does not have container--wide class', () => {
|
|
68
|
+
const $ = cheerio.load(
|
|
69
|
+
renderComponent('browser-banner', {
|
|
70
|
+
...{},
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
expect($('.ons-container').hasClass('ons-container--wide')).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
78
77
|
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe('mode: Welsh language', () => {
|
|
82
|
-
it('has the welsh version of default `bannerLeadingText`', () => {
|
|
83
|
-
const $ = cheerio.load(
|
|
84
|
-
renderComponent('browser-banner', {
|
|
85
|
-
...EXAMPLE_BROWSER_BANNER_DEFAULT,
|
|
86
|
-
lang: 'cy',
|
|
87
|
-
}),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const bannerLeadingText = $('.ons-browser-banner__lead').text().trim();
|
|
91
|
-
expect(bannerLeadingText).toBe('Nid yw’r wefan hon yn cefnogi eich porwr mwyach.');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('has the welsh version of default `bannerCTA`', () => {
|
|
95
|
-
const $ = cheerio.load(renderComponent('browser-banner', { lang: 'cy' }));
|
|
96
|
-
|
|
97
|
-
const bannerCtaHtml = $('.ons-browser-banner__cta').text().trim();
|
|
98
|
-
expect(bannerCtaHtml).toBe('Gallwch ddiweddaru eich porwr i’r fersiwn ddiweddaraf.');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('has the welsh version of default `bannerLinkUrl`', () => {
|
|
102
|
-
const $ = cheerio.load(renderComponent('browser-banner', { lang: 'cy' }));
|
|
103
78
|
|
|
104
|
-
|
|
79
|
+
describe('GIVEN: Params: fullWidth', () => {
|
|
80
|
+
describe('WHEN: fullWidth is set to true', () => {
|
|
81
|
+
it('THEN: has container--full-width class', () => {
|
|
82
|
+
const $ = cheerio.load(
|
|
83
|
+
renderComponent('browser-banner', {
|
|
84
|
+
...{},
|
|
85
|
+
fullWidth: true,
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect($('.ons-container').hasClass('ons-container--full-width')).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('WHEN: fullWidth is not set', () => {
|
|
94
|
+
it('THEN: does not have container--full-width class', () => {
|
|
95
|
+
const $ = cheerio.load(
|
|
96
|
+
renderComponent('browser-banner', {
|
|
97
|
+
...{},
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect($('.ons-container').hasClass('ons-container--full-width')).toBe(false);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
105
104
|
});
|
|
106
105
|
});
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
{% else %}
|
|
73
73
|
type="{{ buttonType }}"
|
|
74
74
|
{% endif %}
|
|
75
|
-
class="ons-btn{{ ' ' + params.classes if params.classes else '' }}{% if params.variants and params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-btn--{{ variant }}{% endfor %}{%
|
|
75
|
+
class="ons-btn{{ ' ' + params.classes if params.classes else '' }}{% if params.variants and params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-btn--{{ variant }}{% endfor %}{% elif params.variants %}{{ ' ' }}ons-btn--{{ params.variants }}{% endif %}{{ ' ons-btn--link ons-js-submit-btn' if params.url }}{{ variantClasses }}"
|
|
76
76
|
{% if params.id %}id="{{ params.id }}"{% endif %}
|
|
77
77
|
{% if params.value and tag != "a" %}value="{{ params.value }}"{% endif %}
|
|
78
78
|
{% if params.name and tag != "a" %}name="{{ params.name }}"{% endif %}
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
{%- endif -%}
|
|
112
112
|
</span>
|
|
113
113
|
{% if params.url and params.newWindow %}
|
|
114
|
-
<span class="ons-btn__new-window-description ons-u-vh">
|
|
114
|
+
<span class="ons-btn__new-window-description ons-u-vh">({{ params.newWindowDescription | default("opens in a new tab") }})</span>
|
|
115
115
|
{% endif %}
|
|
116
116
|
{% if params.buttonContext %}
|
|
117
117
|
<span class="ons-btn__context ons-u-vh">{{ params.buttonContext }}</span>
|
|
@@ -393,7 +393,7 @@ describe('macro: button', () => {
|
|
|
393
393
|
}),
|
|
394
394
|
);
|
|
395
395
|
|
|
396
|
-
expect($('.ons-btn__new-window-description').text()).toBe('
|
|
396
|
+
expect($('.ons-btn__new-window-description').text()).toBe('(opens in a new tab)');
|
|
397
397
|
});
|
|
398
398
|
|
|
399
399
|
it('has a custom new window description when `newWindow` is `true` and `newWindowDescription` is provided', () => {
|
|
@@ -405,7 +405,7 @@ describe('macro: button', () => {
|
|
|
405
405
|
}),
|
|
406
406
|
);
|
|
407
407
|
|
|
408
|
-
expect($('.ons-btn__new-window-description').text()).toBe('
|
|
408
|
+
expect($('.ons-btn__new-window-description').text()).toBe('(custom opens in a new window text)');
|
|
409
409
|
});
|
|
410
410
|
|
|
411
411
|
it('has the `download` attribute when `variants` contains "download"', () => {
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
EXAMPLE_HEADER_LANGUAGE_CONFIG,
|
|
15
15
|
EXAMPLE_HEADER_NAVIGATION_WITH_SUBNAVIGATION_CONFIG,
|
|
16
16
|
EXAMPLE_HEADER_NAVIGATION_WITH_SITESEARCHAUTOSUGGEST,
|
|
17
|
-
} from './
|
|
17
|
+
} from './_test-examples';
|
|
18
18
|
|
|
19
|
-
describe('FOR: Header', () => {
|
|
19
|
+
describe('FOR: Macro: Header', () => {
|
|
20
20
|
describe('GIVEN: Params: none', () => {
|
|
21
21
|
describe('WHEN: All params are at default state', () => {
|
|
22
22
|
const $ = cheerio.load(
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{% from "components/list/_macro.njk" import onsList %}
|
|
2
2
|
{{
|
|
3
3
|
onsList({
|
|
4
|
+
"iconPosition": "before",
|
|
4
5
|
"variants": "summary",
|
|
5
6
|
"itemsList": [
|
|
6
7
|
{
|
|
7
|
-
|
|
8
|
+
"text": 'birth certificate',
|
|
9
|
+
"iconType": "check"
|
|
8
10
|
},
|
|
9
11
|
{
|
|
10
12
|
"text": 'national insurance number'
|
|
@@ -88,10 +88,6 @@ $hub-row-spacing: 1.3rem;
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
&__actions {
|
|
92
|
-
white-space: nowrap;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
91
|
&__spacer {
|
|
96
92
|
background: var(--ons-color-black);
|
|
97
93
|
display: inline-block;
|
|
@@ -190,6 +186,7 @@ $hub-row-spacing: 1.3rem;
|
|
|
190
186
|
|
|
191
187
|
&__button {
|
|
192
188
|
align-self: flex-start;
|
|
189
|
+
text-align: right;
|
|
193
190
|
}
|
|
194
191
|
|
|
195
192
|
&__values--2 {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% from "components/text-indent/_macro.njk" import onsTextIndent %}
|
|
2
2
|
{{-
|
|
3
3
|
onsTextIndent({
|
|
4
|
-
text: '<p>Telephone: 0800 141 2021<br>Monday to Friday, 8 am to 7pm<br>Saturday, 8am to 4pm</p>'
|
|
4
|
+
"text": '<p>Telephone: 0800 141 2021<br>Monday to Friday, 8 am to 7pm<br>Saturday, 8am to 4pm</p>'
|
|
5
5
|
})
|
|
6
6
|
-}}
|