@ons/design-system 65.2.5 → 66.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/components/address-input/_macro.njk +12 -10
- package/components/address-input/_macro.spec.js +12 -10
- package/components/autosuggest/_macro.njk +38 -25
- package/components/autosuggest/_macro.spec.js +90 -17
- package/components/autosuggest/autosuggest.spec.js +8 -6
- package/components/autosuggest/example-autosuggest-country-multiple.njk +7 -5
- package/components/autosuggest/example-autosuggest-country.njk +7 -5
- package/components/button/button.dom.js +1 -1
- package/components/card/_card.scss +6 -8
- package/components/card/_macro.njk +9 -27
- package/components/navigation/_macro.njk +32 -12
- package/components/navigation/_macro.spec.js +22 -18
- package/components/skip-to-content/_skip.scss +1 -1
- package/css/main.css +1 -1
- package/js/analytics.js +4 -7
- package/layout/_template.njk +7 -18
- package/package.json +3 -8
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/objects/_page.scss +7 -0
|
@@ -110,17 +110,19 @@
|
|
|
110
110
|
onsAutosuggest({
|
|
111
111
|
"id": params.id + "-autosuggest",
|
|
112
112
|
"classes": "ons-address-input__autosuggest ons-u-mb-no",
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
"
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
"input": {
|
|
114
|
+
"width": "50",
|
|
115
|
+
"label": {
|
|
116
|
+
"text": params.label.text,
|
|
117
|
+
"id": params.label.id,
|
|
118
|
+
"classes": "ons-js-autosuggest-label"
|
|
119
|
+
},
|
|
120
|
+
"value": params.value,
|
|
121
|
+
"attributes": params.attributes,
|
|
122
|
+
"error": params.error,
|
|
123
|
+
"name": params.name,
|
|
124
|
+
"mutuallyExclusive": params.mutuallyExclusive
|
|
118
125
|
},
|
|
119
|
-
"value": params.value,
|
|
120
|
-
"attributes": params.attributes,
|
|
121
|
-
"error": params.error,
|
|
122
|
-
"name": params.name,
|
|
123
|
-
"mutuallyExclusive": params.mutuallyExclusive,
|
|
124
126
|
"externalInitialiser": true,
|
|
125
127
|
"APIDomain": params.APIDomain,
|
|
126
128
|
"APIDomainBearerToken": params.APIDomainBearerToken,
|
|
@@ -352,17 +352,19 @@ describe('macro: address-input', () => {
|
|
|
352
352
|
expect(autosuggestSpy.occurrences[0]).toEqual({
|
|
353
353
|
id: 'address-input-example-id-autosuggest',
|
|
354
354
|
classes: 'ons-address-input__autosuggest ons-u-mb-no',
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
355
|
+
input: {
|
|
356
|
+
width: '50',
|
|
357
|
+
label: {
|
|
358
|
+
text: '[params.label.text]',
|
|
359
|
+
id: '[params.label.id]',
|
|
360
|
+
classes: 'ons-js-autosuggest-label',
|
|
361
|
+
},
|
|
362
|
+
value: '[params.value]',
|
|
363
|
+
attributes: '[params.attributes]',
|
|
364
|
+
error: '[params.error]',
|
|
365
|
+
name: '[params.name]',
|
|
366
|
+
mutuallyExclusive: '[params.mutuallyExclusive]',
|
|
360
367
|
},
|
|
361
|
-
value: '[params.value]',
|
|
362
|
-
attributes: '[params.attributes]',
|
|
363
|
-
error: '[params.error]',
|
|
364
|
-
name: '[params.name]',
|
|
365
|
-
mutuallyExclusive: '[params.mutuallyExclusive]',
|
|
366
368
|
externalInitialiser: true,
|
|
367
369
|
APIDomain: '[params.APIDomain]',
|
|
368
370
|
APIDomainBearerToken: '[params.APIDomainBearerToken]',
|
|
@@ -37,37 +37,50 @@
|
|
|
37
37
|
>
|
|
38
38
|
|
|
39
39
|
{% set autosuggestResults %}
|
|
40
|
-
<div class="ons-autosuggest__results ons-js-autosuggest-results{% if params.width %} ons-input--w-{{ params.width }}{% else %} ons-input--w-20{% endif %}">
|
|
40
|
+
<div class="ons-autosuggest__results ons-js-autosuggest-results{% if params.input.width %} ons-input--w-{{ params.input.width }}{% else %} ons-input--w-20{% endif %}">
|
|
41
41
|
<div id="{{ params.resultsTitleId }}" class="ons-autosuggest__results-title ons-u-fs-s">{{ params.resultsTitle }}</div>
|
|
42
42
|
<ul class="ons-autosuggest__listbox ons-js-autosuggest-listbox" title="{{ params.resultsTitle }}" role="listbox" id="{{ params.id }}-listbox" tabindex="-1"></ul>
|
|
43
43
|
</div>
|
|
44
44
|
<div class="ons-autosuggest__instructions ons-u-vh ons-js-autosuggest-instructions" id="{{ params.id }}-instructions" tabindex="-1">{{ params.instructions }}</div>
|
|
45
45
|
<div class="ons-autosuggest__status ons-u-vh ons-js-autosuggest-aria-status" aria-live="assertive" aria-atomic="true" role="status" tabindex="-1"></div>
|
|
46
46
|
{% endset %}
|
|
47
|
-
{{ onsInput({
|
|
48
|
-
"id": params.id,
|
|
49
|
-
"classes": "ons-js-autosuggest-input " + (params.classes if params.classes else ''),
|
|
50
|
-
"width": params.width,
|
|
51
|
-
"label": {
|
|
52
|
-
"text": params.label.text,
|
|
53
|
-
"description": params.label.description,
|
|
54
|
-
"id": params.label.id,
|
|
55
|
-
"classes": params.label.classes
|
|
56
|
-
},
|
|
57
|
-
"autocomplete": params.autocomplete,
|
|
58
|
-
"legend": params.legend,
|
|
59
|
-
"legendClasses": params.legendClasses,
|
|
60
|
-
"value": params.value,
|
|
61
|
-
"attributes": params.attributes,
|
|
62
|
-
"error": params.error,
|
|
63
|
-
"mutuallyExclusive": params.mutuallyExclusive,
|
|
64
|
-
"accessiblePlaceholder": params.accessiblePlaceholder,
|
|
65
|
-
"name": params.name,
|
|
66
|
-
"autosuggestResults": autosuggestResults
|
|
67
|
-
}) }}
|
|
68
47
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
48
|
+
{{ onsInput({
|
|
49
|
+
"id": params.id,
|
|
50
|
+
"type": params.input.type,
|
|
51
|
+
"classes": "ons-js-autosuggest-input " + (params.input.classes if params.input.classes else ''),
|
|
52
|
+
"width": params.input.width,
|
|
53
|
+
"label": params.input.label,
|
|
54
|
+
"autocomplete": params.input.autocomplete,
|
|
55
|
+
"legend": params.input.legend,
|
|
56
|
+
"legendClasses": params.input.legendClasses,
|
|
57
|
+
"legendIsQuestionTitle": params.input.legendIsQuestionTitle,
|
|
58
|
+
"value": params.input.value,
|
|
59
|
+
"attributes": params.input.attributes,
|
|
60
|
+
"error": params.input.error,
|
|
61
|
+
"mutuallyExclusive": params.input.mutuallyExclusive,
|
|
62
|
+
"accessiblePlaceholder": params.input.accessiblePlaceholder,
|
|
63
|
+
"name": params.input.name,
|
|
64
|
+
"autosuggestResults": autosuggestResults,
|
|
65
|
+
"min": params.input.min,
|
|
66
|
+
"max": params.input.max,
|
|
67
|
+
"minLength": params.input.minLength,
|
|
68
|
+
"maxLength": params.input.maxLength,
|
|
69
|
+
"prefix": params.input.prefix,
|
|
70
|
+
"suffix": params.input.suffix,
|
|
71
|
+
"fieldId": params.input.fieldId,
|
|
72
|
+
"fieldClasses": params.input.fieldClasses,
|
|
73
|
+
"dontWrap": params.input.dontWrap,
|
|
74
|
+
"charCheckLimit": params.input.charCheckLimit,
|
|
75
|
+
"searchButton": params.input.searchButton,
|
|
76
|
+
"postTextboxLinkText": params.input.postTextboxLinkText,
|
|
77
|
+
"postTextboxLinkUrl": params.input.postTextboxLinkUrl,
|
|
78
|
+
"listeners": params.input.listeners
|
|
79
|
+
}) }}
|
|
80
|
+
|
|
81
|
+
{% if not params.mutuallyExclusive %}
|
|
82
|
+
{{ autosuggestResults | safe }}
|
|
83
|
+
{% endif %}
|
|
84
|
+
|
|
72
85
|
</div>
|
|
73
86
|
{% endmacro %}
|
|
@@ -7,13 +7,15 @@ import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
|
7
7
|
|
|
8
8
|
const EXAMPLE_AUTOSUGGEST = {
|
|
9
9
|
id: 'country-of-birth',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
input: {
|
|
11
|
+
label: {
|
|
12
|
+
text: 'Current name of country',
|
|
13
|
+
description: 'Enter your own answer or select from suggestions',
|
|
14
|
+
id: 'country-of-birth-label',
|
|
15
|
+
classes: 'extra-label-class',
|
|
16
|
+
},
|
|
17
|
+
autocomplete: 'off',
|
|
15
18
|
},
|
|
16
|
-
autocomplete: 'off',
|
|
17
19
|
instructions: 'Use up and down keys to navigate.',
|
|
18
20
|
ariaYouHaveSelected: 'You have selected',
|
|
19
21
|
ariaMinChars: 'Enter 3 or more characters for suggestions.',
|
|
@@ -132,21 +134,67 @@ describe('macro: autosuggest', () => {
|
|
|
132
134
|
|
|
133
135
|
faker.renderComponent('autosuggest', {
|
|
134
136
|
...EXAMPLE_AUTOSUGGEST,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
input: {
|
|
138
|
+
type: 'text',
|
|
139
|
+
classes: 'extra-class another-extra-class',
|
|
140
|
+
width: '7',
|
|
141
|
+
label: {
|
|
142
|
+
text: 'Current name of country',
|
|
143
|
+
description: 'Enter your own answer or select from suggestions',
|
|
144
|
+
id: 'country-of-birth-label',
|
|
145
|
+
classes: 'extra-label-class',
|
|
146
|
+
},
|
|
147
|
+
autocomplete: 'off',
|
|
148
|
+
legend: 'this is a legend',
|
|
149
|
+
legendClasses: 'legend-extra-class',
|
|
150
|
+
value: 'abc',
|
|
151
|
+
attributes: {
|
|
152
|
+
a: 42,
|
|
153
|
+
},
|
|
154
|
+
error: {
|
|
155
|
+
id: 'error-id',
|
|
156
|
+
text: 'An error occurred.',
|
|
157
|
+
},
|
|
158
|
+
mutuallyExclusive: null,
|
|
159
|
+
accessiblePlaceholder: true,
|
|
160
|
+
name: 'country-of-birth-test',
|
|
161
|
+
min: 1,
|
|
162
|
+
max: 10,
|
|
163
|
+
minLength: 1,
|
|
164
|
+
maxLength: 10,
|
|
165
|
+
prefix: {
|
|
166
|
+
title: 'Great British Pounds',
|
|
167
|
+
text: '£',
|
|
168
|
+
id: 'gbp-prefix',
|
|
169
|
+
},
|
|
170
|
+
suffix: {
|
|
171
|
+
title: 'Percentage of total',
|
|
172
|
+
text: '%',
|
|
173
|
+
id: 'percentage-suffix',
|
|
174
|
+
},
|
|
175
|
+
fieldId: 'field-id-test',
|
|
176
|
+
fieldClasses: 'field-class-test',
|
|
177
|
+
dontWrap: true,
|
|
178
|
+
charCheckLimit: {
|
|
179
|
+
limit: 200,
|
|
180
|
+
charCountSingular: 'You have {x} character remaining',
|
|
181
|
+
charCountPlural: 'You have {x} characters remaining',
|
|
182
|
+
charCountOverLimitSingular: '{x} character too many',
|
|
183
|
+
charCountOverLimitPlural: '{x} characters too many',
|
|
184
|
+
},
|
|
185
|
+
searchButton: {
|
|
186
|
+
text: 'Search',
|
|
187
|
+
},
|
|
188
|
+
postTextboxLinkText: 'Post textbox link text',
|
|
189
|
+
postTextboxLinkUrl: 'https://www.ons.gov.uk',
|
|
190
|
+
listeners: {
|
|
191
|
+
click: "function() { console.log('click'); }",
|
|
192
|
+
},
|
|
140
193
|
},
|
|
141
|
-
error: {
|
|
142
|
-
id: 'error-id',
|
|
143
|
-
text: 'An error occurred.',
|
|
144
|
-
},
|
|
145
|
-
mutuallyExclusive: null,
|
|
146
|
-
accessiblePlaceholder: true,
|
|
147
194
|
});
|
|
148
195
|
|
|
149
196
|
expect(inputSpy.occurrences[0]).toHaveProperty('id', 'country-of-birth');
|
|
197
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('type', 'text');
|
|
150
198
|
expect(inputSpy.occurrences[0]).toHaveProperty('classes', 'ons-js-autosuggest-input extra-class another-extra-class');
|
|
151
199
|
expect(inputSpy.occurrences[0]).toHaveProperty('width', '7');
|
|
152
200
|
expect(inputSpy.occurrences[0]).toHaveProperty('label.text', 'Current name of country');
|
|
@@ -154,13 +202,38 @@ describe('macro: autosuggest', () => {
|
|
|
154
202
|
expect(inputSpy.occurrences[0]).toHaveProperty('label.id', 'country-of-birth-label');
|
|
155
203
|
expect(inputSpy.occurrences[0]).toHaveProperty('label.classes', 'extra-label-class');
|
|
156
204
|
expect(inputSpy.occurrences[0]).toHaveProperty('autocomplete', 'off');
|
|
205
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('legend', 'this is a legend');
|
|
206
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('legendClasses', 'legend-extra-class');
|
|
157
207
|
expect(inputSpy.occurrences[0]).toHaveProperty('value', 'abc');
|
|
158
208
|
expect(inputSpy.occurrences[0]).toHaveProperty('attributes.a', 42);
|
|
159
209
|
expect(inputSpy.occurrences[0]).toHaveProperty('error.id', 'error-id');
|
|
160
210
|
expect(inputSpy.occurrences[0]).toHaveProperty('error.text', 'An error occurred.');
|
|
161
211
|
expect(inputSpy.occurrences[0]).toHaveProperty('mutuallyExclusive', null);
|
|
162
212
|
expect(inputSpy.occurrences[0]).toHaveProperty('accessiblePlaceholder', true);
|
|
213
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('name', 'country-of-birth-test');
|
|
163
214
|
expect(typeof inputSpy.occurrences[0].autosuggestResults).toBe('string');
|
|
215
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('min', 1);
|
|
216
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('max', 10);
|
|
217
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('minLength', 1);
|
|
218
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('maxLength', 10);
|
|
219
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('prefix.title', 'Great British Pounds');
|
|
220
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('prefix.text', '£');
|
|
221
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('prefix.id', 'gbp-prefix');
|
|
222
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('suffix.title', 'Percentage of total');
|
|
223
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('suffix.text', '%');
|
|
224
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('suffix.id', 'percentage-suffix');
|
|
225
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('fieldId', 'field-id-test');
|
|
226
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('fieldClasses', 'field-class-test');
|
|
227
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('dontWrap', true);
|
|
228
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.limit', 200);
|
|
229
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.charCountSingular', 'You have {x} character remaining');
|
|
230
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.charCountPlural', 'You have {x} characters remaining');
|
|
231
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.charCountOverLimitSingular', '{x} character too many');
|
|
232
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.charCountOverLimitPlural', '{x} characters too many');
|
|
233
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('searchButton.text', 'Search');
|
|
234
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('postTextboxLinkText', 'Post textbox link text');
|
|
235
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('postTextboxLinkUrl', 'https://www.ons.gov.uk');
|
|
236
|
+
expect(inputSpy.occurrences[0]).toHaveProperty('listeners.click', "function() { console.log('click'); }");
|
|
164
237
|
});
|
|
165
238
|
});
|
|
166
239
|
|
|
@@ -3,13 +3,15 @@ import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
|
3
3
|
|
|
4
4
|
const EXAMPLE_AUTOSUGGEST = {
|
|
5
5
|
id: 'country-of-birth',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
input: {
|
|
7
|
+
label: {
|
|
8
|
+
text: 'Current name of country',
|
|
9
|
+
description: 'Enter your own answer or select from suggestions',
|
|
10
|
+
id: 'country-of-birth-label',
|
|
11
|
+
classes: 'extra-label-class',
|
|
12
|
+
},
|
|
13
|
+
autocomplete: 'off',
|
|
11
14
|
},
|
|
12
|
-
autocomplete: 'off',
|
|
13
15
|
instructions: 'Use up and down keys to navigate.',
|
|
14
16
|
ariaYouHaveSelected: 'You have selected',
|
|
15
17
|
ariaMinChars: 'Enter 3 or more characters for suggestions.',
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
{{ onsAutosuggest({
|
|
7
7
|
"id": "country-of-birth-autosuggest-multiple",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
"input": {
|
|
9
|
+
"label": {
|
|
10
|
+
"text": "Passport",
|
|
11
|
+
"id": "country-of-birth-label-multiple",
|
|
12
|
+
"description": "Enter your own answer or select from suggestions. You can enter multiple countries if you have a passport for more than one."
|
|
13
|
+
},
|
|
14
|
+
"autocomplete": "off"
|
|
12
15
|
},
|
|
13
|
-
"autocomplete": "off",
|
|
14
16
|
"instructions": "Use up and down keys to navigate suggestions once you\'ve typed more than two characters. Use the enter key to select a suggestion. Touch device users, explore by touch or with swipe gestures.",
|
|
15
17
|
"ariaYouHaveSelected": "You have selected",
|
|
16
18
|
"ariaMinChars": "Enter 3 or more characters for suggestions.",
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
{{ onsAutosuggest({
|
|
7
7
|
"id": "country-of-birth-autosuggest",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
"input": {
|
|
9
|
+
"label": {
|
|
10
|
+
"text": "Current name of country",
|
|
11
|
+
"description": "Enter your own answer or select from suggestions",
|
|
12
|
+
"id": "country-of-birth-label"
|
|
13
|
+
},
|
|
14
|
+
"autocomplete": "off"
|
|
12
15
|
},
|
|
13
|
-
"autocomplete": "off",
|
|
14
16
|
"instructions": "Use up and down keys to navigate suggestions once you\'ve typed more than two characters. Use the enter key to select a suggestion. Touch device users, explore by touch or with swipe gestures.",
|
|
15
17
|
"ariaYouHaveSelected": "You have selected",
|
|
16
18
|
"ariaMinChars": "Enter 3 or more characters for suggestions.",
|
|
@@ -6,7 +6,7 @@ async function submitButton() {
|
|
|
6
6
|
|
|
7
7
|
if (buttons.length) {
|
|
8
8
|
const SubmitButton = (await import('./button')).default;
|
|
9
|
-
buttons.forEach(button => {
|
|
9
|
+
buttons.forEach((button) => {
|
|
10
10
|
if (button.classList.contains('ons-js-timer')) {
|
|
11
11
|
submitType = 'timer';
|
|
12
12
|
} else if (button.classList.contains('ons-js-loader')) {
|
|
@@ -5,15 +5,13 @@
|
|
|
5
5
|
&__link {
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
&__image--reorder {
|
|
11
|
-
order: 1;
|
|
12
|
-
}
|
|
8
|
+
margin-bottom: 1rem;
|
|
9
|
+
width: fit-content;
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
& > .ons-card__title {
|
|
12
|
+
margin-bottom: 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
17
15
|
|
|
18
16
|
&__link:hover {
|
|
19
17
|
text-decoration-thickness: 3px;
|
|
@@ -5,36 +5,18 @@
|
|
|
5
5
|
{% set titleSize = params.titleSize | default('2') %}
|
|
6
6
|
|
|
7
7
|
<div class="ons-card">
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
</h{{ titleSize }}>
|
|
16
|
-
{% if params.image.smallSrc %}
|
|
17
|
-
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
|
|
18
|
-
{% elif params.image == true or params.image.placeholderURL %}
|
|
19
|
-
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
|
|
20
|
-
{% endif %}
|
|
21
|
-
{%- if params.url -%}
|
|
22
|
-
</a>
|
|
8
|
+
<a href="{{ params.url }}" class="ons-card__link">
|
|
9
|
+
{%- if params.image -%}
|
|
10
|
+
{% if params.image.smallSrc %}
|
|
11
|
+
<img class="ons-card__image ons-u-mb-s" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
|
|
12
|
+
{% elif params.image == true or params.image.placeholderURL %}
|
|
13
|
+
<img class="ons-card__image ons-u-mb-s " height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
|
|
14
|
+
{% endif %}
|
|
23
15
|
{%- endif -%}
|
|
24
|
-
|
|
25
|
-
{%- else -%}
|
|
26
|
-
|
|
27
|
-
<h{{ titleSize }} class="ons-card__title {{ params.titleClasses | default('ons-u-fs-m') }}" id="{{ params.id }}">
|
|
28
|
-
{%- if params.url -%}
|
|
29
|
-
<a class="ons-card__link" href="{{ params.url }}">
|
|
30
|
-
{%- endif -%}
|
|
16
|
+
<h{{ titleSize }} class="ons-card__title {{ params.titleClasses | default('ons-u-fs-m')}}" id="{{ params.id }}">
|
|
31
17
|
{{ params.title }}
|
|
32
|
-
{%- if params.url -%}
|
|
33
|
-
</a>
|
|
34
|
-
{%- endif -%}
|
|
35
18
|
</h{{ titleSize }}>
|
|
36
|
-
|
|
37
|
-
{%- endif -%}
|
|
19
|
+
</a>
|
|
38
20
|
|
|
39
21
|
<p id="{{ params.textId }}">{{ params.text }}</p>
|
|
40
22
|
|
|
@@ -15,14 +15,16 @@
|
|
|
15
15
|
{{ onsAutosuggest({
|
|
16
16
|
"id": "ons-site-search",
|
|
17
17
|
"containerClasses": "ons-autosuggest--header",
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
18
|
+
"input": {
|
|
19
|
+
"classes": autosuggestClasses,
|
|
20
|
+
"accessiblePlaceholder": true,
|
|
21
|
+
"autocomplete": "off",
|
|
22
|
+
"label": {
|
|
23
|
+
"text": params.siteSearchAutosuggest.label,
|
|
24
|
+
"id": "ons-site-search-label",
|
|
25
|
+
"classes": autosuggestLabelClasses
|
|
26
|
+
}
|
|
23
27
|
},
|
|
24
|
-
"accessiblePlaceholder": true,
|
|
25
|
-
"autocomplete": "off",
|
|
26
28
|
"instructions": params.siteSearchAutosuggest.instructions,
|
|
27
29
|
"ariaYouHaveSelected":params.siteSearchAutosuggest.ariaYouHaveSelected,
|
|
28
30
|
"ariaMinChars": params.siteSearchAutosuggest.ariaMinChars,
|
|
@@ -42,7 +44,11 @@
|
|
|
42
44
|
<ul class="ons-navigation__list">
|
|
43
45
|
{% for item in params.navigation.itemsList %}
|
|
44
46
|
<li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
|
|
45
|
-
|
|
47
|
+
<a class="ons-navigation__link" href="{{ item.url }}" {% if item.id %}id="{{ item.id }}" {% endif %}{% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %}>
|
|
48
|
+
{% if item.title %}{{ item.title }}
|
|
49
|
+
{% elif item.text %}{{ item.text }}
|
|
50
|
+
{% endif %}
|
|
51
|
+
</a>
|
|
46
52
|
</li>
|
|
47
53
|
{% endfor %}
|
|
48
54
|
</ul>
|
|
@@ -55,7 +61,11 @@
|
|
|
55
61
|
<ul class="ons-navigation__list ons-navigation__list">
|
|
56
62
|
{% for item in params.navigation.subNavigation.itemsList %}
|
|
57
63
|
<li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
|
|
58
|
-
<a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}" {% endif %}>
|
|
64
|
+
<a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}" {% endif %}>
|
|
65
|
+
{% if item.title %}{{ item.title }}
|
|
66
|
+
{% elif item.text %}{{ item.text }}
|
|
67
|
+
{% endif %}
|
|
68
|
+
</a>
|
|
59
69
|
</li>
|
|
60
70
|
{% endfor %}
|
|
61
71
|
</ul>
|
|
@@ -81,14 +91,24 @@
|
|
|
81
91
|
</li>
|
|
82
92
|
{% for item in params.navigation.subNavigation.itemsList %}
|
|
83
93
|
<li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
|
|
84
|
-
<a class="ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}--mobile" {% endif %}>
|
|
94
|
+
<a class="ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}--mobile" {% endif %}>
|
|
95
|
+
{% if item.title %}{{ item.title }}
|
|
96
|
+
{% elif item.text %}{{ item.text }}
|
|
97
|
+
{% endif %}
|
|
98
|
+
</a>
|
|
85
99
|
{% if item.sections %}
|
|
86
100
|
{% for section in item.sections %}
|
|
87
|
-
{% if section.sectionTitle %}
|
|
101
|
+
{% if section.sectionTitle %}
|
|
102
|
+
<h3 class="ons-navigation__list-header">{{ section.sectionTitle }}</h3>
|
|
103
|
+
{% endif %}
|
|
88
104
|
<ul class="ons-navigation__list ons-navigation__list--child ons-list--dashed ons-u-ml-s ons-u-mt-xs">
|
|
89
105
|
{% for child in section.children %}
|
|
90
106
|
<li class="ons-navigation__item ons-list__item {{ ' ons-navigation__item--active' if (child.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and child.url in params.navigation.currentPath) }}">
|
|
91
|
-
<a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.ariaLabel %}aria-label="{{ child.ariaLabel }}" {% endif %} {% if child.id %}id="{{ child.id }}" {% endif %}>
|
|
107
|
+
<a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.ariaLabel %}aria-label="{{ child.ariaLabel }}" {% endif %} {% if child.id %}id="{{ child.id }}" {% endif %}>
|
|
108
|
+
{% if child.title %}{{ child.title }}
|
|
109
|
+
{% elif child.text %}{{ child.text }}
|
|
110
|
+
{% endif %}
|
|
111
|
+
</a>
|
|
92
112
|
</li>
|
|
93
113
|
{% endfor %}
|
|
94
114
|
</ul>
|
|
@@ -71,7 +71,6 @@ const PARAMS = {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
const SITE_SEARCH_AUTOSUGGEST = {
|
|
74
|
-
label: 'Search the design system',
|
|
75
74
|
instructions:
|
|
76
75
|
"Use up and down keys to navigate results once you've typed more than two characters. Use the enter key to select a result. Touch device users, explore by touch or with swipe gestures.",
|
|
77
76
|
ariaYouHaveSelected: 'You have selected',
|
|
@@ -122,20 +121,25 @@ describe('macro: navigation', () => {
|
|
|
122
121
|
navigation: PARAMS,
|
|
123
122
|
siteSearchAutosuggest: {
|
|
124
123
|
...SITE_SEARCH_AUTOSUGGEST,
|
|
124
|
+
input: {
|
|
125
|
+
label: 'Search the design system',
|
|
126
|
+
},
|
|
125
127
|
},
|
|
126
128
|
});
|
|
127
129
|
|
|
128
130
|
expect(autosuggestSpy.occurrences[0]).toEqual({
|
|
129
131
|
...SITE_SEARCH_AUTOSUGGEST,
|
|
130
|
-
accessiblePlaceholder: true,
|
|
131
|
-
autocomplete: 'off',
|
|
132
132
|
id: 'ons-site-search',
|
|
133
133
|
containerClasses: 'ons-autosuggest--header',
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
classes: 'ons-
|
|
134
|
+
input: {
|
|
135
|
+
accessiblePlaceholder: true,
|
|
136
|
+
autocomplete: 'off',
|
|
137
|
+
label: 'Search the design system',
|
|
138
|
+
classes: 'ons-input-search ons-input-search--icon',
|
|
139
|
+
label: {
|
|
140
|
+
id: 'ons-site-search-label',
|
|
141
|
+
classes: 'ons-u-pl-m ons-label--white',
|
|
142
|
+
},
|
|
139
143
|
},
|
|
140
144
|
});
|
|
141
145
|
});
|
|
@@ -157,21 +161,21 @@ describe('macro: navigation', () => {
|
|
|
157
161
|
it('has the correct link href for each list item', () => {
|
|
158
162
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
159
163
|
|
|
160
|
-
const values = mapAll($('.ons-navigation--main .ons-navigation__link'), node => node.attr('href'));
|
|
164
|
+
const values = mapAll($('.ons-navigation--main .ons-navigation__link'), (node) => node.attr('href'));
|
|
161
165
|
expect(values).toEqual(['#0', '#1']);
|
|
162
166
|
});
|
|
163
167
|
|
|
164
168
|
it('has the correct link text for each list item', () => {
|
|
165
169
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
166
170
|
|
|
167
|
-
const values = mapAll($('.ons-navigation--main .ons-navigation__link'), node => node.text().trim());
|
|
171
|
+
const values = mapAll($('.ons-navigation--main .ons-navigation__link'), (node) => node.text().trim());
|
|
168
172
|
expect(values).toEqual(['Main nav item 1', 'Main nav item 2']);
|
|
169
173
|
});
|
|
170
174
|
|
|
171
175
|
it('has the correct aria-label for each list item', () => {
|
|
172
176
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
173
177
|
|
|
174
|
-
const values = mapAll($('.ons-navigation--main .ons-navigation__link'), node => node.attr('aria-label'));
|
|
178
|
+
const values = mapAll($('.ons-navigation--main .ons-navigation__link'), (node) => node.attr('aria-label'));
|
|
175
179
|
expect(values).toEqual(['Main nav ariaLabel 1', 'Main nav ariaLabel 2']);
|
|
176
180
|
});
|
|
177
181
|
|
|
@@ -249,21 +253,21 @@ describe('macro: navigation', () => {
|
|
|
249
253
|
it('has the correct link href for each list item', () => {
|
|
250
254
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
251
255
|
|
|
252
|
-
const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), node => node.attr('href'));
|
|
256
|
+
const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), (node) => node.attr('href'));
|
|
253
257
|
expect(values).toEqual(['/sub-item-1', '/sub-item-2']);
|
|
254
258
|
});
|
|
255
259
|
|
|
256
260
|
it('has the correct link text for each list item', () => {
|
|
257
261
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
258
262
|
|
|
259
|
-
const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), node => node.text().trim());
|
|
263
|
+
const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), (node) => node.text().trim());
|
|
260
264
|
expect(values).toEqual(['Sub nav item 1', 'Sub nav item 2']);
|
|
261
265
|
});
|
|
262
266
|
|
|
263
267
|
it('has the correct aria-label for each list item', () => {
|
|
264
268
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
265
269
|
|
|
266
|
-
const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), node => node.attr('aria-label'));
|
|
270
|
+
const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), (node) => node.attr('aria-label'));
|
|
267
271
|
expect(values).toEqual(['Sub nav ariaLabel 1', 'Sub nav ariaLabel 2']);
|
|
268
272
|
});
|
|
269
273
|
|
|
@@ -322,7 +326,7 @@ describe('macro: navigation', () => {
|
|
|
322
326
|
|
|
323
327
|
const values = mapAll(
|
|
324
328
|
$('.ons-navigation__list--parent > li a').not('.ons-navigation__list--parent li .ons-navigation__list--child a'),
|
|
325
|
-
node => node.attr('href'),
|
|
329
|
+
(node) => node.attr('href'),
|
|
326
330
|
);
|
|
327
331
|
expect(values).toEqual(['#overview', '/sub-item-1', '/sub-item-2']);
|
|
328
332
|
});
|
|
@@ -332,7 +336,7 @@ describe('macro: navigation', () => {
|
|
|
332
336
|
|
|
333
337
|
const values = mapAll(
|
|
334
338
|
$('.ons-navigation__list--parent > li a').not('.ons-navigation__list--parent li .ons-navigation__list--child a'),
|
|
335
|
-
node => node.text().trim(),
|
|
339
|
+
(node) => node.text().trim(),
|
|
336
340
|
);
|
|
337
341
|
expect(values).toEqual(['Overview', 'Sub nav item 1', 'Sub nav item 2']);
|
|
338
342
|
});
|
|
@@ -364,14 +368,14 @@ describe('macro: navigation', () => {
|
|
|
364
368
|
it('has the correct link href for each child list item', () => {
|
|
365
369
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
366
370
|
|
|
367
|
-
const values = mapAll($('.ons-navigation__list--child > li a'), node => node.attr('href'));
|
|
371
|
+
const values = mapAll($('.ons-navigation__list--child > li a'), (node) => node.attr('href'));
|
|
368
372
|
expect(values).toEqual(['/sub-item-2/child-item-1', '/sub-item-2/child-item-2']);
|
|
369
373
|
});
|
|
370
374
|
|
|
371
375
|
it('has the correct link text for each child list item', () => {
|
|
372
376
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
373
377
|
|
|
374
|
-
const values = mapAll($('.ons-navigation__list--child > li a'), node => node.text().trim());
|
|
378
|
+
const values = mapAll($('.ons-navigation__list--child > li a'), (node) => node.text().trim());
|
|
375
379
|
expect(values).toEqual(['Child item 1', 'Child item 2']);
|
|
376
380
|
});
|
|
377
381
|
|