@ons/design-system 68.0.0 → 70.0.0
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 +6 -0
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +2 -10
- package/components/access-code/access-code.dom.js +1 -1
- package/components/access-code/access-code.spec.js +2 -2
- package/components/access-code/example-access-code-error.njk +9 -14
- package/components/access-code/example-access-code.njk +3 -5
- package/components/accordion/accordion.js +4 -4
- package/components/address-input/_macro.spec.js +3 -15
- package/components/address-input/autosuggest.address.dom.js +1 -1
- package/components/address-input/autosuggest.address.js +3 -2
- package/components/address-input/autosuggest.address.setter.js +3 -3
- package/components/address-input/autosuggest.address.spec.js +66 -69
- package/components/address-output/_macro.spec.js +6 -30
- package/components/autosuggest/_autosuggest.scss +1 -1
- package/components/autosuggest/autosuggest.dom.js +1 -1
- package/components/autosuggest/autosuggest.helpers.js +1 -1
- package/components/back-to-top/_back-to-top.scss +34 -0
- package/components/back-to-top/_macro.njk +17 -0
- package/components/back-to-top/_macro.spec.js +60 -0
- package/components/back-to-top/back-to-top.dom.js +12 -0
- package/components/back-to-top/back-to-top.js +58 -0
- package/components/back-to-top/back-to-top.spec.js +117 -0
- package/components/back-to-top/example-back-to-top.njk +37 -0
- package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
- package/components/browser-banner/_macro.spec.js +4 -12
- package/components/button/_macro.njk +6 -6
- package/components/button/_macro.spec.js +1 -5
- package/components/button/button.js +7 -8
- package/components/button/button.spec.js +17 -39
- package/components/call-to-action/_macro.spec.js +2 -6
- package/components/card/_macro.njk +25 -25
- package/components/card/_macro.spec.js +10 -34
- package/components/char-check-limit/_macro.njk +1 -1
- package/components/char-check-limit/_macro.spec.js +3 -7
- package/components/char-check-limit/character-check.spec.js +24 -20
- package/components/checkboxes/_checkbox-macro.njk +1 -1
- package/components/checkboxes/_checkbox.scss +0 -3
- package/components/checkboxes/_macro.spec.js +1 -5
- package/components/checkboxes/checkbox-with-autoselect.js +3 -3
- package/components/checkboxes/checkbox-with-fieldset.js +2 -2
- package/components/checkboxes/checkboxes-with-reveal.js +4 -2
- package/components/checkboxes/checkboxes.dom.js +2 -2
- package/components/checkboxes/checkboxes.spec.js +13 -13
- package/components/content-pagination/_macro.spec.js +2 -2
- package/components/cookies-banner/cookies-banner.dom.js +1 -1
- package/components/cookies-banner/cookies-banner.js +1 -1
- package/components/cookies-banner/cookies-banner.spec.js +7 -7
- package/components/date-input/_macro.njk +71 -69
- package/components/date-input/_macro.spec.js +20 -5
- package/components/date-input/example-date-input-double-field.njk +27 -0
- package/components/date-input/example-date-input-single-field.njk +18 -0
- package/components/details/details.spec.js +12 -12
- package/components/details/example-details-with-warning.njk +5 -7
- package/components/document-list/_macro.spec.js +9 -27
- package/components/document-list/document-list.scss +1 -1
- package/components/document-list/example-document-list-downloads.njk +3 -3
- package/components/document-list/example-document-list-search-result-featured.njk +1 -1
- package/components/document-list/example-document-list-search-results.njk +3 -3
- package/components/download-resources/download-resources.js +54 -54
- package/components/download-resources/download-resources.spec.js +3 -1
- package/components/duration/_macro.njk +52 -48
- package/components/duration/_macro.spec.js +112 -4
- package/components/duration/example-duration-error-for-single-field.njk +1 -1
- package/components/duration/example-duration-single-field.njk +24 -0
- package/components/error/_macro.njk +1 -1
- package/components/error/_macro.spec.js +2 -6
- package/components/feedback/_macro.njk +1 -1
- package/components/feedback/_macro.spec.js +4 -20
- package/components/field/_macro.spec.js +1 -3
- package/components/fieldset/_fieldset.scss +1 -2
- package/components/fieldset/_macro.spec.js +3 -9
- package/components/footer/_footer.scss +8 -0
- package/components/footer/_macro.njk +8 -7
- package/components/footer/_macro.spec.js +14 -2
- package/components/header/_macro.njk +1 -1
- package/components/header/_macro.spec.js +1 -1
- package/components/helpers/grid.njk +15 -15
- package/components/icon/_macro.njk +15 -11
- package/components/icon/_macro.spec.js +8 -16
- package/components/image/_macro.spec.js +1 -5
- package/components/input/_macro.njk +22 -23
- package/components/input/_macro.spec.js +1 -1
- package/components/input/character-check.dom.js +1 -1
- package/components/input/input.spec.js +1 -4
- package/components/label/_label.scss +1 -0
- package/components/label/_macro.njk +2 -2
- package/components/label/_macro.spec.js +4 -13
- package/components/list/_macro.spec.js +4 -12
- package/components/message/_macro.njk +17 -17
- package/components/message/_macro.spec.js +9 -33
- package/components/message-list/_macro.spec.js +7 -39
- package/components/metadata/_macro.njk +10 -10
- package/components/modal/_macro.spec.js +3 -9
- package/components/modal/modal.dom.js +1 -1
- package/components/modal/modal.spec.js +5 -5
- package/components/multiple-input-fields/_macro.njk +49 -0
- package/components/mutually-exclusive/_macro.spec.js +2 -10
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +9 -9
- package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +8 -8
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.js +13 -13
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
- package/components/navigation/navigation.spec.js +0 -2
- package/components/pagination/_macro.spec.js +11 -53
- package/components/panel/_macro.njk +17 -17
- package/components/panel/_macro.spec.js +25 -25
- package/components/panel/_panel.scss +10 -9
- package/components/panel/example-panel-bare.njk +3 -4
- package/components/panel/example-panel-with-announcement.njk +6 -10
- package/components/panel/example-panel-with-error-summary.njk +2 -2
- package/components/panel/example-panel-with-information.njk +0 -1
- package/components/panel/example-panel-with-success-message.njk +1 -1
- package/components/panel/example-panel-with-warning.njk +2 -3
- package/components/password/password.dom.js +1 -1
- package/components/phase-banner/_macro.spec.js +3 -9
- package/components/question/_macro.njk +1 -1
- package/components/question/_macro.spec.js +5 -19
- package/components/question/_question.scss +1 -4
- package/components/question/example-question-interviewer-note.njk +1 -1
- package/components/quote/_macro.spec.js +2 -10
- package/components/radios/clear-radios.js +3 -3
- package/components/radios/radio-with-fieldset.js +4 -4
- package/components/radios/radios.dom.js +1 -1
- package/components/radios/radios.spec.js +26 -26
- package/components/related-content/_macro.spec.js +2 -4
- package/components/related-content/_section-macro.spec.js +2 -8
- package/components/relationships/example-relationships-error.njk +16 -18
- package/components/relationships/relationships.dom.js +1 -1
- package/components/relationships/relationships.js +2 -2
- package/components/reply/_macro.spec.js +3 -3
- package/components/reply/reply.dom.js +1 -1
- package/components/reply/reply.spec.js +3 -3
- package/components/section-navigation/_macro.njk +12 -12
- package/components/section-navigation/_macro.spec.js +13 -21
- package/components/select/_macro.spec.js +6 -6
- package/components/share-page/_macro.spec.js +6 -14
- package/components/skip-to-content/_macro.spec.js +3 -11
- package/components/skip-to-content/skip-to-content.dom.js +1 -1
- package/components/skip-to-content/skip-to-content.js +1 -1
- package/components/skip-to-content/skip-to-content.spec.js +2 -2
- package/components/status/_macro.njk +2 -2
- package/components/status/_macro.spec.js +5 -9
- package/components/status/example-status-dead.njk +1 -1
- package/components/status/example-status-error.njk +1 -1
- package/components/status/example-status-pending.njk +1 -1
- package/components/status/example-status-small.njk +1 -1
- package/components/status/example-status-success.njk +1 -1
- package/components/summary/_macro.njk +7 -8
- package/components/summary/_macro.spec.js +27 -9
- package/components/table/_macro.spec.js +6 -10
- package/components/table/scrollable-table.dom.js +1 -1
- package/components/table/scrollable-table.js +1 -1
- package/components/table/sortable-table.js +4 -4
- package/components/table/table.spec.js +21 -17
- package/components/table-of-contents/_macro.njk +31 -31
- package/components/table-of-contents/_macro.spec.js +3 -11
- package/components/table-of-contents/toc.dom.js +1 -1
- package/components/table-of-contents/toc.spec.js +36 -32
- package/components/tabs/example-tabs-details.njk +1 -1
- package/components/tabs/tabs.dom.js +1 -1
- package/components/tabs/tabs.js +8 -8
- package/components/text-indent/_macro.spec.js +2 -6
- package/components/textarea/textarea.dom.js +1 -1
- package/components/textarea/textarea.spec.js +8 -8
- package/components/timeout-modal/_macro.spec.js +1 -3
- package/components/timeout-modal/timeout-modal.dom.js +1 -1
- package/components/timeout-modal/timeout-modal.spec.js +10 -10
- package/components/timeout-panel/_macro.njk +16 -17
- package/components/timeout-panel/_macro.spec.js +1 -1
- package/components/timeout-panel/timeout-panel.dom.js +1 -1
- package/components/timeout-panel/timeout-panel.spec.js +8 -8
- package/components/video/_macro.spec.js +1 -5
- package/components/video/video.dom.js +1 -1
- package/components/video/video.spec.js +16 -12
- package/css/main.css +1 -1
- package/favicons/safari-pinned-tab.svg +23 -23
- package/js/analytics.js +15 -14
- package/js/cookies-settings.dom.js +1 -1
- package/js/cookies-settings.spec.js +19 -19
- package/js/domready.js +1 -1
- package/js/fetch.js +1 -1
- package/js/inpagelink.js +3 -3
- package/js/main.js +1 -0
- package/js/print-button.js +1 -1
- package/js/timeout.js +1 -1
- package/package.json +2 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_typography.scss +8 -2
- package/scss/main.scss +1 -0
- package/scss/overrides/hcm.scss +8 -1
- package/scss/vars/_colors.scss +2 -1
- package/components/date-field-input/_macro.njk +0 -86
|
@@ -68,7 +68,6 @@
|
|
|
68
68
|
"accessiblePlaceholder": params.accessiblePlaceholder,
|
|
69
69
|
"inline": params.label.inline
|
|
70
70
|
}) }}
|
|
71
|
-
|
|
72
71
|
{% endif %}
|
|
73
72
|
|
|
74
73
|
{% if params.prefix or params.suffix %}
|
|
@@ -103,16 +102,16 @@
|
|
|
103
102
|
{% elif params.searchButton %}
|
|
104
103
|
<span class="ons-grid--flex ons-input_search-button{% if params.label.description %} ons-input--with-text-description{% endif %}">
|
|
105
104
|
{% if params.accessiblePlaceholder %}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
{{ onsLabel({
|
|
106
|
+
"for": params.id,
|
|
107
|
+
"id": params.label.id,
|
|
108
|
+
"text": params.label.text,
|
|
109
|
+
"classes": params.label.classes,
|
|
110
|
+
"attributes": params.label.attributes,
|
|
111
|
+
"accessiblePlaceholder": params.accessiblePlaceholder,
|
|
112
|
+
"inline": params.label.inline
|
|
113
|
+
}) }}
|
|
114
|
+
{% endif %}
|
|
116
115
|
|
|
117
116
|
{{ input | safe }}
|
|
118
117
|
{%- set buttonLabel -%}
|
|
@@ -138,23 +137,23 @@
|
|
|
138
137
|
</span>
|
|
139
138
|
{% else %}
|
|
140
139
|
{% if params.accessiblePlaceholder %}
|
|
141
|
-
|
|
140
|
+
<span class="ons-grid--flex {% if params.label.description %} ons-input--with-text-description{% endif %}">
|
|
142
141
|
{% if params.accessiblePlaceholder %}
|
|
143
142
|
{{ onsLabel({
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
143
|
+
"for": params.id,
|
|
144
|
+
"id": params.label.id,
|
|
145
|
+
"text": params.label.text,
|
|
146
|
+
"classes": params.label.classes,
|
|
147
|
+
"attributes": params.label.attributes,
|
|
148
|
+
"accessiblePlaceholder": params.accessiblePlaceholder,
|
|
149
|
+
"inline": params.label.inline
|
|
150
|
+
}) }}
|
|
152
151
|
{% endif %}
|
|
153
152
|
{% endif %}
|
|
154
153
|
{{ input | safe }}
|
|
155
154
|
{% if params.accessiblePlaceholder %}
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
</span>
|
|
156
|
+
{% endif %}
|
|
158
157
|
{% endif %}
|
|
159
158
|
{% endset %}
|
|
160
159
|
|
|
@@ -163,7 +162,7 @@
|
|
|
163
162
|
{% call onsCharLimit({
|
|
164
163
|
"id": params.id ~ "-check",
|
|
165
164
|
"limit": params.charCheckLimit.limit,
|
|
166
|
-
"
|
|
165
|
+
"variant": "check",
|
|
167
166
|
"charCountSingular": params.charCheckLimit.charCountSingular,
|
|
168
167
|
"charCountPlural": params.charCheckLimit.charCountPlural,
|
|
169
168
|
"charCountOverLimitSingular": params.charCheckLimit.charCountOverLimitSingular,
|
|
@@ -617,7 +617,7 @@ describe('macro: input', () => {
|
|
|
617
617
|
expect(charCheckLimitSpy.occurrences).toContainEqual({
|
|
618
618
|
id: 'example-id-check',
|
|
619
619
|
limit: 200,
|
|
620
|
-
|
|
620
|
+
variant: 'check',
|
|
621
621
|
charCountSingular: 'You have {x} character remaining',
|
|
622
622
|
charCountPlural: 'You have {x} characters remaining',
|
|
623
623
|
charCountOverLimitSingular: '{x} character too many',
|
|
@@ -6,7 +6,7 @@ async function initialise() {
|
|
|
6
6
|
if (checkedInputs.length) {
|
|
7
7
|
const CharCheck = (await import('../char-check-limit/character-check')).default;
|
|
8
8
|
|
|
9
|
-
checkedInputs.forEach(input => new CharCheck(input));
|
|
9
|
+
checkedInputs.forEach((input) => new CharCheck(input));
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import axe from '../../tests/helpers/axe';
|
|
4
|
-
import { renderComponent, templateFaker, setTestPage } from '../../tests/helpers/rendering';
|
|
1
|
+
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
5
2
|
|
|
6
3
|
const EXAMPLE_INPUT_MINIMAL = {
|
|
7
4
|
id: 'example-id',
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</span>
|
|
18
18
|
{%- endset %}
|
|
19
19
|
{%- if params.description and params.accessiblePlaceholder -%}
|
|
20
|
-
{{- description | safe -}}
|
|
20
|
+
{{- description | safe -}}
|
|
21
21
|
{%- else -%}
|
|
22
22
|
<label
|
|
23
23
|
class="{% if params.inputType is not defined -%}ons-label{%- endif %}{{- ' ' + params.classes if params.classes else "" -}}{%- if params.description %} ons-label--with-description{%- endif %} {{- ' ons-label--placeholder' if params.accessiblePlaceholder else "" -}}"
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
{{- description | safe -}}
|
|
44
44
|
{%- endif -%}
|
|
45
45
|
{%- endif %}
|
|
46
|
-
{%- endif -%}
|
|
46
|
+
{%- endif -%}
|
|
47
47
|
{% endmacro %}
|
|
@@ -119,12 +119,7 @@ describe('macro: label', () => {
|
|
|
119
119
|
])('has the provided `text` %s', (_, params) => {
|
|
120
120
|
const $ = cheerio.load(renderComponent('label', params));
|
|
121
121
|
|
|
122
|
-
expect(
|
|
123
|
-
$('.ons-label')
|
|
124
|
-
.text()
|
|
125
|
-
.trim()
|
|
126
|
-
.startsWith('Example label text'),
|
|
127
|
-
).toBe(true);
|
|
122
|
+
expect($('.ons-label').text().trim().startsWith('Example label text')).toBe(true);
|
|
128
123
|
});
|
|
129
124
|
|
|
130
125
|
describe('description element', () => {
|
|
@@ -147,11 +142,7 @@ describe('macro: label', () => {
|
|
|
147
142
|
])('has the provided `description` text %s', (_, params) => {
|
|
148
143
|
const $ = cheerio.load(renderComponent('label', params));
|
|
149
144
|
|
|
150
|
-
expect(
|
|
151
|
-
$('.ons-label__description')
|
|
152
|
-
.text()
|
|
153
|
-
.trim(),
|
|
154
|
-
).toBe('An example description');
|
|
145
|
+
expect($('.ons-label__description').text().trim()).toBe('An example description');
|
|
155
146
|
});
|
|
156
147
|
|
|
157
148
|
it('has a default `id` attribute of `description-hint`', () => {
|
|
@@ -192,7 +183,7 @@ describe('macro: label', () => {
|
|
|
192
183
|
expect($('.ons-label__description').hasClass('ons-input--with-description')).toBe(false);
|
|
193
184
|
});
|
|
194
185
|
|
|
195
|
-
it.each([['checkbox'], ['radio']])('has the description in an `aria-hidden` element when "%s" `inputType` is provided', inputType => {
|
|
186
|
+
it.each([['checkbox'], ['radio']])('has the description in an `aria-hidden` element when "%s" `inputType` is provided', (inputType) => {
|
|
196
187
|
const $ = cheerio.load(
|
|
197
188
|
renderComponent('label', {
|
|
198
189
|
...EXAMPLE_LABEL_WITH_DESCRIPTION,
|
|
@@ -205,7 +196,7 @@ describe('macro: label', () => {
|
|
|
205
196
|
|
|
206
197
|
it.each([['checkbox'], ['radio']])(
|
|
207
198
|
'has a duplicate description in a visually hidden element when "%s" `inputType` is provided',
|
|
208
|
-
inputType => {
|
|
199
|
+
(inputType) => {
|
|
209
200
|
const $ = cheerio.load(
|
|
210
201
|
renderComponent('label', {
|
|
211
202
|
...EXAMPLE_LABEL_WITH_DESCRIPTION,
|
|
@@ -465,11 +465,7 @@ describe('macro: list', () => {
|
|
|
465
465
|
}),
|
|
466
466
|
);
|
|
467
467
|
|
|
468
|
-
expect(
|
|
469
|
-
$('.ons-list__prefix')
|
|
470
|
-
.text()
|
|
471
|
-
.trim(),
|
|
472
|
-
).toBe('[PREFIX].');
|
|
468
|
+
expect($('.ons-list__prefix').text().trim()).toBe('[PREFIX].');
|
|
473
469
|
});
|
|
474
470
|
|
|
475
471
|
it('marks `prefix` content as visually hidden when list element is not <ol>', () => {
|
|
@@ -521,11 +517,7 @@ describe('macro: list', () => {
|
|
|
521
517
|
}),
|
|
522
518
|
);
|
|
523
519
|
|
|
524
|
-
expect(
|
|
525
|
-
$('.ons-list__suffix')
|
|
526
|
-
.text()
|
|
527
|
-
.trim(),
|
|
528
|
-
).toBe('[SUFFIX]');
|
|
520
|
+
expect($('.ons-list__suffix').text().trim()).toBe('[SUFFIX]');
|
|
529
521
|
});
|
|
530
522
|
|
|
531
523
|
it('marks `suffix` content as visually hidden when list element is not <ol>', () => {
|
|
@@ -565,7 +557,7 @@ describe('macro: list', () => {
|
|
|
565
557
|
});
|
|
566
558
|
|
|
567
559
|
describe('icons', () => {
|
|
568
|
-
it.each([['before'], ['after']])('renders default icon on list items when icon is positioned %s', iconPosition => {
|
|
560
|
+
it.each([['before'], ['after']])('renders default icon on list items when icon is positioned %s', (iconPosition) => {
|
|
569
561
|
const faker = templateFaker();
|
|
570
562
|
const iconsSpy = faker.spy('icon');
|
|
571
563
|
|
|
@@ -580,7 +572,7 @@ describe('macro: list', () => {
|
|
|
580
572
|
expect(iconsSpy.occurrences[1]).toEqual({ iconType: 'check', iconSize: 'xl' });
|
|
581
573
|
});
|
|
582
574
|
|
|
583
|
-
it.each([['before'], ['after']])('renders a custom icon on specific list items when icon is positioned %s', iconPosition => {
|
|
575
|
+
it.each([['before'], ['after']])('renders a custom icon on specific list items when icon is positioned %s', (iconPosition) => {
|
|
584
576
|
const faker = templateFaker();
|
|
585
577
|
const iconsSpy = faker.spy('icon');
|
|
586
578
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{%- macro onsMessage(params) -%}
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
<div class="ons-message ons-message--{{ params.variant }}">
|
|
3
|
+
<div class="ons-message__head">
|
|
4
|
+
<dl class="ons-message__metadata" {% if params.id %} id="{{ params.id }}"{% endif %}>
|
|
5
|
+
<div class="ons-message__sender">
|
|
6
|
+
<dt class="ons-message__term ons-u-fw-b">{{ params.fromLabel }}:</dt>
|
|
7
|
+
<dd class="ons-message__value ons-u-fw-b" {% if params.fromId %} id="{{ params.fromId }}"{% endif %} {% if params.fromName %} name="{{ params.fromName }}"{% endif %}>{{ params.fromValue }}</dd>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="ons-message__timestamp">
|
|
10
|
+
<dt class="ons-message__term ons-u-fs-s">{{ params.sentLabel }}:</dt>
|
|
11
|
+
<dd class="ons-message__value ons-u-fs-s" {% if params.sentId %} id="{{ params.sentId }}"{% endif %} {% if params.sentName %} name="{{ params.sentName }}"{% endif %}>{{ params.sentValue }}</dd>
|
|
12
|
+
</div>
|
|
13
|
+
</dl>
|
|
14
|
+
{% if params.unreadLink %}
|
|
15
|
+
<a class="ons-message__unread-link" {% if params.unreadLinkId %}id="{{ params.unreadLinkId }}"{% endif %} href="{{ params.unreadLink }}">{{ params.unreadLinkText }}</a>
|
|
16
|
+
{% endif %}
|
|
8
17
|
</div>
|
|
9
|
-
<div class="ons-
|
|
10
|
-
|
|
11
|
-
<dd class="ons-message__value ons-u-fs-s" {% if params.sentId %} id="{{ params.sentId }}"{% endif %} {% if params.sentName %} name="{{ params.sentName }}"{% endif %}>{{ params.sentValue }}</dd>
|
|
18
|
+
<div class="ons-message__body" {% if params.messageID %} id="{{ params.messageID }}"{% endif %}>
|
|
19
|
+
{{ caller() }}
|
|
12
20
|
</div>
|
|
13
|
-
</dl>
|
|
14
|
-
{% if params.unreadLink %}
|
|
15
|
-
<a class="ons-message__unread-link" {% if params.unreadLinkId %}id="{{ params.unreadLinkId }}"{% endif %} href="{{ params.unreadLink }}">{{ params.unreadLinkText }}</a>
|
|
16
|
-
{% endif %}
|
|
17
21
|
</div>
|
|
18
|
-
<div class="ons-message__body" {% if params.messageID %} id="{{ params.messageID }}"{% endif %}>
|
|
19
|
-
{{ caller() }}
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
22
|
{%- endmacro -%}
|
|
@@ -6,7 +6,7 @@ import axe from '../../tests/helpers/axe';
|
|
|
6
6
|
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
8
|
const EXAMPLE_MESSAGE_MINIMAL = {
|
|
9
|
-
|
|
9
|
+
variant: 'sent',
|
|
10
10
|
fromLabel: 'From',
|
|
11
11
|
fromValue: 'Example Sender',
|
|
12
12
|
sentLabel: 'Date sent',
|
|
@@ -35,13 +35,13 @@ describe('macro: message', () => {
|
|
|
35
35
|
it.each([
|
|
36
36
|
['sent', 'ons-message--sent'],
|
|
37
37
|
['received', 'ons-message--received'],
|
|
38
|
-
])('has appropriate class for provided `
|
|
38
|
+
])('has appropriate class for provided `variant` (%s -> %s)', (variant, expectedClass) => {
|
|
39
39
|
const $ = cheerio.load(
|
|
40
40
|
renderComponent(
|
|
41
41
|
'message',
|
|
42
42
|
{
|
|
43
43
|
...EXAMPLE_MESSAGE_MINIMAL,
|
|
44
|
-
|
|
44
|
+
variant,
|
|
45
45
|
},
|
|
46
46
|
['Message content...'],
|
|
47
47
|
),
|
|
@@ -59,21 +59,13 @@ describe('macro: message', () => {
|
|
|
59
59
|
it('has the provided `fromLabel`', () => {
|
|
60
60
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
61
61
|
|
|
62
|
-
expect(
|
|
63
|
-
$('.ons-message__sender .ons-message__term')
|
|
64
|
-
.text()
|
|
65
|
-
.trim(),
|
|
66
|
-
).toBe('From:');
|
|
62
|
+
expect($('.ons-message__sender .ons-message__term').text().trim()).toBe('From:');
|
|
67
63
|
});
|
|
68
64
|
|
|
69
65
|
it('has the provided `fromValue`', () => {
|
|
70
66
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
71
67
|
|
|
72
|
-
expect(
|
|
73
|
-
$('.ons-message__sender .ons-message__value')
|
|
74
|
-
.text()
|
|
75
|
-
.trim(),
|
|
76
|
-
).toBe('Example Sender');
|
|
68
|
+
expect($('.ons-message__sender .ons-message__value').text().trim()).toBe('Example Sender');
|
|
77
69
|
});
|
|
78
70
|
|
|
79
71
|
it('has the provided `fromId`', () => {
|
|
@@ -85,21 +77,13 @@ describe('macro: message', () => {
|
|
|
85
77
|
it('has the provided `sentLabel`', () => {
|
|
86
78
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
87
79
|
|
|
88
|
-
expect(
|
|
89
|
-
$('.ons-message__timestamp .ons-message__term')
|
|
90
|
-
.text()
|
|
91
|
-
.trim(),
|
|
92
|
-
).toBe('Date sent:');
|
|
80
|
+
expect($('.ons-message__timestamp .ons-message__term').text().trim()).toBe('Date sent:');
|
|
93
81
|
});
|
|
94
82
|
|
|
95
83
|
it('has the provided `sentValue`', () => {
|
|
96
84
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
97
85
|
|
|
98
|
-
expect(
|
|
99
|
-
$('.ons-message__timestamp .ons-message__value')
|
|
100
|
-
.text()
|
|
101
|
-
.trim(),
|
|
102
|
-
).toBe('Tue 4 Jul 2020 at 7:47');
|
|
86
|
+
expect($('.ons-message__timestamp .ons-message__value').text().trim()).toBe('Tue 4 Jul 2020 at 7:47');
|
|
103
87
|
});
|
|
104
88
|
|
|
105
89
|
it('has the provided `sentId`', () => {
|
|
@@ -117,20 +101,12 @@ describe('macro: message', () => {
|
|
|
117
101
|
it('has the provided `unreadLinkText`', () => {
|
|
118
102
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE, ['Message content...']));
|
|
119
103
|
|
|
120
|
-
expect(
|
|
121
|
-
$('.ons-message__unread-link')
|
|
122
|
-
.text()
|
|
123
|
-
.trim(),
|
|
124
|
-
).toBe('Unread message');
|
|
104
|
+
expect($('.ons-message__unread-link').text().trim()).toBe('Unread message');
|
|
125
105
|
});
|
|
126
106
|
|
|
127
107
|
it('has the message content', () => {
|
|
128
108
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
129
109
|
|
|
130
|
-
expect(
|
|
131
|
-
$('.ons-message__body')
|
|
132
|
-
.text()
|
|
133
|
-
.trim(),
|
|
134
|
-
).toBe('Message content...');
|
|
110
|
+
expect($('.ons-message__body').text().trim()).toBe('Message content...');
|
|
135
111
|
});
|
|
136
112
|
});
|
|
@@ -85,31 +85,19 @@ describe('macro: message-list', () => {
|
|
|
85
85
|
it('has `unreadText` for unread messages', () => {
|
|
86
86
|
const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST));
|
|
87
87
|
|
|
88
|
-
expect(
|
|
89
|
-
$('#message1 .ons-message-item__unread')
|
|
90
|
-
.text()
|
|
91
|
-
.trim(),
|
|
92
|
-
).toBe('(New)');
|
|
88
|
+
expect($('#message1 .ons-message-item__unread').text().trim()).toBe('(New)');
|
|
93
89
|
});
|
|
94
90
|
|
|
95
91
|
it('has visually hidden label `fromLabel`', () => {
|
|
96
92
|
const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_MINIMAL));
|
|
97
93
|
|
|
98
|
-
expect(
|
|
99
|
-
$('.ons-message-item__metadata-term--from:first')
|
|
100
|
-
.text()
|
|
101
|
-
.trim(),
|
|
102
|
-
).toBe('From:');
|
|
94
|
+
expect($('.ons-message-item__metadata-term--from:first').text().trim()).toBe('From:');
|
|
103
95
|
});
|
|
104
96
|
|
|
105
97
|
it('has visually hidden label `dateLabel`', () => {
|
|
106
98
|
const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_MINIMAL));
|
|
107
99
|
|
|
108
|
-
expect(
|
|
109
|
-
$('.ons-message-item__metadata-term--date:first')
|
|
110
|
-
.text()
|
|
111
|
-
.trim(),
|
|
112
|
-
).toBe('Date:');
|
|
100
|
+
expect($('.ons-message-item__metadata-term--date:first').text().trim()).toBe('Date:');
|
|
113
101
|
});
|
|
114
102
|
|
|
115
103
|
it('has visually hidden label `hiddenReadLabel`', () => {
|
|
@@ -123,31 +111,11 @@ describe('macro: message-list', () => {
|
|
|
123
111
|
|
|
124
112
|
const $message2 = $('.ons-message-item:nth-child(2)');
|
|
125
113
|
|
|
126
|
-
expect(
|
|
127
|
-
$message2
|
|
128
|
-
.find('.ons-message-item__subject')
|
|
129
|
-
.text()
|
|
130
|
-
.trim(),
|
|
131
|
-
).toBe('Another example message subject');
|
|
114
|
+
expect($message2.find('.ons-message-item__subject').text().trim()).toBe('Another example message subject');
|
|
132
115
|
expect($message2.find('.ons-message-item__subject').attr('id')).toBe('message2');
|
|
133
|
-
expect(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.text()
|
|
137
|
-
.trim(),
|
|
138
|
-
).toBe('Example Sender 2');
|
|
139
|
-
expect(
|
|
140
|
-
$message2
|
|
141
|
-
.find('.ons-message-item__metadata-value--date')
|
|
142
|
-
.text()
|
|
143
|
-
.trim(),
|
|
144
|
-
).toBe('Mon 1 Oct 2019 at 9:52');
|
|
145
|
-
expect(
|
|
146
|
-
$message2
|
|
147
|
-
.find('.ons-message-item__body')
|
|
148
|
-
.text()
|
|
149
|
-
.trim(),
|
|
150
|
-
).toBe('Another example message.');
|
|
116
|
+
expect($message2.find('.ons-message-item__metadata-value--from').text().trim()).toBe('Example Sender 2');
|
|
117
|
+
expect($message2.find('.ons-message-item__metadata-value--date').text().trim()).toBe('Mon 1 Oct 2019 at 9:52');
|
|
118
|
+
expect($message2.find('.ons-message-item__body').text().trim()).toBe('Another example message.');
|
|
151
119
|
expect($message2.find('.ons-message-item__link a').attr('href')).toBe('https://example.com/message/2');
|
|
152
120
|
});
|
|
153
121
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{% from "components/description-list/_macro.njk" import onsDescriptionList %}
|
|
2
2
|
|
|
3
3
|
{% macro onsMetadata(params) %}
|
|
4
|
-
{{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}}
|
|
4
|
+
{{
|
|
5
|
+
onsDescriptionList({
|
|
6
|
+
"id": params.id,
|
|
7
|
+
"classes": params.classes,
|
|
8
|
+
"descriptionListLabel": params.metadataLabel,
|
|
9
|
+
"termCol": params.termCol,
|
|
10
|
+
"descriptionCol": params.descriptionCol,
|
|
11
|
+
"itemsList": params.itemsList
|
|
12
|
+
})
|
|
13
|
+
}}
|
|
14
14
|
{% endmacro %}
|
|
@@ -22,18 +22,14 @@ describe('macro: modal', () => {
|
|
|
22
22
|
it('has expected `title`', () => {
|
|
23
23
|
const $ = cheerio.load(renderComponent('modal', EXAMPLE_MODAL_BASIC));
|
|
24
24
|
|
|
25
|
-
const title = $('.ons-modal__title')
|
|
26
|
-
.html()
|
|
27
|
-
.trim();
|
|
25
|
+
const title = $('.ons-modal__title').html().trim();
|
|
28
26
|
expect(title).toBe('Modal title');
|
|
29
27
|
});
|
|
30
28
|
|
|
31
29
|
it('has expected `body`', () => {
|
|
32
30
|
const $ = cheerio.load(renderComponent('modal', EXAMPLE_MODAL_BASIC));
|
|
33
31
|
|
|
34
|
-
const title = $('.ons-modal__body')
|
|
35
|
-
.html()
|
|
36
|
-
.trim();
|
|
32
|
+
const title = $('.ons-modal__body').html().trim();
|
|
37
33
|
expect(title).toBe('Modal body text');
|
|
38
34
|
});
|
|
39
35
|
|
|
@@ -64,9 +60,7 @@ describe('macro: modal', () => {
|
|
|
64
60
|
it('calls with content', () => {
|
|
65
61
|
const $ = cheerio.load(renderComponent('modal', { EXAMPLE_MODAL_BASIC }, 'Example content...'));
|
|
66
62
|
|
|
67
|
-
const content = $('.ons-modal__body')
|
|
68
|
-
.text()
|
|
69
|
-
.trim();
|
|
63
|
+
const content = $('.ons-modal__body').text().trim();
|
|
70
64
|
expect(content).toBe('Example content...');
|
|
71
65
|
});
|
|
72
66
|
|
|
@@ -25,12 +25,12 @@ describe('script: modal', () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it('displays the modal', async () => {
|
|
28
|
-
const modalIsVisible = await page.$eval('.ons-modal', node => node.classList.contains('ons-u-db'));
|
|
28
|
+
const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
|
|
29
29
|
expect(modalIsVisible).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it('has the correct body class added', async () => {
|
|
33
|
-
const bodyClassAddition = await page.$eval('body', node => node.classList.contains('ons-modal-overlay'));
|
|
33
|
+
const bodyClassAddition = await page.$eval('body', (node) => node.classList.contains('ons-modal-overlay'));
|
|
34
34
|
expect(bodyClassAddition).toBe(true);
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -41,12 +41,12 @@ describe('script: modal', () => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
it('hides the modal', async () => {
|
|
44
|
-
const modalIsVisible = await page.$eval('.ons-modal', node => node.classList.contains('ons-u-db'));
|
|
44
|
+
const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
|
|
45
45
|
expect(modalIsVisible).toBe(false);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it('has the body class removed', async () => {
|
|
49
|
-
const bodyClassAddition = await page.$eval('body', node => node.classList.contains('ons-modal-overlay'));
|
|
49
|
+
const bodyClassAddition = await page.$eval('body', (node) => node.classList.contains('ons-modal-overlay'));
|
|
50
50
|
expect(bodyClassAddition).toBe(false);
|
|
51
51
|
});
|
|
52
52
|
|
|
@@ -64,7 +64,7 @@ describe('script: modal', () => {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
it('closes the modal', async () => {
|
|
67
|
-
const modalIsVisible = await page.$eval('.ons-modal', node => node.classList.contains('ons-u-db'));
|
|
67
|
+
const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
|
|
68
68
|
expect(modalIsVisible).toBe(false);
|
|
69
69
|
});
|
|
70
70
|
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{% from "components/mutually-exclusive/_macro.njk" import onsMutuallyExclusive %}
|
|
2
|
+
{% from "components/fieldset/_macro.njk" import onsFieldset %}
|
|
3
|
+
|
|
4
|
+
{% macro onsMultipleInputFields(params) %}
|
|
5
|
+
{% if params.numberOfFields > 1 %}
|
|
6
|
+
{% set fields %}
|
|
7
|
+
<div class="ons-field-group">
|
|
8
|
+
{{ params.fields | safe }}
|
|
9
|
+
</div>
|
|
10
|
+
{% endset %}
|
|
11
|
+
{% else %}
|
|
12
|
+
{{ params.fields | safe }}
|
|
13
|
+
{% endif %}
|
|
14
|
+
|
|
15
|
+
{% if params.mutuallyExclusive %}
|
|
16
|
+
{% call onsMutuallyExclusive({
|
|
17
|
+
"id": params.id,
|
|
18
|
+
"legend": params.legendOrLabel,
|
|
19
|
+
"legendClasses": params.legendClasses,
|
|
20
|
+
"description": params.description,
|
|
21
|
+
"classes": params.classes,
|
|
22
|
+
"dontWrap": params.dontWrap if params.numberOfFields > 1 else true,
|
|
23
|
+
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
24
|
+
"exclusiveOptions": params.mutuallyExclusive.exclusiveOptions,
|
|
25
|
+
"or": params.mutuallyExclusive.or,
|
|
26
|
+
"deselectMessage": params.mutuallyExclusive.deselectMessage,
|
|
27
|
+
"deselectGroupAdjective": params.mutuallyExclusive.deselectGroupAdjective,
|
|
28
|
+
"deselectExclusiveOptionAdjective": params.mutuallyExclusive.deselectExclusiveOptionAdjective,
|
|
29
|
+
"error": params.error
|
|
30
|
+
}) %}
|
|
31
|
+
{{ fields | safe }}
|
|
32
|
+
{% endcall %}
|
|
33
|
+
{% elif params.numberOfFields > 1 %}
|
|
34
|
+
{% call onsFieldset({
|
|
35
|
+
"id": params.id,
|
|
36
|
+
"legend": params.legendOrLabel,
|
|
37
|
+
"legendClasses": params.legendClasses,
|
|
38
|
+
"description": params.description,
|
|
39
|
+
"classes": params.classes,
|
|
40
|
+
"dontWrap": params.dontWrap,
|
|
41
|
+
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
42
|
+
"error": params.error
|
|
43
|
+
}) %}
|
|
44
|
+
{{ fields | safe }}
|
|
45
|
+
{% endcall %}
|
|
46
|
+
{% else %}
|
|
47
|
+
{{ fields | safe }}
|
|
48
|
+
{% endif %}
|
|
49
|
+
{% endmacro %}
|
|
@@ -123,11 +123,7 @@ describe('macro: mutually-exclusive', () => {
|
|
|
123
123
|
it('renders visually hidden "Or" label', () => {
|
|
124
124
|
const $ = cheerio.load(renderComponent('mutually-exclusive', EXAMPLE_MUTUALLY_EXCLUSIVE, FAKE_FIELD));
|
|
125
125
|
|
|
126
|
-
expect(
|
|
127
|
-
$('.ons-checkboxes__label')
|
|
128
|
-
.text()
|
|
129
|
-
.trim(),
|
|
130
|
-
).toBe('Or');
|
|
126
|
+
expect($('.ons-checkboxes__label').text().trim()).toBe('Or');
|
|
131
127
|
});
|
|
132
128
|
|
|
133
129
|
it('renders a checkbox component with the expected parameters', () => {
|
|
@@ -159,11 +155,7 @@ describe('macro: mutually-exclusive', () => {
|
|
|
159
155
|
it('renders visually hidden "Or" label', () => {
|
|
160
156
|
const $ = cheerio.load(renderComponent('mutually-exclusive', EXAMPLE_MUTUALLY_EXCLUSIVE_RADIOS, FAKE_FIELD));
|
|
161
157
|
|
|
162
|
-
expect(
|
|
163
|
-
$('.ons-checkboxes__label')
|
|
164
|
-
.text()
|
|
165
|
-
.trim(),
|
|
166
|
-
).toBe('Or');
|
|
158
|
+
expect($('.ons-checkboxes__label').text().trim()).toBe('Or');
|
|
167
159
|
});
|
|
168
160
|
|
|
169
161
|
it('renders a radios component with the expected parameters', () => {
|