@ons/design-system 72.1.0 → 72.1.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 +1 -1
- package/components/accordion/_macro.spec.js +2 -2
- package/components/address-input/_macro.spec.js +245 -322
- package/components/address-input/autosuggest.address.spec.js +16 -14
- package/components/address-output/_macro.spec.js +121 -74
- package/components/address-output/_test_examples.js +8 -0
- package/components/autosuggest/_macro.spec.js +373 -184
- package/components/back-to-top/back-to-top.dom.js +4 -4
- package/components/back-to-top/back-to-top.js +1 -1
- package/components/browser-banner/_macro.spec.js +11 -11
- package/components/button/_button.scss +1 -1
- package/components/button/_macro.njk +1 -1
- package/components/button/_macro.spec.js +405 -351
- package/components/button/example-button-group.njk +1 -0
- package/components/checkboxes/_checkbox.scss +3 -3
- package/components/description-list/_description-list.scss +40 -9
- package/components/description-list/_macro.njk +20 -12
- package/components/description-list/_macro.spec.js +11 -1
- package/components/description-list/example-inline-description-list.njk +58 -0
- package/components/details/_details.scss +1 -2
- package/components/details/example-details-open.njk +10 -0
- package/components/external-link/_macro.spec.js +66 -69
- package/components/external-link/_test_examples.js +4 -0
- package/components/feedback/_macro.spec.js +109 -80
- package/components/feedback/_test_examples.js +17 -0
- package/components/field/_macro.spec.js +106 -69
- package/components/header/_macro.njk +92 -90
- package/components/header/_macro.spec.js +10 -0
- package/components/header/example-header-basic.njk +11 -0
- package/components/hero/_hero.scss +239 -2
- package/components/hero/_macro.njk +7 -0
- package/components/hero/_macro.spec.js +5 -0
- package/components/hero/example-hero-navy-blue.njk +14 -0
- package/components/section-navigation/_macro.njk +9 -6
- package/components/table-of-contents/_macro.njk +3 -3
- package/components/table-of-contents/_macro.spec.js +3 -3
- package/components/table-of-contents/{_toc.scss → _table-of-contents.scss} +1 -1
- package/components/table-of-contents/table-of-contents.dom.js +13 -0
- package/components/table-of-contents/{toc.js → table-of-contents.js} +4 -4
- package/components/table-of-contents/{toc.spec.js → table-of-contents.spec.js} +2 -2
- package/components/tabs/_tabs.scss +10 -11
- package/components/tabs/tabs.js +3 -3
- package/components/timeout-modal/timeout-modal.spec.js +1 -1
- package/css/main.css +1 -1
- package/js/main.js +1 -1
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +1 -1
- package/scss/utilities/_margin.scss +4 -0
- package/scss/utilities/_padding.scss +4 -0
- package/scss/vars/_colors.scss +2 -0
- package/components/table-of-contents/toc.dom.js +0 -13
|
@@ -5,91 +5,128 @@ import * as cheerio from 'cheerio';
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
6
|
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
expect(results).toHaveNoViolations();
|
|
8
|
+
describe('FOR: Macro: Field', () => {
|
|
9
|
+
describe('GIVEN: Params: none', () => {
|
|
10
|
+
describe('WHEN: no params are provided', () => {
|
|
11
|
+
const $ = cheerio.load(renderComponent('field'));
|
|
12
|
+
test('THEN: passes jest-axe checks', async () => {
|
|
13
|
+
const results = await axe($.html());
|
|
14
|
+
expect(results).toHaveNoViolations();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
18
17
|
});
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
describe('GIVEN: Params: id', () => {
|
|
20
|
+
describe('WHEN: id is provided', () => {
|
|
21
|
+
const $ = cheerio.load(
|
|
22
|
+
renderComponent('field', {
|
|
23
|
+
id: 'example-field',
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
test('THEN: renders with the provided id', () => {
|
|
27
|
+
expect($('.ons-field').attr('id')).toBe('example-field');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
24
30
|
});
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
describe('GIVEN: Params: classes', () => {
|
|
33
|
+
describe('WHEN: additional style classes are provided', () => {
|
|
34
|
+
const $ = cheerio.load(
|
|
35
|
+
renderComponent('field', {
|
|
36
|
+
classes: 'extra-class another-extra-class',
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
test('THEN: renders with provided classes', () => {
|
|
40
|
+
expect($('.ons-field').hasClass('extra-class')).toBe(true);
|
|
41
|
+
expect($('.ons-field').hasClass('another-extra-class')).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
36
44
|
});
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
describe('GIVEN: Params: inline', () => {
|
|
47
|
+
describe('WHEN: inline is provided', () => {
|
|
48
|
+
const $ = cheerio.load(
|
|
49
|
+
renderComponent('field', {
|
|
50
|
+
inline: true,
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
53
|
+
test('THEN: renders with the inline class', () => {
|
|
54
|
+
expect($('.ons-field').hasClass('ons-field--inline')).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
47
57
|
});
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
describe('GIVEN: Params: attributes', () => {
|
|
60
|
+
describe('WHEN: custom attributes are provided', () => {
|
|
61
|
+
const $ = cheerio.load(
|
|
62
|
+
renderComponent('field', {
|
|
63
|
+
attributes: {
|
|
64
|
+
a: 123,
|
|
65
|
+
b: 456,
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
test('THEN: renders with additionally provided attributes', () => {
|
|
70
|
+
expect($('.ons-field').attr('a')).toBe('123');
|
|
71
|
+
expect($('.ons-field').attr('b')).toBe('456');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
62
74
|
});
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
describe('GIVEN: Params: dontWrap', () => {
|
|
77
|
+
describe('WHEN: dontWrap is set to true', () => {
|
|
78
|
+
const $ = cheerio.load(
|
|
79
|
+
renderComponent('field', {
|
|
80
|
+
dontWrap: true,
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
test('THEN: renders the content without being wrapped in a field div', () => {
|
|
84
|
+
expect($('.ons-field').length).toBe(0);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
74
87
|
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
describe('WHEN: dontWrap is set to false', () => {
|
|
89
|
+
const $ = cheerio.load(
|
|
90
|
+
renderComponent('field', {
|
|
91
|
+
dontWrap: false,
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
test('THEN: renders the content wrapped in a field div', () => {
|
|
95
|
+
expect($('.ons-field').length).toBe(1);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
77
98
|
|
|
78
|
-
|
|
79
|
-
|
|
99
|
+
describe('WHEN: dontWrap is not provided', () => {
|
|
100
|
+
const $ = cheerio.load(renderComponent('field', {}));
|
|
101
|
+
test('THEN: renders the content wrapped in a field div', () => {
|
|
102
|
+
expect($('.ons-field').length).toBe(1);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
80
105
|
});
|
|
81
106
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
107
|
+
describe('GIVEN: Params: error', () => {
|
|
108
|
+
describe('WHEN: error is provided', () => {
|
|
109
|
+
const faker = templateFaker();
|
|
110
|
+
const errorSpy = faker.spy('error');
|
|
111
|
+
|
|
112
|
+
faker.renderComponent('field', {
|
|
113
|
+
error: { text: 'There is an error' },
|
|
114
|
+
});
|
|
115
|
+
test('THEN" calls the error component', () => {
|
|
116
|
+
expect(errorSpy.occurrences[0]).toEqual({
|
|
117
|
+
text: 'There is an error',
|
|
118
|
+
});
|
|
119
|
+
});
|
|
89
120
|
});
|
|
121
|
+
});
|
|
90
122
|
|
|
91
|
-
|
|
92
|
-
|
|
123
|
+
describe('GIVEN: Content', () => {
|
|
124
|
+
describe('WHEN: field is called with content provided', () => {
|
|
125
|
+
const $ = cheerio.load(renderComponent('field', {}, 'Example content...'));
|
|
126
|
+
const content = $('.ons-field').html().trim();
|
|
127
|
+
test('THEN: renders the field with the provided content', () => {
|
|
128
|
+
expect(content).toEqual(expect.stringContaining('Example content...'));
|
|
129
|
+
});
|
|
93
130
|
});
|
|
94
131
|
});
|
|
95
132
|
});
|
|
@@ -218,118 +218,120 @@
|
|
|
218
218
|
</nav>
|
|
219
219
|
{% endif %}
|
|
220
220
|
</div>
|
|
221
|
-
|
|
222
|
-
<div class="ons-
|
|
223
|
-
<div
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
221
|
+
{% if params.variants != "basic" %}
|
|
222
|
+
<div class="ons-header__main">
|
|
223
|
+
<div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
|
|
224
|
+
<div
|
|
225
|
+
class="ons-grid ons-grid-flex ons-grid-flex--between ons-grid-flex--vertical-center ons-grid-flex--no-wrap{{ ' ons-grid--gutterless' if not params.button }}"
|
|
226
|
+
>
|
|
227
|
+
<div class="ons-grid__col ons-col-auto ons-u-flex-shrink">
|
|
228
|
+
{% if params.titleLogo.large %}
|
|
228
229
|
|
|
229
|
-
|
|
230
|
-
<div
|
|
231
|
-
class="ons-header__title-logo ons-header__title-logo--large{{ ' ' + params.titleLogo.classes if params.titleLogo.classes else '' }}{{ ' ons-u-d-no@2xs@s' if params.titleLogo.small }}"
|
|
232
|
-
>
|
|
233
|
-
{{ params.titleLogo.large | safe }}
|
|
234
|
-
</div>
|
|
235
|
-
{% if params.titleLogo.small %}
|
|
230
|
+
{% set title %}
|
|
236
231
|
<div
|
|
237
|
-
class="ons-header__title-logo ons-header__title-logo--
|
|
232
|
+
class="ons-header__title-logo ons-header__title-logo--large{{ ' ' + params.titleLogo.classes if params.titleLogo.classes else '' }}{{ ' ons-u-d-no@2xs@s' if params.titleLogo.small }}"
|
|
238
233
|
>
|
|
239
|
-
{{ params.titleLogo.
|
|
234
|
+
{{ params.titleLogo.large | safe }}
|
|
240
235
|
</div>
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
{% if params.titleLogo.small %}
|
|
237
|
+
<div
|
|
238
|
+
class="ons-header__title-logo ons-header__title-logo--small ons-u-d-no@s{{ ' ' + params.titleLogo.classes if params.titleLogo.classes else '' }}"
|
|
239
|
+
>
|
|
240
|
+
{{ params.titleLogo.small | safe }}
|
|
241
|
+
</div>
|
|
242
|
+
{% endif %}
|
|
243
|
+
{% endset %}
|
|
243
244
|
|
|
244
|
-
|
|
245
|
-
|
|
245
|
+
{% if params.titleUrl %}
|
|
246
|
+
<a class="ons-header__title-logo-link" href="{{ params.titleUrl }}">{{ title | safe }}</a>
|
|
247
|
+
{% else %}
|
|
248
|
+
{{ title | safe }}
|
|
249
|
+
{% endif %}
|
|
246
250
|
{% else %}
|
|
247
|
-
{{ title | safe }}
|
|
248
|
-
{% endif %}
|
|
249
|
-
{% else %}
|
|
250
251
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
{% set title %}
|
|
253
|
+
{{ openingTag | safe }}
|
|
254
|
+
class="ons-header__title">{{ params.title }}{{ closingTag | safe }}
|
|
255
|
+
{% endset %}
|
|
255
256
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
{% if params.titleUrl %}
|
|
258
|
+
<a class="ons-header__title-link" href="{{ params.titleUrl }}">{{ title | safe }}</a>
|
|
259
|
+
{% else %}
|
|
260
|
+
{{ title | safe }}
|
|
261
|
+
{% endif %}
|
|
260
262
|
{% endif %}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
</div>
|
|
263
|
+
{% if params.description %}
|
|
264
|
+
<p class="ons-header__description">{{ params.description }}</p>
|
|
265
|
+
{% endif %}
|
|
266
|
+
</div>
|
|
266
267
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
{% if params.button %}
|
|
269
|
+
{% if params.variants == 'neutral' %}
|
|
270
|
+
{% set buttonVariant = "ghost-dark" %}
|
|
271
|
+
{% else %}
|
|
272
|
+
{% set buttonVariant = "ghost" %}
|
|
273
|
+
{% endif %}
|
|
274
|
+
<div class="ons-grid__col ons-col-auto ons-u-flex-no-shrink">
|
|
275
|
+
{{
|
|
276
|
+
onsButton({
|
|
277
|
+
"text": params.button.text,
|
|
278
|
+
"classes": "ons-u-d-no@2xs@l" if params.navigation else "ons-u-d-no@2xs@m",
|
|
279
|
+
"variants": buttonVariant,
|
|
280
|
+
"name": params.button.name,
|
|
281
|
+
"attributes": params.button.attributes,
|
|
282
|
+
"url": params.button.url,
|
|
283
|
+
"iconType": "exit",
|
|
284
|
+
"iconPosition": "after"
|
|
285
|
+
})
|
|
286
|
+
}}
|
|
287
|
+
</div>
|
|
272
288
|
{% endif %}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
"
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
289
|
+
{% if params.navigation or params.siteSearchAutosuggest %}
|
|
290
|
+
<div class="ons-grid__col ons-col-auto ons-u-flex-no-shrink">
|
|
291
|
+
{% if params.siteSearchAutosuggest %}
|
|
292
|
+
{% if params.variants == 'neutral' %}
|
|
293
|
+
{% set buttonVariant = ["small", "ghost-dark"] %}
|
|
294
|
+
{% else %}
|
|
295
|
+
{% set buttonVariant = ["small", "ghost"] %}
|
|
296
|
+
{% endif %}
|
|
297
|
+
<span class="ons-grid ons-u-d-no@2xs@xs ons-u-ml-no ons-u-d-no@l">
|
|
298
|
+
{{
|
|
299
|
+
onsButton({
|
|
300
|
+
"text": "Search",
|
|
301
|
+
"classes": "ons-btn--search ons-u-ml-2xs ons-u-d-no ons-js-toggle-search",
|
|
302
|
+
"variants": buttonVariant,
|
|
303
|
+
"iconType": "search",
|
|
304
|
+
"iconPosition": "only",
|
|
305
|
+
"attributes": {
|
|
306
|
+
"aria-label": "Toggle search" ,
|
|
307
|
+
"aria-controls": "ons-site-search",
|
|
308
|
+
"aria-expanded": "false"
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
}}
|
|
312
|
+
</span>
|
|
295
313
|
{% endif %}
|
|
296
|
-
|
|
314
|
+
{% if params.navigation.toggleNavigationButton %}
|
|
315
|
+
{% set buttonVariant = ["mobile", "ghost"] %}
|
|
297
316
|
{{
|
|
298
317
|
onsButton({
|
|
299
|
-
"text":
|
|
300
|
-
"classes": "ons-
|
|
318
|
+
"text": params.navigation.toggleNavigationButton.text,
|
|
319
|
+
"classes": "ons-u-ml-2xs ons-u-d-no ons-js-navigation-button ons-u-d-no@l",
|
|
301
320
|
"variants": buttonVariant,
|
|
302
|
-
"iconType": "search",
|
|
303
|
-
"iconPosition": "only",
|
|
304
321
|
"attributes": {
|
|
305
|
-
"aria-label": "Toggle
|
|
306
|
-
"aria-controls":
|
|
322
|
+
"aria-label": params.navigation.toggleNavigationButton.ariaLabel | default("Toggle main menu") ,
|
|
323
|
+
"aria-controls": params.navigation.id,
|
|
307
324
|
"aria-expanded": "false"
|
|
308
325
|
}
|
|
309
326
|
})
|
|
310
327
|
}}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
{{
|
|
316
|
-
onsButton({
|
|
317
|
-
"text": params.navigation.toggleNavigationButton.text,
|
|
318
|
-
"classes": "ons-u-ml-2xs ons-u-d-no ons-js-navigation-button ons-u-d-no@l",
|
|
319
|
-
"variants": buttonVariant,
|
|
320
|
-
"attributes": {
|
|
321
|
-
"aria-label": params.navigation.toggleNavigationButton.ariaLabel | default("Toggle main menu") ,
|
|
322
|
-
"aria-controls": params.navigation.id,
|
|
323
|
-
"aria-expanded": "false"
|
|
324
|
-
}
|
|
325
|
-
})
|
|
326
|
-
}}
|
|
327
|
-
{% endif %}
|
|
328
|
-
</div>
|
|
329
|
-
{% endif %}
|
|
328
|
+
{% endif %}
|
|
329
|
+
</div>
|
|
330
|
+
{% endif %}
|
|
331
|
+
</div>
|
|
330
332
|
</div>
|
|
331
333
|
</div>
|
|
332
|
-
|
|
334
|
+
{% endif %}
|
|
333
335
|
{% if params.navigation %}
|
|
334
336
|
{{ onsNavigation(params) }}
|
|
335
337
|
{% endif %}
|
|
@@ -43,6 +43,16 @@ describe('FOR: Macro: Header', () => {
|
|
|
43
43
|
expect($('.ons-header--variant-b').length).toBe(1);
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
+
describe('WHEN: variants is set to basic', () => {
|
|
47
|
+
test('THEN: does not render the main part of the header', () => {
|
|
48
|
+
const $ = cheerio.load(
|
|
49
|
+
renderComponent('header', {
|
|
50
|
+
variants: 'basic',
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
53
|
+
expect($('.ons-header > .ons-header__main').length).toBe(0);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
46
56
|
});
|
|
47
57
|
describe('GIVEN: Params: classes', () => {
|
|
48
58
|
describe('WHEN: classes are provided', () => {
|