@ons/design-system 66.0.2 → 67.0.1
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 +3 -2
- package/components/accordion/_macro.spec.js +2 -8
- package/components/accordion/accordion.dom.js +2 -2
- package/components/accordion/accordion.spec.js +22 -19
- package/components/accordion/example-accordion-open.njk +3 -3
- package/components/card/_card.scss +1 -1
- package/components/checkboxes/_macro.njk +1 -1
- package/components/checkboxes/example-checkboxes-with-revealed-checkboxes-expanded.njk +1 -1
- package/components/checkboxes/example-checkboxes-with-revealed-checkboxes.njk +1 -1
- package/components/cookies-banner/_macro.njk +1 -1
- package/components/cookies-banner/_macro.spec.js +1 -1
- package/components/details/_details.scss +66 -57
- package/components/details/_macro.njk +5 -5
- package/components/details/_macro.spec.js +3 -10
- package/components/details/details.dom.js +1 -1
- package/components/details/details.js +13 -1
- package/components/details/details.spec.js +43 -11
- package/components/details/example-details-with-warning.njk +1 -2
- package/components/footer/_macro.njk +1 -1
- package/components/header/_header.scss +4 -0
- package/components/header/_macro.njk +17 -17
- package/components/header/_macro.spec.js +128 -5
- package/components/header/example-header-external-with-navigation-and-search.njk +57 -0
- package/components/input/_input-type.scss +2 -2
- package/components/input/_macro.njk +1 -1
- package/components/input/_macro.spec.js +4 -16
- package/components/input/input.dom.js +11 -0
- package/components/input/input.js +14 -0
- package/components/input/input.spec.js +28 -0
- package/components/label/_macro.njk +2 -2
- package/components/navigation/_macro.njk +3 -1
- package/components/related-content/_macro.njk +28 -30
- package/components/section-navigation/_macro.njk +68 -55
- package/components/section-navigation/_section-navigation.scss +20 -2
- package/components/video/_macro.njk +11 -11
- package/css/main.css +1 -1
- package/css/print.css +1 -1
- package/js/main.js +1 -0
- package/layout/_template.njk +29 -30
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/objects/_page.scss +3 -5
- package/scss/print.scss +28 -5
- package/components/collapsible/_macro.njk +0 -22
- package/components/collapsible/_macro.spec.js +0 -151
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
{% set currentLanguageISOCode = currentLanguage.ISOCode %}
|
|
13
13
|
{% endif %}
|
|
14
14
|
|
|
15
|
-
<header class="ons-header
|
|
15
|
+
<header class="ons-header{% if params.classes %} {{ params.classes }}{% endif %}{% if params.variants is not string %}{% for variant in params.variants %} ons-header--{{ variant }}{% endfor %}{% else %} ons-header--{{ params.variants }}{% endif %}" role="banner">
|
|
16
16
|
{{
|
|
17
17
|
onsBrowserBanner({
|
|
18
18
|
"lang": currentLanguageISOCode,
|
|
@@ -141,22 +141,22 @@
|
|
|
141
141
|
<ul class="ons-header-service-nav__list">
|
|
142
142
|
{% for item in params.serviceLinks.itemsList %}
|
|
143
143
|
<li class="ons-header-service-nav__item ons-header-service-nav__item--mobile">
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
144
|
+
{% if item.iconType %}
|
|
145
|
+
{{
|
|
146
|
+
onsIcon({
|
|
147
|
+
"iconType": item.iconType
|
|
148
|
+
})
|
|
149
|
+
}}
|
|
150
|
+
{% endif %}
|
|
151
|
+
{% if item.url %}
|
|
152
|
+
<a
|
|
153
|
+
href="{{ item.url }}"
|
|
154
|
+
class="ons-header-service-nav__link"
|
|
155
|
+
{% if item.id %} id="{{ item.id }}"{% endif %}
|
|
156
|
+
>{% if item.title %}{{ item.title }}{% elif item.text %}{{ item.text }}{% endif %}</a>
|
|
157
|
+
{% else %}
|
|
158
|
+
{% if item.title %}{{ item.title }}{% elif item.text %}{{ item.text }}{% endif %}
|
|
159
|
+
{% endif %}
|
|
160
160
|
</li>
|
|
161
161
|
{% endfor %}
|
|
162
162
|
</ul>
|
|
@@ -161,6 +161,45 @@ const EXAMPLE_HEADER_NAVIGATION_WITH_SUBNAVIGATION_CONFIG = {
|
|
|
161
161
|
},
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
const EXAMPLE_HEADER_NAVIGATION_WITH_SITESEARCHAUTOSUGGEST = {
|
|
165
|
+
navigation: {
|
|
166
|
+
id: 'main-nav',
|
|
167
|
+
ariaLabel: 'Main menu',
|
|
168
|
+
currentPath: '#home',
|
|
169
|
+
itemsList: [
|
|
170
|
+
{
|
|
171
|
+
title: 'Home',
|
|
172
|
+
url: '#home',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
title: 'Guidance',
|
|
176
|
+
url: '#0',
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
toggleNavigationButton: {
|
|
180
|
+
text: 'Menu',
|
|
181
|
+
ariaLabel: 'Toggle main menu',
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
siteSearchAutosuggest: {
|
|
185
|
+
label: 'label',
|
|
186
|
+
instructions: 'Use up and down keys to navigate.',
|
|
187
|
+
ariaYouHaveSelected: 'You have selected',
|
|
188
|
+
ariaMinChars: 'Enter 3 or more characters for suggestions.',
|
|
189
|
+
minChars: 3,
|
|
190
|
+
ariaResultsLabel: 'Country suggestions',
|
|
191
|
+
ariaOneResult: 'There is one suggestion available.',
|
|
192
|
+
ariaNResults: 'There are {n} suggestions available.',
|
|
193
|
+
ariaLimitedResults: 'Type more characters to improve your search',
|
|
194
|
+
moreResults: 'Continue entering to improve suggestions',
|
|
195
|
+
resultsTitle: 'Suggestions',
|
|
196
|
+
resultsTitleId: 'country-of-birth-suggestions',
|
|
197
|
+
noResults: 'No suggestions found.',
|
|
198
|
+
typeMore: 'Continue entering to get suggestions',
|
|
199
|
+
language: 'en-gb',
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
164
203
|
describe('macro: header', () => {
|
|
165
204
|
describe('mode: basic', () => {
|
|
166
205
|
it('passes jest-axe checks', async () => {
|
|
@@ -453,21 +492,21 @@ describe('macro: header', () => {
|
|
|
453
492
|
it('has the text for each list item', () => {
|
|
454
493
|
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LIST_ITEMS));
|
|
455
494
|
|
|
456
|
-
const values = mapAll($('.ons-header-service-nav--main .ons-header-service-nav__item'), node => node.text().trim());
|
|
495
|
+
const values = mapAll($('.ons-header-service-nav--main .ons-header-service-nav__item'), (node) => node.text().trim());
|
|
457
496
|
expect(values).toEqual(['Title 1', 'Title 2', 'Title 3']);
|
|
458
497
|
});
|
|
459
498
|
|
|
460
499
|
it('has the link text for each list item', () => {
|
|
461
500
|
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LINKS_MULTIPLE));
|
|
462
501
|
|
|
463
|
-
const values = mapAll($('.ons-header-service-nav--main .ons-header-service-nav__link'), node => node.text().trim());
|
|
502
|
+
const values = mapAll($('.ons-header-service-nav--main .ons-header-service-nav__link'), (node) => node.text().trim());
|
|
464
503
|
expect(values).toEqual(['Title 1', 'Title 2', 'Title 3']);
|
|
465
504
|
});
|
|
466
505
|
|
|
467
506
|
it('has the link href for each list item', () => {
|
|
468
507
|
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LINKS_MULTIPLE));
|
|
469
508
|
|
|
470
|
-
const values = mapAll($('.ons-header-service-nav--main .ons-header-service-nav__link'), node => node.attr('href'));
|
|
509
|
+
const values = mapAll($('.ons-header-service-nav--main .ons-header-service-nav__link'), (node) => node.attr('href'));
|
|
471
510
|
expect(values).toEqual(['#1', '#2', '#3']);
|
|
472
511
|
});
|
|
473
512
|
|
|
@@ -486,14 +525,14 @@ describe('macro: header', () => {
|
|
|
486
525
|
it('has the link text for each list item for mobile', () => {
|
|
487
526
|
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LINKS_MULTIPLE));
|
|
488
527
|
|
|
489
|
-
const values = mapAll($('.ons-header-service-nav--mobile .ons-header-service-nav__link'), node => node.text().trim());
|
|
528
|
+
const values = mapAll($('.ons-header-service-nav--mobile .ons-header-service-nav__link'), (node) => node.text().trim());
|
|
490
529
|
expect(values).toEqual(['Title 1', 'Title 2', 'Title 3']);
|
|
491
530
|
});
|
|
492
531
|
|
|
493
532
|
it('has the link href for each list item for mobile', () => {
|
|
494
533
|
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LINKS_MULTIPLE));
|
|
495
534
|
|
|
496
|
-
const values = mapAll($('.ons-header-service-nav--mobile .ons-header-service-nav__link'), node => node.attr('href'));
|
|
535
|
+
const values = mapAll($('.ons-header-service-nav--mobile .ons-header-service-nav__link'), (node) => node.attr('href'));
|
|
497
536
|
expect(values).toEqual(['#1', '#2', '#3']);
|
|
498
537
|
});
|
|
499
538
|
|
|
@@ -742,3 +781,87 @@ describe('macro: header', () => {
|
|
|
742
781
|
});
|
|
743
782
|
});
|
|
744
783
|
});
|
|
784
|
+
|
|
785
|
+
describe('mode: with site search autosuggest', () => {
|
|
786
|
+
it('renders the search with expected parameters', () => {
|
|
787
|
+
const faker = templateFaker();
|
|
788
|
+
const buttonSpy = faker.spy('autosuggest');
|
|
789
|
+
|
|
790
|
+
faker.renderComponent('header', EXAMPLE_HEADER_NAVIGATION_WITH_SITESEARCHAUTOSUGGEST);
|
|
791
|
+
|
|
792
|
+
expect(buttonSpy.occurrences[0]).toEqual({
|
|
793
|
+
ariaLimitedResults: 'Type more characters to improve your search',
|
|
794
|
+
minChars: 3,
|
|
795
|
+
language: 'en-gb',
|
|
796
|
+
ariaMinChars: 'Enter 3 or more characters for suggestions.',
|
|
797
|
+
ariaNResults: 'There are {n} suggestions available.',
|
|
798
|
+
ariaOneResult: 'There is one suggestion available.',
|
|
799
|
+
ariaResultsLabel: 'Country suggestions',
|
|
800
|
+
ariaYouHaveSelected: 'You have selected',
|
|
801
|
+
containerClasses: 'ons-autosuggest--header',
|
|
802
|
+
id: 'ons-site-search',
|
|
803
|
+
input: {
|
|
804
|
+
accessiblePlaceholder: true,
|
|
805
|
+
autocomplete: 'off',
|
|
806
|
+
classes: 'ons-input-search ons-input-search--icon',
|
|
807
|
+
label: {
|
|
808
|
+
classes: 'ons-u-pl-m ons-label--white',
|
|
809
|
+
id: 'ons-site-search-label',
|
|
810
|
+
text: 'label',
|
|
811
|
+
},
|
|
812
|
+
},
|
|
813
|
+
instructions: 'Use up and down keys to navigate.',
|
|
814
|
+
moreResults: 'Continue entering to improve suggestions',
|
|
815
|
+
noResults: 'No suggestions found.',
|
|
816
|
+
resultsTitle: 'Suggestions',
|
|
817
|
+
typeMore: 'Continue entering to get suggestions',
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
describe('when the user inputs text', () => {
|
|
822
|
+
let $; // Initialize a Cheerio instance
|
|
823
|
+
|
|
824
|
+
const mockData = [
|
|
825
|
+
{ en: 'England' },
|
|
826
|
+
{ en: 'Wales' },
|
|
827
|
+
{ en: 'Scotland' },
|
|
828
|
+
{ en: 'United States of America' },
|
|
829
|
+
{ en: 'United States Virgin Islands' },
|
|
830
|
+
{ en: 'Åland Islands' },
|
|
831
|
+
];
|
|
832
|
+
|
|
833
|
+
beforeEach(() => {
|
|
834
|
+
$ = cheerio.load(
|
|
835
|
+
renderComponent('header', {
|
|
836
|
+
...EXAMPLE_HEADER_NAVIGATION_WITH_SITESEARCHAUTOSUGGEST,
|
|
837
|
+
autosuggestData: mockData,
|
|
838
|
+
}),
|
|
839
|
+
);
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
it('does not show suggestions when input length < minimum characters', () => {
|
|
843
|
+
$('.ons-js-autosuggest-input').val('En');
|
|
844
|
+
|
|
845
|
+
setTimeout(() => {
|
|
846
|
+
const suggestionCount = $('.ons-autosuggest__option').length;
|
|
847
|
+
expect(suggestionCount).toBe(0);
|
|
848
|
+
}, 20);
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
it('shows suggestions when input length >= minimum characters', () => {
|
|
852
|
+
$('.ons-js-autosuggest-input').val('Eng');
|
|
853
|
+
|
|
854
|
+
setTimeout(() => {
|
|
855
|
+
const suggestionCount = $('.ons-autosuggest__option').length;
|
|
856
|
+
expect(suggestionCount).toBe(1);
|
|
857
|
+
}, 20);
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
it('gets the language if set', () => {
|
|
861
|
+
$('.ons-js-autosuggest-input').val('Eng');
|
|
862
|
+
|
|
863
|
+
const autosuggestElement = $('.ons-js-autosuggest').attr('data-lang');
|
|
864
|
+
expect(autosuggestElement).toBe('en-gb');
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
"fullWidth": true
|
|
3
|
+
---
|
|
4
|
+
{% from "components/header/_macro.njk" import onsHeader %}
|
|
5
|
+
|
|
6
|
+
{{
|
|
7
|
+
onsHeader({
|
|
8
|
+
"title": 'Design system',
|
|
9
|
+
"titleUrl": '#0',
|
|
10
|
+
"navigation": {
|
|
11
|
+
"id": 'main-nav',
|
|
12
|
+
"ariaLabel": 'Main menu',
|
|
13
|
+
"currentPath": '#home',
|
|
14
|
+
"itemsList": [
|
|
15
|
+
{
|
|
16
|
+
"text": 'Home',
|
|
17
|
+
"url": '#home'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"text": 'Guidance',
|
|
21
|
+
"url": '#0'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"text": 'Foundations',
|
|
25
|
+
"url": '#0'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"text": 'Components',
|
|
29
|
+
"url": '#0'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"text": 'Patterns',
|
|
33
|
+
"url": '#0'
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"toggleNavigationButton": {
|
|
37
|
+
"text": 'Menu',
|
|
38
|
+
"ariaLabel": 'Toggle main menu'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
'siteSearchAutosuggest': {
|
|
42
|
+
"autosuggestData": "/examples/data/country-of-birth.json",
|
|
43
|
+
"label": "search",
|
|
44
|
+
"instructions": "instructions",
|
|
45
|
+
"ariaYouHaveSelected": "ariaYouHaveSelected",
|
|
46
|
+
"ariaMinChars": "ariaMinChars",
|
|
47
|
+
"ariaResultsLabel": "ariaResultsLabel",
|
|
48
|
+
"ariaOneResult": "ariaOneResult",
|
|
49
|
+
"ariaNResults": "ariaNResults",
|
|
50
|
+
"ariaLimitedResults": "ariaLimitedResults",
|
|
51
|
+
"moreResults": "moreResults",
|
|
52
|
+
"resultsTitle": "resultsTitle",
|
|
53
|
+
"noResults": "noResults",
|
|
54
|
+
"typeMore": "typeMore"
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
}}
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
z-index: 1;
|
|
15
15
|
|
|
16
16
|
&:focus {
|
|
17
|
-
//
|
|
17
|
+
// Override default input focus so it can wrap prefix/suffix too
|
|
18
18
|
box-shadow: none;
|
|
19
19
|
outline: none;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
//
|
|
22
|
+
// Override default input error style so it can wrap prefix/suffix too
|
|
23
23
|
&.ons-input--error:not(:focus) {
|
|
24
24
|
border-right: $input-border-width solid var(--ons-color-input-border);
|
|
25
25
|
box-shadow: none;
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
{% set prefixClass = " ons-input-type--prefix" %}
|
|
77
77
|
{% endif %}
|
|
78
78
|
|
|
79
|
-
<span class="ons-input-type{{ prefixClass }}">
|
|
79
|
+
<span class="ons-input-type{{ prefixClass }}{% if params.prefix or params.suffix %} ons-js-input-container-abbr{% endif %}">
|
|
80
80
|
<span class="ons-input-type__inner">
|
|
81
81
|
{{ input | safe }}
|
|
82
82
|
|
|
@@ -245,7 +245,7 @@ describe('macro: input', () => {
|
|
|
245
245
|
expect($('.ons-input').attr('autocomplete')).toBe('on');
|
|
246
246
|
});
|
|
247
247
|
|
|
248
|
-
it.each([['email'], ['tel'], ['text']])('outputs `type` attribute of "%s"', type => {
|
|
248
|
+
it.each([['email'], ['tel'], ['text']])('outputs `type` attribute of "%s"', (type) => {
|
|
249
249
|
const $ = cheerio.load(
|
|
250
250
|
renderComponent('input', {
|
|
251
251
|
...EXAMPLE_INPUT_MINIMAL,
|
|
@@ -421,11 +421,7 @@ describe('macro: input', () => {
|
|
|
421
421
|
|
|
422
422
|
expect($('.ons-input-type--prefix .ons-js-input-abbr').attr('id')).toBe('example-prefix-id');
|
|
423
423
|
expect($('.ons-input-type--prefix .ons-js-input-abbr').attr('title')).toBe('Example prefix title');
|
|
424
|
-
expect(
|
|
425
|
-
$('.ons-input-type--prefix .ons-js-input-abbr')
|
|
426
|
-
.text()
|
|
427
|
-
.trim(),
|
|
428
|
-
).toBe('Example prefix text');
|
|
424
|
+
expect($('.ons-input-type--prefix .ons-js-input-abbr').text().trim()).toBe('Example prefix text');
|
|
429
425
|
});
|
|
430
426
|
|
|
431
427
|
it('does not render prefix element when `prefix.id` not set', () => {
|
|
@@ -483,11 +479,7 @@ describe('macro: input', () => {
|
|
|
483
479
|
|
|
484
480
|
expect($('.ons-js-input-abbr').attr('id')).toBe('example-suffix-id');
|
|
485
481
|
expect($('.ons-js-input-abbr').attr('title')).toBe('Example suffix title');
|
|
486
|
-
expect(
|
|
487
|
-
$('.ons-js-input-abbr')
|
|
488
|
-
.text()
|
|
489
|
-
.trim(),
|
|
490
|
-
).toBe('Example suffix text');
|
|
482
|
+
expect($('.ons-js-input-abbr').text().trim()).toBe('Example suffix text');
|
|
491
483
|
});
|
|
492
484
|
|
|
493
485
|
it('does not render suffix element when `suffix.id` not set', () => {
|
|
@@ -653,11 +645,7 @@ describe('macro: input', () => {
|
|
|
653
645
|
);
|
|
654
646
|
|
|
655
647
|
expect($('a.ons-input__post-link').attr('href')).toBe('https://example.com/link');
|
|
656
|
-
expect(
|
|
657
|
-
$('a.ons-input__post-link')
|
|
658
|
-
.text()
|
|
659
|
-
.trim(),
|
|
660
|
-
).toBe('Example link');
|
|
648
|
+
expect($('a.ons-input__post-link').text().trim()).toBe('Example link');
|
|
661
649
|
});
|
|
662
650
|
});
|
|
663
651
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import domready from '../../js/domready';
|
|
2
|
+
|
|
3
|
+
domready(async () => {
|
|
4
|
+
const abbrInputs = [...document.querySelectorAll('.ons-js-input-container-abbr')];
|
|
5
|
+
|
|
6
|
+
if (abbrInputs.length) {
|
|
7
|
+
const abbrInput = (await import('./input')).default;
|
|
8
|
+
|
|
9
|
+
abbrInputs.forEach((element) => new abbrInput(element));
|
|
10
|
+
}
|
|
11
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default class AbbrInput {
|
|
2
|
+
constructor(context) {
|
|
3
|
+
this.abbrInput = context;
|
|
4
|
+
this.bindEventListeners();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
bindEventListeners() {
|
|
8
|
+
this.abbrInput.querySelector('.ons-js-input-abbr').addEventListener('click', this.handleClick.bind(this));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
handleClick() {
|
|
12
|
+
this.abbrInput.querySelector('.ons-input').focus();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as cheerio from 'cheerio';
|
|
2
|
+
|
|
3
|
+
import axe from '../../tests/helpers/axe';
|
|
4
|
+
import { renderComponent, templateFaker, setTestPage } from '../../tests/helpers/rendering';
|
|
5
|
+
|
|
6
|
+
const EXAMPLE_INPUT_MINIMAL = {
|
|
7
|
+
id: 'example-id',
|
|
8
|
+
name: 'example-name',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe('script: input', () => {
|
|
12
|
+
it('focuses input when abbreviation is clicked', async () => {
|
|
13
|
+
await setTestPage(
|
|
14
|
+
'/test',
|
|
15
|
+
renderComponent('input', {
|
|
16
|
+
...EXAMPLE_INPUT_MINIMAL,
|
|
17
|
+
prefix: {
|
|
18
|
+
id: 'example-prefix-id',
|
|
19
|
+
title: 'Example prefix title',
|
|
20
|
+
text: 'Example prefix text',
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
await page.click('.ons-js-input-abbr');
|
|
25
|
+
const focusedElementId = await page.evaluate(() => document.activeElement.id);
|
|
26
|
+
expect(focusedElementId).toEqual('example-id');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{% macro onsLabel(params) %}
|
|
2
2
|
{% if params.id %}
|
|
3
|
-
{% set descriptionID = params.id ~ "-description-hint" %}
|
|
3
|
+
{% set descriptionID = params.id ~ "-description-hint" %}
|
|
4
4
|
{% else %}
|
|
5
|
-
{% set descriptionID = "description-hint" %}
|
|
5
|
+
{% set descriptionID = "description-hint" %}
|
|
6
6
|
{% endif %}
|
|
7
7
|
|
|
8
8
|
{% if params.inputType == "checkbox" or params.inputType == "radio" %}
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"instructions": params.siteSearchAutosuggest.instructions,
|
|
29
29
|
"ariaYouHaveSelected":params.siteSearchAutosuggest.ariaYouHaveSelected,
|
|
30
|
+
"minChars": params.siteSearchAutosuggest.minChars,
|
|
30
31
|
"ariaMinChars": params.siteSearchAutosuggest.ariaMinChars,
|
|
31
32
|
"ariaResultsLabel": params.siteSearchAutosuggest.ariaResultsLabel,
|
|
32
33
|
"ariaOneResult": params.siteSearchAutosuggest.ariaOneResult,
|
|
@@ -36,7 +37,8 @@
|
|
|
36
37
|
"resultsTitle": params.siteSearchAutosuggest.resultsTitle,
|
|
37
38
|
"autosuggestData": params.siteSearchAutosuggest.autosuggestData,
|
|
38
39
|
"noResults": params.siteSearchAutosuggest.noResults,
|
|
39
|
-
"typeMore": params.siteSearchAutosuggest.typeMore
|
|
40
|
+
"typeMore": params.siteSearchAutosuggest.typeMore,
|
|
41
|
+
"language": params.siteSearchAutosuggest.language
|
|
40
42
|
}) }}
|
|
41
43
|
</div>
|
|
42
44
|
{% endif %}
|
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
{% macro onsRelatedContent(params) %}
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
{% if params.classes %}
|
|
4
|
+
{% set classes = ' ' + params.classes %}
|
|
5
|
+
{% endif %}
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{% from "components/related-content/_section-macro.njk" import onsRelatedContentSection %}
|
|
11
|
-
{% call onsRelatedContentSection(
|
|
12
|
-
{
|
|
13
|
-
"title": row.title,
|
|
14
|
-
"id": row.id
|
|
15
|
-
}
|
|
16
|
-
) %}
|
|
17
|
-
<nav class="ons-related-content__navigation" aria-labelledby="{{ row.id }}">
|
|
7
|
+
<aside class="ons-related-content{{ classes }}" aria-label="{{ params.ariaLabel | default("Related content") }}">
|
|
8
|
+
{% if params.rows %}
|
|
9
|
+
{% from "components/related-content/_section-macro.njk" import onsRelatedContentSection %}
|
|
18
10
|
{% from "components/list/_macro.njk" import onsList %}
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
{% for row in params.rows %}
|
|
12
|
+
{% call onsRelatedContentSection({
|
|
13
|
+
"title": row.title,
|
|
14
|
+
"id": row.id
|
|
15
|
+
}) %}
|
|
16
|
+
<nav class="ons-related-content__navigation" aria-labelledby="{{ row.id }}">
|
|
17
|
+
{{
|
|
18
|
+
onsList({
|
|
19
|
+
"variants": 'bare',
|
|
20
|
+
"iconType": row.iconType,
|
|
21
|
+
"iconPosition": row.iconPosition,
|
|
22
|
+
"iconSize": row.iconSize,
|
|
23
|
+
"itemsList": row.itemsList
|
|
24
|
+
})
|
|
25
|
+
}}
|
|
26
|
+
</nav>
|
|
27
|
+
{% endcall %}
|
|
28
|
+
{% endfor %}
|
|
29
|
+
{% else %}
|
|
30
|
+
{{ caller() if caller }}
|
|
31
|
+
{% endif %}
|
|
32
|
+
</aside>
|
|
35
33
|
|
|
36
34
|
{% endmacro %}
|
|
@@ -1,59 +1,72 @@
|
|
|
1
1
|
{% macro onsSectionNavigation(params) %}
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
{% if params.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
2
|
+
{% set headingLevel = params.headingLevel | int | default(2) %}
|
|
3
|
+
{% set sectionTitleHeadingLevel = headingLevel + 1 %}
|
|
4
|
+
<nav class="ons-section-nav{% if params.variants == 'vertical' %} ons-section-nav--vertical{% endif %} {% if params.classes %} {{ params.classes }} {% endif %}"{% if params.id %} id="{{ params.id }}"{% endif %} aria-labelledby="{{ params.hiddenTitleId | default("section-menu-nav-title")}}">
|
|
5
|
+
<h{{ headingLevel }} class="ons-u-vh" id="{{ params.hiddenTitleId | default("section-menu-nav-title") }}">{{ params.hiddenTitle | default("Pages in this section") }}</h{{ headingLevel }}>
|
|
6
|
+
{% if params.sections %}
|
|
7
|
+
{% for section in params.sections %}
|
|
8
|
+
{% set sectionItemHeadingLevel = headingLevel + 2 if section.title else headingLevel + 1 %}
|
|
9
|
+
<div class="ons-section-nav__sub">
|
|
10
|
+
{% if section.title %}
|
|
11
|
+
<h{{ sectionTitleHeadingLevel }} class="ons-u-fs-r--b ons-u-mb-s">{{ section.title }}</h{{ sectionTitleHeadingLevel }}>
|
|
12
|
+
{% endif %}
|
|
13
|
+
<ul class="ons-section-nav__list">
|
|
14
|
+
{% for item in section.itemsList %}
|
|
15
|
+
{% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.title|lower) %}
|
|
16
|
+
{% set isCurrent = true %}
|
|
17
|
+
{% else %}
|
|
18
|
+
{% set isCurrent = false %}
|
|
19
|
+
{% endif %}
|
|
20
|
+
<li class="ons-section-nav__item{% if item.classes %}{{ ' ' + item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
|
|
21
|
+
{% if isCurrent == true %}
|
|
22
|
+
<h{{ sectionItemHeadingLevel }} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ sectionItemHeadingLevel }}>
|
|
23
|
+
{% else %}
|
|
24
|
+
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
|
|
25
|
+
{% endif %}
|
|
26
|
+
{% if item.anchors and isCurrent == true %}
|
|
27
|
+
<ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
|
|
28
|
+
{% for anchor in item.anchors %}
|
|
29
|
+
<li class="ons-section-nav__item ons-list__item">
|
|
30
|
+
<a href="{{ anchor.url }}" class="ons-section-nav__link ons-list__link">{{ anchor.title }}</a>
|
|
31
|
+
</li>
|
|
32
|
+
{% endfor %}
|
|
33
|
+
</ul>
|
|
34
|
+
{% endif %}
|
|
35
|
+
</li>
|
|
36
|
+
{% endfor %}
|
|
37
|
+
</ul>
|
|
38
|
+
</div>
|
|
39
|
+
{% endfor %}
|
|
40
|
+
{% else %}
|
|
41
|
+
{% if params.title %}
|
|
42
|
+
<h{{ sectionTitleHeadingLevel }} class="ons-u-fs-r--b ons-u-mb-s">{{ params.title }}</h{{ sectionTitleHeadingLevel }}>
|
|
43
|
+
{% endif %}
|
|
36
44
|
<ul class="ons-section-nav__list">
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<li class="ons-section-nav__item{% if item.classes %} ' ' + {{ item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
|
|
44
|
-
<a class="ons-section-nav__link" href="{{ item.url }}"{% if isCurrent == true %} aria-current="location"{% endif %}>{{ item.title }}</a>
|
|
45
|
-
{% if item.anchors %}
|
|
46
|
-
<ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
|
|
47
|
-
{% for anchor in item.anchors %}
|
|
48
|
-
<li class="ons-section-nav__item ons-list__item">
|
|
49
|
-
<a href="{{ anchor.url }}" class="ons-section-nav__link ons-list__link">{{ anchor.title }}</a>
|
|
50
|
-
</li>
|
|
51
|
-
{% endfor %}
|
|
52
|
-
</ul>
|
|
45
|
+
{% for item in params.itemsList %}
|
|
46
|
+
{% set sectionItemHeadingLevel = headingLevel + 2 if params.title else headingLevel + 1 %}
|
|
47
|
+
{% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.title|lower) %}
|
|
48
|
+
{% set isCurrent = true %}
|
|
49
|
+
{% else %}
|
|
50
|
+
{% set isCurrent = false %}
|
|
53
51
|
{% endif %}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
<li class="ons-section-nav__item{% if item.classes %}{{ ' ' + item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
|
|
53
|
+
{% if isCurrent == true %}
|
|
54
|
+
<h{{ sectionItemHeadingLevel}} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ headingLevel + 2 if section.title else headingLevel + 1 }}>
|
|
55
|
+
{% else %}
|
|
56
|
+
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
|
|
57
|
+
{% endif %}
|
|
58
|
+
{% if item.anchors %}
|
|
59
|
+
<ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
|
|
60
|
+
{% for anchor in item.anchors %}
|
|
61
|
+
<li class="ons-section-nav__item ons-list__item">
|
|
62
|
+
<a href="{{ anchor.url }}" class="ons-section-nav__link ons-list__link">{{ anchor.title }}</a>
|
|
63
|
+
</li>
|
|
64
|
+
{% endfor %}
|
|
65
|
+
</ul>
|
|
66
|
+
{% endif %}
|
|
67
|
+
</li>
|
|
68
|
+
{% endfor %}
|
|
69
|
+
</ul>
|
|
70
|
+
{% endif %}
|
|
71
|
+
</nav>
|
|
59
72
|
{% endmacro %}
|