@ons/design-system 74.0.0-next.1 → 74.0.0-next.11
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 +15 -3
- package/components/access-code/example-access-code-error.njk +2 -2
- package/components/access-code/example-access-code.njk +2 -2
- package/components/address-input/_macro.njk +6 -6
- package/components/address-input/_macro.spec.js +0 -3
- package/components/address-input/autosuggest.address.spec.js +23 -0
- package/components/address-output/_macro.njk +1 -1
- package/components/announcement-banner/_announcement-banner.scss +5 -0
- package/components/autosuggest/_autosuggest.scss +8 -0
- package/components/autosuggest/autosuggest.ui.js +11 -5
- package/components/back-to-top/_back-to-top.scss +7 -0
- package/components/back-to-top/_macro.njk +1 -1
- package/components/back-to-top/example-full-page-back-to-top.njk +1 -1
- package/components/breadcrumbs/_breadcrumbs.scss +4 -7
- package/components/breadcrumbs/_macro.njk +29 -25
- package/components/breadcrumbs/_macro.spec.js +39 -0
- package/components/breadcrumbs/example-breadcrumbs-wide.njk +52 -0
- package/components/char-check-limit/_macro.njk +16 -14
- package/components/chart/_chart.scss +0 -9
- package/components/chart/_macro.njk +96 -128
- package/components/chart/_macro.spec.js +43 -28
- package/components/chart/example-area-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-area-chart.njk +6 -3
- package/components/chart/example-bar-chart-with-annotations.njk +6 -3
- package/components/chart/example-bar-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-bar-chart-with-point-range-and-reference-line-annotations.njk +6 -3
- package/components/chart/example-bar-chart.njk +6 -3
- package/components/chart/example-bar-with-confidence-levels.njk +6 -3
- package/components/chart/example-clustered-bar-chart.njk +6 -3
- package/components/chart/example-clustered-column-chart.njk +6 -3
- package/components/chart/example-column-chart-with-annotations.njk +6 -3
- package/components/chart/example-column-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-column-chart-with-custom-reference-line-value.njk +6 -3
- package/components/chart/example-column-chart-with-range-annotations.njk +6 -3
- package/components/chart/example-column-chart-with-reference-line-annotations.njk +6 -3
- package/components/chart/example-column-chart.njk +6 -3
- package/components/chart/example-column-with-confidence-levels.njk +6 -3
- package/components/chart/example-column-with-line-chart.njk +6 -3
- package/components/chart/example-iframe-chart.njk +6 -3
- package/components/chart/example-line-chart-with-annotations.njk +6 -3
- package/components/chart/example-line-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-line-chart-with-custom-reference-line-value.njk +6 -3
- package/components/chart/example-line-chart-with-label-format.njk +6 -3
- package/components/chart/example-line-chart-with-markers.njk +6 -3
- package/components/chart/example-line-chart-with-range-annotations-inside.njk +6 -3
- package/components/chart/example-line-chart-with-range-annotations-outside-left-right.njk +6 -3
- package/components/chart/example-line-chart-with-range-annotations-outside-top-bottom.njk +6 -3
- package/components/chart/example-line-chart-with-reference-line-annotations.njk +6 -3
- package/components/chart/example-line-chart.njk +6 -3
- package/components/chart/example-scatter-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-scatter-chart.njk +6 -3
- package/components/chart/example-stacked-bar-chart.njk +6 -3
- package/components/chart/example-stacked-column-chart.njk +6 -3
- package/components/details/_details.scss +9 -0
- package/components/details/example-details-with-warning.njk +1 -1
- package/components/document-list/_macro.njk +2 -2
- package/components/document-list/_macro.spec.js +55 -0
- package/components/featured-article/_macro.njk +6 -40
- package/components/featured-article/example-featured-article-with-chart.njk +19 -14
- package/components/featured-article/example-featured-article-with-image.njk +12 -7
- package/components/featured-article/featured-article.scss +1 -1
- package/components/featured-article/macro.spec.js +46 -69
- package/components/feedback/_macro.njk +4 -1
- package/components/feedback/_macro.spec.js +1 -1
- package/components/figure/_figure.scss +32 -0
- package/components/figure/_macro.njk +98 -0
- package/components/figure/_macro.spec.js +520 -0
- package/components/figure/example-figure-heading-level-2.njk +34 -0
- package/components/figure/example-figure-with-div.njk +29 -0
- package/components/figure/example-figure-without-footer.njk +12 -0
- package/components/figure/example-figure-without-header.njk +24 -0
- package/components/figure/example-figure.njk +34 -0
- package/components/footer/_macro.njk +5 -2
- package/components/header/_header.scss +1 -3
- package/components/header/_macro.njk +8 -4
- package/components/header/_macro.spec.js +48 -0
- package/components/hero/_hero.scss +4 -0
- package/components/hero/_macro.njk +3 -2
- package/components/hero/_macro.spec.js +36 -0
- package/components/hero/example-hero-dark-wide.njk +17 -0
- package/components/hero/example-hero-dark-with-external-breadcrumbs.njk +17 -21
- package/components/hero/example-hero-default-full-width.njk +16 -0
- package/components/hero/example-hero-default-with-external-breadcrumbs.njk +165 -169
- package/components/hero/example-hero-grey-with-external-breadcrumbs.njk +207 -211
- package/components/hero/example-hero-navy-blue-with-external-breadcrumbs.njk +163 -167
- package/components/hero/example-hero-pale-blue-with-external-breadcrumbs.njk +165 -169
- package/components/image/_image.scss +0 -7
- package/components/image/_macro.njk +25 -14
- package/components/image/_macro.spec.js +122 -7
- package/components/image/example-image-with-figure-fields.njk +25 -0
- package/components/input/_input.scss +4 -0
- package/components/input/_macro.njk +4 -1
- package/components/label/_label.scss +3 -0
- package/components/list/_list.scss +5 -0
- package/components/list/_macro.njk +1 -0
- package/components/list/_macro.spec.js +16 -0
- package/components/message-list/_message-list.scss +2 -0
- package/components/panel/_macro.njk +1 -1
- package/components/panel/_panel.scss +8 -0
- package/components/panel/example-panel-bare.njk +1 -1
- package/components/phase-banner/_phase-banner.scss +1 -0
- package/components/question/example-question-ccs.njk +1 -1
- package/components/question/example-question-fieldset.njk +1 -1
- package/components/question/example-question-interviewer-note.njk +1 -1
- package/components/question/example-question-no-fieldset.njk +1 -1
- package/components/quote/_macro.njk +1 -1
- package/components/relationships/example-relationships-error.njk +1 -1
- package/components/relationships/example-relationships-you.njk +1 -1
- package/components/relationships/example-relationships.njk +1 -1
- package/components/skip-to-content/_macro.njk +1 -1
- package/components/skip-to-content/_skip.scss +8 -0
- package/components/table/_macro.njk +138 -111
- package/components/table/_macro.spec.js +175 -16
- package/components/table/_table.scss +6 -1
- package/components/table/example-table-basic-no-caption.njk +46 -0
- package/components/table/example-table-basic-visually-hidden-caption.njk +47 -0
- package/components/table/example-table-with-figure-fields.njk +86 -0
- package/components/table/table.spec.js +2 -0
- package/components/table-of-contents/_macro.njk +6 -4
- package/components/table-of-contents/_macro.spec.js +43 -3
- package/components/table-of-contents/example-table-of-contents-ordered.njk +64 -0
- package/components/table-of-contents/example-table-of-contents-sticky-full-page-ordered.njk +156 -0
- package/components/table-of-contents/example-table-of-contents-sticky-full-page.njk +1 -1
- package/components/table-of-contents/table-of-contents.spec.js +4 -5
- package/css/main.css +1 -1
- package/layout/_template.njk +66 -46
- package/package.json +45 -36
- package/scripts/main.es5.js +3 -3
- package/scripts/main.js +2 -2
- package/scss/base/_global.scss +8 -0
- package/scss/base/_typography.scss +9 -0
- package/scss/helpers/_mixins.scss +8 -0
- package/scss/main.scss +1 -0
- package/scss/objects/_page.scss +1 -1
- package/scss/objects/_spacing.scss +0 -4
- package/scss/utilities/_utilities.scss +10 -0
- package/scss/vars/_forms.scss +2 -1
- package/scss/vars/_index.scss +1 -0
- package/scss/vars/_utilities.scss +2 -0
package/README.md
CHANGED
|
@@ -143,11 +143,23 @@ Checkout the branch locally and run:
|
|
|
143
143
|
|
|
144
144
|
`yarn test-visual` - This will run the same tests locally as were run in Github Actions. After they have completed the report will open in your default browser.
|
|
145
145
|
|
|
146
|
+
`VR_SHARD_INDEX=0 VR_SHARD_COUNT=4 yarn test-visual` - This runs only one shard of the visual tests locally. Useful when one shard fails in CI.
|
|
147
|
+
|
|
148
|
+
### Handling VR test failures
|
|
149
|
+
|
|
150
|
+
If the VR tests fail locally, you'll see an error starting with `Error: docker run --rm -i --add-host=host.docker.internal:host-gateway...`
|
|
151
|
+
|
|
152
|
+
`npx http-server backstop_data -p 8008 -o /html_report/` - View the report in your browser.
|
|
153
|
+
|
|
154
|
+
### Approving VR test reference image changes
|
|
155
|
+
|
|
146
156
|
`yarn test-visual:approve` - This will approve the failures/diff caught by the tests.
|
|
147
157
|
|
|
148
|
-
|
|
158
|
+
Commit and approve the file changes in the normal way.
|
|
159
|
+
|
|
160
|
+
`git lfs push --all origin` - This will push the new reference images to Git LFS.
|
|
149
161
|
|
|
150
|
-
You can then
|
|
162
|
+
You can then push the updated references and your changes to your branch. The test images that would have been created when you ran `yarn test-visual` are gitignored and the new references images will be pushed to Git LFS.
|
|
151
163
|
|
|
152
164
|
If your local tests are failing but you have approved them, run `yarn test-visual:reference`. This will update the reference images locally on your machine.
|
|
153
165
|
|
|
@@ -176,7 +188,7 @@ yarn add @ons/design-system@next
|
|
|
176
188
|
|
|
177
189
|
### Publishing the stable major
|
|
178
190
|
|
|
179
|
-
1. Merge `next` into `main`.
|
|
191
|
+
1. Merge `next` into `main`. **Do not squash; use a regular merge commit to preserve history.**
|
|
180
192
|
2. Create a normal release tag, for example: `74.0.0`.
|
|
181
193
|
3. Publish the GitHub Release (not marked as a pre-release).
|
|
182
194
|
|
|
@@ -14,7 +14,7 @@ layout: ~
|
|
|
14
14
|
}
|
|
15
15
|
%}
|
|
16
16
|
|
|
17
|
-
{% block
|
|
17
|
+
{% block mainContent %}
|
|
18
18
|
{%
|
|
19
19
|
call onsPanel({
|
|
20
20
|
"title": "There is a problem with this page",
|
|
@@ -76,7 +76,7 @@ layout: ~
|
|
|
76
76
|
"variant": "warn"
|
|
77
77
|
})
|
|
78
78
|
%}
|
|
79
|
-
Someone in your household must still complete a study using this household access code
|
|
79
|
+
<p>Someone in your household must still complete a study using this household access code</p>
|
|
80
80
|
{% endcall %}
|
|
81
81
|
{% endset %}
|
|
82
82
|
|
|
@@ -16,7 +16,7 @@ layout: ~
|
|
|
16
16
|
}
|
|
17
17
|
%}
|
|
18
18
|
|
|
19
|
-
{% block
|
|
19
|
+
{% block mainContent %}
|
|
20
20
|
<h1 class="ons-u-mt-2xl">Start study</h1>
|
|
21
21
|
|
|
22
22
|
{{
|
|
@@ -53,7 +53,7 @@ layout: ~
|
|
|
53
53
|
"variant": "warn"
|
|
54
54
|
})
|
|
55
55
|
%}
|
|
56
|
-
Someone in your household must still complete a study using this household access code
|
|
56
|
+
<p>Someone in your household must still complete a study using this household access code</p>
|
|
57
57
|
{% endcall %}
|
|
58
58
|
{% endset %}
|
|
59
59
|
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"text": params.organisation.label
|
|
20
20
|
},
|
|
21
21
|
"classes": "ons-js-address-organisation",
|
|
22
|
-
"width": "20@m",
|
|
23
22
|
"name": params.id + "-organisation",
|
|
24
23
|
"error": params.organisation.error
|
|
25
24
|
})
|
|
@@ -34,7 +33,6 @@
|
|
|
34
33
|
"text": params.line1.label
|
|
35
34
|
},
|
|
36
35
|
"classes": "ons-js-address-line1",
|
|
37
|
-
"width": "20@m",
|
|
38
36
|
"name": params.id + "-line1",
|
|
39
37
|
"error": params.line1.error
|
|
40
38
|
})
|
|
@@ -49,7 +47,6 @@
|
|
|
49
47
|
"text": params.line2.label
|
|
50
48
|
},
|
|
51
49
|
"classes": "ons-js-address-line2",
|
|
52
|
-
"width": "20@m",
|
|
53
50
|
"name": params.id + "-line2",
|
|
54
51
|
"error": params.line2.error
|
|
55
52
|
})
|
|
@@ -165,9 +162,12 @@
|
|
|
165
162
|
})
|
|
166
163
|
}}
|
|
167
164
|
{% if params.manualLinkText %}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
{# p tag ensures reading width is applied #}
|
|
166
|
+
<p class="ons-u-mb-no">
|
|
167
|
+
<a href="{{ params.manualLinkUrl }}" class="ons-js-address-manual-btn ons-u-mt-s ons-u-dib"
|
|
168
|
+
>{{ params.manualLinkText }}</a
|
|
169
|
+
>
|
|
170
|
+
</p>
|
|
171
171
|
{% endif %}
|
|
172
172
|
</div>
|
|
173
173
|
{% endif %}
|
|
@@ -176,7 +176,6 @@ describe('FOR: Macro: Address-input', () => {
|
|
|
176
176
|
text: 'Organisation name',
|
|
177
177
|
},
|
|
178
178
|
value: 'Example Organisation',
|
|
179
|
-
width: '20@m',
|
|
180
179
|
error: { text: 'Server error: organisation name' },
|
|
181
180
|
});
|
|
182
181
|
});
|
|
@@ -191,7 +190,6 @@ describe('FOR: Macro: Address-input', () => {
|
|
|
191
190
|
text: 'Address line 1',
|
|
192
191
|
},
|
|
193
192
|
value: 'Flat 12345',
|
|
194
|
-
width: '20@m',
|
|
195
193
|
error: { text: 'Server error: address line 1' },
|
|
196
194
|
});
|
|
197
195
|
});
|
|
@@ -207,7 +205,6 @@ describe('FOR: Macro: Address-input', () => {
|
|
|
207
205
|
text: 'Address line 2',
|
|
208
206
|
},
|
|
209
207
|
value: '12345 The Road',
|
|
210
|
-
width: '20@m',
|
|
211
208
|
error: { text: 'Server error: address line 2' },
|
|
212
209
|
});
|
|
213
210
|
});
|
|
@@ -411,6 +411,29 @@ describe('script: address-input', () => {
|
|
|
411
411
|
});
|
|
412
412
|
});
|
|
413
413
|
});
|
|
414
|
+
|
|
415
|
+
describe('when a grouped suggestion is selected with the mouse', () => {
|
|
416
|
+
beforeEach(async () => {
|
|
417
|
+
const options = await page.$$('.ons-autosuggest__option');
|
|
418
|
+
await options[0].click();
|
|
419
|
+
await setTimeout(400);
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it('makes expected bucket request', async () => {
|
|
423
|
+
expect(
|
|
424
|
+
await apiFaker.getRequestCount(
|
|
425
|
+
'/addresses/eq/bucket?postcode=CF14%202AA&streetname=Penlline%20Road&townname=Whitchurch&groupfullpostcodes=combo',
|
|
426
|
+
),
|
|
427
|
+
).toBe(1);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it('keeps nested suggestion entries after blur timeout', async () => {
|
|
431
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) =>
|
|
432
|
+
nodes.map((node) => node.textContent.trim()),
|
|
433
|
+
);
|
|
434
|
+
expect(suggestions).toEqual(['197 College Road, Whitchurch, Cardiff, CF14 2AB']);
|
|
435
|
+
});
|
|
436
|
+
});
|
|
414
437
|
});
|
|
415
438
|
|
|
416
439
|
describe('when there is an error retrieving the address', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{% macro onsAddressOutput(params) %}
|
|
2
|
-
<div class="ons-address-output{{ ' ' + params.classes if params.classes else '' }}">
|
|
2
|
+
<div class="ons-address-output ons-u-reading-width{{ ' ' + params.classes if params.classes else '' }}">
|
|
3
3
|
<p class="ons-address-output__lines">
|
|
4
4
|
{% if params.unit %}
|
|
5
5
|
<span class="ons-address-output__unit">{{ params.unit }}</span><br />
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
&__results-title {
|
|
29
|
+
@include reading-width;
|
|
30
|
+
|
|
29
31
|
background: var(--ons-color-grey-15);
|
|
30
32
|
border-bottom: 1px solid var(--ons-color-input-border);
|
|
31
33
|
padding: 0.25rem 0.5rem;
|
|
@@ -41,6 +43,12 @@
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
&__option-text {
|
|
47
|
+
@include reading-width;
|
|
48
|
+
|
|
49
|
+
display: block;
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
&__option {
|
|
45
53
|
cursor: pointer;
|
|
46
54
|
margin: 0;
|
|
@@ -201,6 +201,8 @@ export default class AutosuggestUI {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
handleFocus() {
|
|
204
|
+
this.blurring = false;
|
|
205
|
+
|
|
204
206
|
if (this.allowMultiple === 'true' && this.allSelections.length && this.input.value.slice(-1) !== ' ' && this.input.value !== '') {
|
|
205
207
|
this.input.value = `${this.input.value}, `;
|
|
206
208
|
}
|
|
@@ -382,7 +384,7 @@ export default class AutosuggestUI {
|
|
|
382
384
|
innerHTML +
|
|
383
385
|
`<span class="ons-autosuggest__category ons-u-lighter ons-u-fs-s ons-u-db">${resultItem.category}</span>`;
|
|
384
386
|
}
|
|
385
|
-
listElement.innerHTML = innerHTML
|
|
387
|
+
listElement.innerHTML = `<span class="ons-autosuggest__option-text">${innerHTML}</span>`;
|
|
386
388
|
listElement.addEventListener('click', () => {
|
|
387
389
|
this.selectResult(index);
|
|
388
390
|
});
|
|
@@ -399,7 +401,7 @@ export default class AutosuggestUI {
|
|
|
399
401
|
const listElement = document.createElement('li');
|
|
400
402
|
listElement.className = `${classAutosuggestOption} ${classAutosuggestOptionMoreResults}`;
|
|
401
403
|
listElement.setAttribute('aria-hidden', 'true');
|
|
402
|
-
listElement.innerHTML = DOMPurify.sanitize(this.moreResults)
|
|
404
|
+
listElement.innerHTML = `<span class="ons-autosuggest__option-text">${DOMPurify.sanitize(this.moreResults)}</span>`;
|
|
403
405
|
this.listbox.appendChild(listElement);
|
|
404
406
|
}
|
|
405
407
|
|
|
@@ -438,11 +440,14 @@ export default class AutosuggestUI {
|
|
|
438
440
|
message = this.typeMore;
|
|
439
441
|
this.setAriaStatus(message);
|
|
440
442
|
this.listbox.innerHTML = DOMPurify.sanitize(
|
|
441
|
-
`<li class="${classAutosuggestOption} ${classAutosuggestOptionNoResults}">${message}</li>`,
|
|
443
|
+
`<li class="${classAutosuggestOption} ${classAutosuggestOptionNoResults}"><span class="ons-autosuggest__option-text">${message}</span></li>`,
|
|
442
444
|
);
|
|
443
445
|
} else if (status > 400 || status === '') {
|
|
444
446
|
const sanitizedHref = DOMPurify.sanitize(window.location.href);
|
|
445
|
-
message =
|
|
447
|
+
message =
|
|
448
|
+
'<p>' +
|
|
449
|
+
this.errorAPI +
|
|
450
|
+
(this.errorAPILinkText ? ' <a href="' + sanitizedHref + '">' + this.errorAPILinkText + '</a>.</p>' : '');
|
|
446
451
|
let ariaMessage = this.errorAPI + (this.errorAPILinkText ? ' ' + this.errorAPILinkText : '');
|
|
447
452
|
|
|
448
453
|
this.input.setAttribute('disabled', true);
|
|
@@ -457,7 +462,7 @@ export default class AutosuggestUI {
|
|
|
457
462
|
} else {
|
|
458
463
|
message = this.noResults;
|
|
459
464
|
this.listbox.innerHTML = DOMPurify.sanitize(
|
|
460
|
-
`<li class="${classAutosuggestOption} ${classAutosuggestOptionNoResults}">${message}</li>`,
|
|
465
|
+
`<li class="${classAutosuggestOption} ${classAutosuggestOptionNoResults}"><span class="ons-autosuggest__option-text">${message}</span></li>`,
|
|
461
466
|
);
|
|
462
467
|
}
|
|
463
468
|
}
|
|
@@ -513,6 +518,7 @@ export default class AutosuggestUI {
|
|
|
513
518
|
|
|
514
519
|
selectResult(index) {
|
|
515
520
|
if (this.results.length) {
|
|
521
|
+
clearTimeout(this.blurTimeout);
|
|
516
522
|
this.settingResult = true;
|
|
517
523
|
const result = this.results[index || this.highlightedResultIndex || 0];
|
|
518
524
|
const resultItem = result.item ?? result;
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
margin-left: 0.25rem;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
// This element also gets a margin-left value set in the JS to match the content left spacing
|
|
7
|
+
&__content {
|
|
8
|
+
@include reading-width;
|
|
9
|
+
|
|
10
|
+
display: inline-block;
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
&__enabled {
|
|
7
14
|
background: none;
|
|
8
15
|
width: fit-content;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{% macro onsBackToTop(params) %}
|
|
4
4
|
<div class="ons-back-to-top ons-js-back-to-top ons-back-to-top__enabled">
|
|
5
5
|
<a href="#{{ params.anchor | default('top') }}" class="ons-back-to-top__link">
|
|
6
|
-
<span>
|
|
6
|
+
<span class="ons-back-to-top__content">
|
|
7
7
|
{{-
|
|
8
8
|
onsIcon({
|
|
9
9
|
"iconType": 'arrow-up',
|
|
@@ -3,7 +3,7 @@ $breadcrumb-chevron-height: 0.65rem;
|
|
|
3
3
|
.ons-breadcrumbs-wrapper {
|
|
4
4
|
position: relative;
|
|
5
5
|
z-index: 10;
|
|
6
|
-
margin-bottom: -
|
|
6
|
+
margin-bottom: -1rem;
|
|
7
7
|
&--grey {
|
|
8
8
|
background-color: var(--ons-color-banner-bg);
|
|
9
9
|
}
|
|
@@ -14,9 +14,9 @@ $breadcrumb-chevron-height: 0.65rem;
|
|
|
14
14
|
|
|
15
15
|
&--navy-blue {
|
|
16
16
|
background-color: var(--ons-color-navy-blue-light);
|
|
17
|
-
margin-bottom: -
|
|
17
|
+
margin-bottom: -0.75rem;
|
|
18
18
|
@include mq(l) {
|
|
19
|
-
margin-bottom: -
|
|
19
|
+
margin-bottom: -2.25rem;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -48,15 +48,12 @@ $breadcrumb-chevron-height: 0.65rem;
|
|
|
48
48
|
&--pale-blue {
|
|
49
49
|
background-color: var(--ons-color-pale-blue);
|
|
50
50
|
}
|
|
51
|
-
.ons-breadcrumbs {
|
|
52
|
-
padding: 1rem;
|
|
53
|
-
}
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
.ons-breadcrumbs {
|
|
57
54
|
align-items: center;
|
|
58
55
|
display: flex;
|
|
59
|
-
padding: 1rem 0;
|
|
56
|
+
padding: 1rem 0 0;
|
|
60
57
|
|
|
61
58
|
&__items {
|
|
62
59
|
margin: 0;
|
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
{% from "components/icon/_macro.njk" import onsIcon %}
|
|
2
2
|
{% macro onsBreadcrumbs(params) %}
|
|
3
3
|
{% set breadcrumbs %}
|
|
4
|
-
<
|
|
5
|
-
class="ons-
|
|
6
|
-
aria-label="{{ params.ariaLabel | default('Breadcrumbs') }}"
|
|
7
|
-
{% if params.id %}id="{{ params.id }}"{% endif %}
|
|
4
|
+
<div
|
|
5
|
+
class="ons-container{{ ' ons-container--full-width' if params.fullWidth else "" }}{{ ' ons-container--wide' if params.wide else "" }}"
|
|
8
6
|
>
|
|
9
|
-
<
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ ' ' }}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
|
|
20
|
-
>{{ item.text }}</a
|
|
7
|
+
<nav
|
|
8
|
+
class="ons-breadcrumbs{{ ' ' + params.classes if params.classes else '' }}"
|
|
9
|
+
aria-label="{{ params.ariaLabel | default('Breadcrumbs') }}"
|
|
10
|
+
{% if params.id %}id="{{ params.id }}"{% endif %}
|
|
11
|
+
>
|
|
12
|
+
<ol class="ons-breadcrumbs__items ons-u-fs-s">
|
|
13
|
+
{%- for item in params.itemsList -%}
|
|
14
|
+
<li
|
|
15
|
+
class="ons-breadcrumbs__item{{ ' ' + item.itemClasses if item.itemClasses else '' }}"
|
|
16
|
+
id="breadcrumb-{{ loop.index }}"
|
|
21
17
|
>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
<a
|
|
19
|
+
class="ons-breadcrumbs__link{{ ' ' + item.linkClasses if item.linkClasses else '' }}"
|
|
20
|
+
href="{% if not isDesignSystemExample %}{{ item.url }}{% else %}#0{% endif %}"
|
|
21
|
+
{% if item.id %}{{ ' ' }}id='{{ item.id }}'{% endif %}
|
|
22
|
+
{% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ ' ' }}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
|
|
23
|
+
>{{ item.text }}</a
|
|
24
|
+
>
|
|
25
|
+
{{-
|
|
26
|
+
onsIcon({
|
|
27
|
+
"iconType": "chevron"
|
|
28
|
+
})
|
|
29
|
+
-}}
|
|
30
|
+
</li>
|
|
31
|
+
{%- endfor -%}
|
|
32
|
+
</ol>
|
|
33
|
+
</nav>
|
|
34
|
+
</div>
|
|
31
35
|
{% endset %}
|
|
32
36
|
{% if params.variant %}
|
|
33
37
|
<div class="ons-breadcrumbs-wrapper ons-breadcrumbs-wrapper--{{ params.variant }}">{{ breadcrumbs | safe }}</div>
|
|
@@ -133,6 +133,45 @@ describe('FOR: Macro: Breadcrumbs', () => {
|
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
+
describe('GIVEN: Params: fullWidth', () => {
|
|
137
|
+
describe('WHEN: fullWidth is not provided', () => {
|
|
138
|
+
const $ = cheerio.load(renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS));
|
|
139
|
+
test('THEN: renders container without full-width class', () => {
|
|
140
|
+
expect($('.ons-container').hasClass('ons-container--full-width')).toBe(false);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
describe('WHEN: fullWidth is set to true', () => {
|
|
144
|
+
const $ = cheerio.load(
|
|
145
|
+
renderComponent('breadcrumbs', {
|
|
146
|
+
...EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS,
|
|
147
|
+
fullWidth: true,
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
test('THEN: renders container with full-width class', () => {
|
|
151
|
+
expect($('.ons-container').hasClass('ons-container--full-width')).toBe(true);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
describe('GIVEN: Params: wide', () => {
|
|
156
|
+
describe('WHEN: wide is not provided', () => {
|
|
157
|
+
const $ = cheerio.load(renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS));
|
|
158
|
+
test('THEN: renders container without wide class', () => {
|
|
159
|
+
expect($('.ons-container').hasClass('ons-container--wide')).toBe(false);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
describe('WHEN: wide is set to true', () => {
|
|
163
|
+
const $ = cheerio.load(
|
|
164
|
+
renderComponent('breadcrumbs', {
|
|
165
|
+
...EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS,
|
|
166
|
+
wide: true,
|
|
167
|
+
}),
|
|
168
|
+
);
|
|
169
|
+
test('THEN: renders container with wide class', () => {
|
|
170
|
+
expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
136
175
|
describe('GIVEN: Params: variant', () => {
|
|
137
176
|
describe('WHEN: variant is provided', () => {
|
|
138
177
|
const $ = cheerio.load(
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Example: Breadcrumbs override wide'
|
|
3
|
+
layout: ~
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
{% from "components/hero/_macro.njk" import onsHero %}
|
|
7
|
+
{% from "components/breadcrumbs/_macro.njk" import onsBreadcrumbs %}
|
|
8
|
+
{% extends "layout/_template.njk" %}
|
|
9
|
+
{%
|
|
10
|
+
set pageConfig = {
|
|
11
|
+
"header": {
|
|
12
|
+
"title": 'Service title',
|
|
13
|
+
"mastheadLogoUrl": '#0',
|
|
14
|
+
"titleUrl": '#0',
|
|
15
|
+
"serviceLinks": {
|
|
16
|
+
"id": "service-links-internal",
|
|
17
|
+
"ariaLabel": 'Services menu',
|
|
18
|
+
"ariaListLabel": 'Menu',
|
|
19
|
+
"toggleServicesButton": {
|
|
20
|
+
"text": 'Account',
|
|
21
|
+
"ariaLabel": 'Toggle services menu'
|
|
22
|
+
},
|
|
23
|
+
"itemsList": [
|
|
24
|
+
{
|
|
25
|
+
"text": "Jacky Turner",
|
|
26
|
+
"iconType": 'person'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"text": "Sign out",
|
|
30
|
+
"url": "#0"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"wide": true
|
|
36
|
+
}
|
|
37
|
+
%}
|
|
38
|
+
|
|
39
|
+
{% block breadcrumbs %}
|
|
40
|
+
{{
|
|
41
|
+
onsBreadcrumbs({
|
|
42
|
+
"wide": true,
|
|
43
|
+
"ariaLabel": 'Breadcrumbs',
|
|
44
|
+
"itemsList": [
|
|
45
|
+
{
|
|
46
|
+
"url": '/',
|
|
47
|
+
"text": 'Home'
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
}}
|
|
52
|
+
{% endblock %}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{% macro onsCharLimit(params) %}
|
|
2
|
-
|
|
3
|
-
{%
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
<div class="ons-u-reading-width">
|
|
3
|
+
{% if params.variant == "check" %}
|
|
4
|
+
{% set content = caller() %}
|
|
5
|
+
<span class="ons-js-char-check-input">{{ content | safe }}</span>
|
|
6
|
+
{% endif %}
|
|
7
|
+
<span
|
|
8
|
+
id="{{ params.id }}"
|
|
9
|
+
class="ons-input__limit ons-u-fs-s--b ons-u-d-no ons-u-mt-2xs"
|
|
10
|
+
data-count-type="{{ params.variant if params.variant == 'word' else 'char' }}"
|
|
11
|
+
data-message-singular="{% if params.variant == 'word' %}{{ params.wordCountSingular }}{% else %}{{ params.charCountSingular }}{% endif %}"
|
|
12
|
+
data-message-plural="{% if params.variant == 'word' %}{{ params.wordCountPlural }}{% else %}{{ params.charCountPlural }}{% endif %}"
|
|
13
|
+
data-message-over-limit-singular="{% if params.variant == 'word' %}{{ params.wordCountOverLimitSingular | default("You have exceeded the word limit by {x} word") }}{% else %}{{ params.charCountOverLimitSingular | default("You have exceeded the character limit by {x} character") }}{% endif %}"
|
|
14
|
+
data-message-over-limit-plural="{% if params.variant == 'word' %}{{ params.wordCountOverLimitPlural | default("You have exceeded the word limit by {x} words") }}{% else %}{{ params.charCountOverLimitPlural | default("You have exceeded the character limit by {x} characters") }}{% endif %}"
|
|
15
|
+
>
|
|
16
|
+
</span>
|
|
17
|
+
</div>
|
|
16
18
|
{% endmacro %}
|
|
@@ -29,15 +29,6 @@
|
|
|
29
29
|
outline-offset: 2px;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
&__download-title {
|
|
33
|
-
@extend .ons-u-pt-l;
|
|
34
|
-
@extend .ons-u-fs-r--b;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&__caption {
|
|
38
|
-
color: var(--ons-color-grey-75);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
32
|
&__annotations-footnotes-number {
|
|
42
33
|
// !important is necessary for some range annotation labels at mobile, otherwise
|
|
43
34
|
// the inline-styled block display takes precedence. This inline style is only
|