@ons/design-system 67.2.0 → 69.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 +5 -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.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 +6 -30
- 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/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/error/_macro.njk +1 -1
- package/components/error/_macro.spec.js +2 -6
- 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/helpers/grid.njk +15 -15
- package/components/icon/_macro.njk +7 -3
- package/components/icon/_macro.spec.js +4 -12
- 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/modal/_macro.spec.js +3 -9
- package/components/modal/modal.dom.js +1 -1
- package/components/modal/modal.spec.js +5 -5
- 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.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 +4 -5
- 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
|
@@ -2,7 +2,7 @@ import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
|
2
2
|
|
|
3
3
|
const EXAMPLE_INPUT_WITH_CHARACTER_CHECK = {
|
|
4
4
|
id: 'search-field',
|
|
5
|
-
|
|
5
|
+
variant: 'number',
|
|
6
6
|
width: '6',
|
|
7
7
|
label: {
|
|
8
8
|
text: 'Filter results',
|
|
@@ -24,7 +24,7 @@ const EXAMPLE_CHARACTER_CHECK_WITH_MUTUALLY_EXCLUSIVE = {
|
|
|
24
24
|
id: 'feedback',
|
|
25
25
|
name: 'feedback',
|
|
26
26
|
width: '30',
|
|
27
|
-
legend: '
|
|
27
|
+
legend: 'Feedback legend',
|
|
28
28
|
label: {
|
|
29
29
|
text: 'Enter your feedback',
|
|
30
30
|
},
|
|
@@ -59,12 +59,12 @@ describe('script: character-check', () => {
|
|
|
59
59
|
|
|
60
60
|
describe('Given that the char check helper has initialised correctly', () => {
|
|
61
61
|
it('the char check readout should be invisible', async () => {
|
|
62
|
-
const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
|
|
62
|
+
const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
|
|
63
63
|
expect(hasClass).toBe(true);
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
it('then the character limit readout should reflect the number of characters remaining', async () => {
|
|
67
|
-
const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
|
|
67
|
+
const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
|
|
68
68
|
expect(innerHtml.trim()).toBe('You have 11 characters remaining');
|
|
69
69
|
});
|
|
70
70
|
});
|
|
@@ -76,17 +76,17 @@ describe('script: character-check', () => {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
it('then the characters remaining readout reflect the number of characters remaining', async () => {
|
|
79
|
-
const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
|
|
79
|
+
const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
|
|
80
80
|
expect(innerHtml.trim()).toBe('You have 10 characters remaining');
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
it('the char check readout should be visible', async () => {
|
|
84
|
-
const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
|
|
84
|
+
const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
|
|
85
85
|
expect(hasClass).toBe(false);
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
it('then aria-live should be set to polite', async () => {
|
|
89
|
-
const ariaLiveAttribute = await page.$eval('#search-field-check', element => element.getAttribute('aria-live'));
|
|
89
|
+
const ariaLiveAttribute = await page.$eval('#search-field-check', (element) => element.getAttribute('aria-live'));
|
|
90
90
|
expect(ariaLiveAttribute).toBe('polite');
|
|
91
91
|
});
|
|
92
92
|
});
|
|
@@ -97,7 +97,7 @@ describe('script: character-check', () => {
|
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
it('the char check readout should be invisible', async () => {
|
|
100
|
-
const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
|
|
100
|
+
const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
|
|
101
101
|
expect(hasClass).toBe(true);
|
|
102
102
|
});
|
|
103
103
|
});
|
|
@@ -108,7 +108,7 @@ describe('script: character-check', () => {
|
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
it('then the characters remaining readout reflect the number of characters remaining', async () => {
|
|
111
|
-
const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
|
|
111
|
+
const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
|
|
112
112
|
expect(innerHtml.trim()).toBe('You have 1 character remaining');
|
|
113
113
|
});
|
|
114
114
|
});
|
|
@@ -120,24 +120,26 @@ describe('script: character-check', () => {
|
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
it('the char check readout should be visible', async () => {
|
|
123
|
-
const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
|
|
123
|
+
const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
|
|
124
124
|
expect(hasClass).toBe(false);
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
it('then the characters remaining readout reflect the number of characters exceeded', async () => {
|
|
128
|
-
const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
|
|
128
|
+
const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
|
|
129
129
|
expect(innerHtml.trim()).toBe('1 number too many');
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
it('then aria-live should be set to assertive', async () => {
|
|
133
|
-
const ariaLiveAttribute = await page.$eval('#search-field-check', element => element.getAttribute('aria-live'));
|
|
133
|
+
const ariaLiveAttribute = await page.$eval('#search-field-check', (element) => element.getAttribute('aria-live'));
|
|
134
134
|
expect(ariaLiveAttribute).toBe('assertive');
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
it('then the input and readout should be given limit reached classes', async () => {
|
|
138
|
-
const hasClassOnSearchInput = await page.$eval('#search-field', element =>
|
|
138
|
+
const hasClassOnSearchInput = await page.$eval('#search-field', (element) =>
|
|
139
|
+
element.classList.contains('ons-input--limit-reached'),
|
|
140
|
+
);
|
|
139
141
|
expect(hasClassOnSearchInput).toBe(true);
|
|
140
|
-
const hasClassOnLimitReadout = await page.$eval('#search-field-check', element =>
|
|
142
|
+
const hasClassOnLimitReadout = await page.$eval('#search-field-check', (element) =>
|
|
141
143
|
element.classList.contains('ons-input__limit--reached'),
|
|
142
144
|
);
|
|
143
145
|
expect(hasClassOnLimitReadout).toBe(true);
|
|
@@ -150,24 +152,26 @@ describe('script: character-check', () => {
|
|
|
150
152
|
});
|
|
151
153
|
|
|
152
154
|
it('the char check readout should be visible', async () => {
|
|
153
|
-
const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
|
|
155
|
+
const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
|
|
154
156
|
expect(hasClass).toBe(false);
|
|
155
157
|
});
|
|
156
158
|
|
|
157
159
|
it('then the characters remaining readout reflect the number of characters exceeded', async () => {
|
|
158
|
-
const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
|
|
160
|
+
const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
|
|
159
161
|
expect(innerHtml.trim()).toBe('2 numbers too many');
|
|
160
162
|
});
|
|
161
163
|
|
|
162
164
|
it('then aria-live should be set to assertive', async () => {
|
|
163
|
-
const ariaLiveAttribute = await page.$eval('#search-field-check', element => element.getAttribute('aria-live'));
|
|
165
|
+
const ariaLiveAttribute = await page.$eval('#search-field-check', (element) => element.getAttribute('aria-live'));
|
|
164
166
|
expect(ariaLiveAttribute).toBe('assertive');
|
|
165
167
|
});
|
|
166
168
|
|
|
167
169
|
it('then the input and readout should be given limit reached classes', async () => {
|
|
168
|
-
const hasClassOnSearchInput = await page.$eval('#search-field', element =>
|
|
170
|
+
const hasClassOnSearchInput = await page.$eval('#search-field', (element) =>
|
|
171
|
+
element.classList.contains('ons-input--limit-reached'),
|
|
172
|
+
);
|
|
169
173
|
expect(hasClassOnSearchInput).toBe(true);
|
|
170
|
-
const hasClassOnLimitReadout = await page.$eval('#search-field-check', element =>
|
|
174
|
+
const hasClassOnLimitReadout = await page.$eval('#search-field-check', (element) =>
|
|
171
175
|
element.classList.contains('ons-input__limit--reached'),
|
|
172
176
|
);
|
|
173
177
|
expect(hasClassOnLimitReadout).toBe(true);
|
|
@@ -188,7 +192,7 @@ describe('script: character-check', () => {
|
|
|
188
192
|
});
|
|
189
193
|
|
|
190
194
|
it('then aria-live attribute should removed', async () => {
|
|
191
|
-
const hasAriaLiveAttribute = await page.$eval('#feedback-lim', element => element.hasAttribute('aria-live'));
|
|
195
|
+
const hasAriaLiveAttribute = await page.$eval('#feedback-lim', (element) => element.hasAttribute('aria-live'));
|
|
192
196
|
expect(hasAriaLiveAttribute).toBe(false);
|
|
193
197
|
});
|
|
194
198
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
id="{{ params.id }}"
|
|
8
8
|
class="ons-checkbox__input ons-js-checkbox{{ ' ' + params.inputClasses if params.inputClasses else '' }}"
|
|
9
9
|
value="{{ params.value }}"
|
|
10
|
-
{% if params.disabled == true %}disabled aria-disabled="true"{%endif %}
|
|
10
|
+
{% if params.disabled == true %}disabled aria-disabled="true"{% endif %}
|
|
11
11
|
{% if params.name %} name="{{ params.name }}"{% endif %}
|
|
12
12
|
{% if params.checked %} checked{% endif %}
|
|
13
13
|
{% if params.other and not params.other.open %} aria-controls="{{ params.id }}-other-wrap" aria-haspopup="true"{% endif %}
|
|
@@ -24,7 +24,6 @@ $checkbox-padding: 11px;
|
|
|
24
24
|
// Check icon
|
|
25
25
|
&::after {
|
|
26
26
|
border: solid var(--ons-color-input-border);
|
|
27
|
-
border-radius: 1px;
|
|
28
27
|
border-top-color: var(--ons-color-input-bg);
|
|
29
28
|
border-width: 0 0 3px 3px;
|
|
30
29
|
box-sizing: border-box;
|
|
@@ -94,7 +93,6 @@ $checkbox-padding: 11px;
|
|
|
94
93
|
|
|
95
94
|
&:checked,
|
|
96
95
|
&:focus {
|
|
97
|
-
|
|
98
96
|
& + .ons-checkbox__label::before {
|
|
99
97
|
background: none;
|
|
100
98
|
border: none;
|
|
@@ -122,7 +120,6 @@ $checkbox-padding: 11px;
|
|
|
122
120
|
|
|
123
121
|
&:checked,
|
|
124
122
|
&:focus {
|
|
125
|
-
|
|
126
123
|
& + .ons-checkbox__label::before {
|
|
127
124
|
background: none;
|
|
128
125
|
border: none;
|
|
@@ -125,11 +125,7 @@ describe('macro: checkboxes', () => {
|
|
|
125
125
|
it('has the expected text', () => {
|
|
126
126
|
const $ = cheerio.load(renderComponent('checkboxes', EXAMPLE_CHECKBOXES));
|
|
127
127
|
|
|
128
|
-
expect(
|
|
129
|
-
$('.ons-checkboxes__label')
|
|
130
|
-
.text()
|
|
131
|
-
.trim(),
|
|
132
|
-
).toBe('Select all that apply');
|
|
128
|
+
expect($('.ons-checkboxes__label').text().trim()).toBe('Select all that apply');
|
|
133
129
|
});
|
|
134
130
|
|
|
135
131
|
it('has additionally provided `checkboxesLabelClasses`', () => {
|
|
@@ -6,7 +6,7 @@ export default class CheckboxWithAutoSelect {
|
|
|
6
6
|
this.insideReveal = insideReveal;
|
|
7
7
|
// Event listeners
|
|
8
8
|
this.button.addEventListener('click', this.handleButtonEvent.bind(this));
|
|
9
|
-
this.checkboxes.forEach(checkbox => checkbox.addEventListener('change', this.handleCheckboxEvent.bind(this)));
|
|
9
|
+
this.checkboxes.forEach((checkbox) => checkbox.addEventListener('change', this.handleCheckboxEvent.bind(this)));
|
|
10
10
|
if (this.insideReveal) {
|
|
11
11
|
this.insideReveal.addEventListener('change', this.handleCheckboxEvent.bind(this));
|
|
12
12
|
}
|
|
@@ -23,7 +23,7 @@ export default class CheckboxWithAutoSelect {
|
|
|
23
23
|
|
|
24
24
|
handleButtonEvent(event) {
|
|
25
25
|
event.preventDefault();
|
|
26
|
-
this.checkboxes.forEach(checkbox => {
|
|
26
|
+
this.checkboxes.forEach((checkbox) => {
|
|
27
27
|
checkbox.checked = this.allChecked === false ? true : false;
|
|
28
28
|
});
|
|
29
29
|
this.buttonText.innerHTML = this.allChecked === false ? this.unselectAllText : this.selectAllText;
|
|
@@ -31,7 +31,7 @@ export default class CheckboxWithAutoSelect {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
handleCheckboxEvent() {
|
|
34
|
-
const totalChecked = this.checkboxes.filter(checkbox => checkbox.checked).length;
|
|
34
|
+
const totalChecked = this.checkboxes.filter((checkbox) => checkbox.checked).length;
|
|
35
35
|
this.buttonText.innerHTML = totalChecked === this.numberOfCheckboxes ? this.unselectAllText : this.selectAllText;
|
|
36
36
|
this.allChecked = totalChecked === this.numberOfCheckboxes ? true : false;
|
|
37
37
|
}
|
|
@@ -13,14 +13,14 @@ export default class CheckboxWithFieldset {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
checkChildInputsOnSelect() {
|
|
16
|
-
this.childInputs.forEach(input => {
|
|
16
|
+
this.childInputs.forEach((input) => {
|
|
17
17
|
input.checked = this.selectAllChildrenInput.checked === true ? true : false;
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
uncheckChildInputsOnDeselect() {
|
|
22
22
|
if (this.checkbox.checked === false) {
|
|
23
|
-
this.childInputs.forEach(input => {
|
|
23
|
+
this.childInputs.forEach((input) => {
|
|
24
24
|
input.checked = false;
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export default class Checkboxes {
|
|
2
2
|
constructor(inputs) {
|
|
3
3
|
this.inputs = inputs;
|
|
4
|
-
this.inputs.forEach(input => input.addEventListener('change', this.setExpandedAttributes.bind(this)));
|
|
4
|
+
this.inputs.forEach((input) => input.addEventListener('change', this.setExpandedAttributes.bind(this)));
|
|
5
5
|
this.setExpandedAttributes();
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
setExpandedAttributes() {
|
|
9
|
-
this.inputs
|
|
9
|
+
this.inputs
|
|
10
|
+
.filter((input) => input.hasAttribute('aria-haspopup'))
|
|
11
|
+
.forEach((input) => input.setAttribute('aria-expanded', input.checked));
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -18,7 +18,7 @@ domready(async () => {
|
|
|
18
18
|
const otherFieldsets = [...document.querySelectorAll('.ons-js-other-fieldset-checkbox')];
|
|
19
19
|
if (otherFieldsets) {
|
|
20
20
|
const CheckboxWithInnerFieldset = (await import('./checkbox-with-fieldset')).default;
|
|
21
|
-
otherFieldsets.forEach(otherFieldset => {
|
|
21
|
+
otherFieldsets.forEach((otherFieldset) => {
|
|
22
22
|
const context = otherFieldset.closest('.ons-checkbox');
|
|
23
23
|
new CheckboxWithInnerFieldset(context);
|
|
24
24
|
});
|
|
@@ -27,7 +27,7 @@ domready(async () => {
|
|
|
27
27
|
const autoSelectButtons = [...document.querySelectorAll('.ons-js-auto-selector')];
|
|
28
28
|
if (autoSelectButtons) {
|
|
29
29
|
const CheckboxWithAutoSelect = (await import('./checkbox-with-autoselect')).default;
|
|
30
|
-
autoSelectButtons.forEach(button => {
|
|
30
|
+
autoSelectButtons.forEach((button) => {
|
|
31
31
|
const context = button.parentNode;
|
|
32
32
|
const insideReveal = context.parentNode.parentNode.querySelector('.ons-js-other');
|
|
33
33
|
new CheckboxWithAutoSelect(context, button, insideReveal);
|
|
@@ -47,12 +47,12 @@ describe('script: checkboxes', () => {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it('all checkboxes should be checked', async () => {
|
|
50
|
-
const checkedStates = await page.$$eval('.ons-js-checkbox', nodes => nodes.map(node => node.checked));
|
|
50
|
+
const checkedStates = await page.$$eval('.ons-js-checkbox', (nodes) => nodes.map((node) => node.checked));
|
|
51
51
|
expect(checkedStates).toEqual([true, true, true]);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
it('the button text should have changed', async () => {
|
|
55
|
-
const buttonText = await page.$eval('.ons-js-button-text', node => node.textContent);
|
|
55
|
+
const buttonText = await page.$eval('.ons-js-button-text', (node) => node.textContent);
|
|
56
56
|
expect(buttonText).toBe('Unselect all');
|
|
57
57
|
});
|
|
58
58
|
});
|
|
@@ -64,23 +64,23 @@ describe('script: checkboxes', () => {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
it('all checkboxes should be unchecked', async () => {
|
|
67
|
-
const checkedStates = await page.$$eval('.ons-js-checkbox', nodes => nodes.map(node => node.checked));
|
|
67
|
+
const checkedStates = await page.$$eval('.ons-js-checkbox', (nodes) => nodes.map((node) => node.checked));
|
|
68
68
|
expect(checkedStates).toEqual([false, false, false]);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
it('the button text should have changed', async () => {
|
|
72
|
-
const buttonText = await page.$eval('.ons-js-button-text', node => node.textContent);
|
|
72
|
+
const buttonText = await page.$eval('.ons-js-button-text', (node) => node.textContent);
|
|
73
73
|
expect(buttonText).toBe('Select all');
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
describe('when all except one checkbox is checked', () => {
|
|
78
78
|
beforeEach(async () => {
|
|
79
|
-
await page.$eval('#olives-other', node => (node.checked = true));
|
|
79
|
+
await page.$eval('#olives-other', (node) => (node.checked = true));
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
it('the button text should be select all', async () => {
|
|
83
|
-
const buttonText = await page.$eval('.ons-js-button-text', node => node.textContent);
|
|
83
|
+
const buttonText = await page.$eval('.ons-js-button-text', (node) => node.textContent);
|
|
84
84
|
expect(buttonText).toBe('Select all');
|
|
85
85
|
});
|
|
86
86
|
});
|
|
@@ -93,13 +93,13 @@ describe('script: checkboxes', () => {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
it('the button text should be unselect all', async () => {
|
|
96
|
-
const buttonText = await page.$eval('.ons-js-button-text', node => node.textContent);
|
|
96
|
+
const buttonText = await page.$eval('.ons-js-button-text', (node) => node.textContent);
|
|
97
97
|
expect(buttonText).toBe('Unselect all');
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
describe('reveal and fieldset', function() {
|
|
102
|
+
describe('reveal and fieldset', function () {
|
|
103
103
|
const params = {
|
|
104
104
|
legend: 'What are your favourite pizza toppings?',
|
|
105
105
|
checkboxesLabel: 'Select all that apply',
|
|
@@ -157,7 +157,7 @@ describe('script: checkboxes', () => {
|
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
it('checkboxes with other options should be given aria-expanded attributes', async () => {
|
|
160
|
-
const ariaExpanded = await page.$eval('#other-checkbox', node => node.getAttribute('aria-expanded'));
|
|
160
|
+
const ariaExpanded = await page.$eval('#other-checkbox', (node) => node.getAttribute('aria-expanded'));
|
|
161
161
|
expect(ariaExpanded).toBe('false');
|
|
162
162
|
});
|
|
163
163
|
|
|
@@ -167,7 +167,7 @@ describe('script: checkboxes', () => {
|
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
it('has aria-expanded attribute should be set to true', async () => {
|
|
170
|
-
const ariaExpanded = await page.$eval('#other-checkbox', node => node.getAttribute('aria-expanded'));
|
|
170
|
+
const ariaExpanded = await page.$eval('#other-checkbox', (node) => node.getAttribute('aria-expanded'));
|
|
171
171
|
expect(ariaExpanded).toBe('true');
|
|
172
172
|
});
|
|
173
173
|
|
|
@@ -177,7 +177,7 @@ describe('script: checkboxes', () => {
|
|
|
177
177
|
});
|
|
178
178
|
|
|
179
179
|
it('the checkbox with an other input aria-expanded attribute not change', async () => {
|
|
180
|
-
const ariaExpanded = await page.$eval('#other-checkbox', node => node.getAttribute('aria-expanded'));
|
|
180
|
+
const ariaExpanded = await page.$eval('#other-checkbox', (node) => node.getAttribute('aria-expanded'));
|
|
181
181
|
expect(ariaExpanded).toBe('true');
|
|
182
182
|
});
|
|
183
183
|
});
|
|
@@ -193,12 +193,12 @@ describe('script: checkboxes', () => {
|
|
|
193
193
|
});
|
|
194
194
|
|
|
195
195
|
it('its aria-expanded attribute should be set to false', async () => {
|
|
196
|
-
const ariaExpanded = await page.$eval('#other-checkbox', node => node.getAttribute('aria-expanded'));
|
|
196
|
+
const ariaExpanded = await page.$eval('#other-checkbox', (node) => node.getAttribute('aria-expanded'));
|
|
197
197
|
expect(ariaExpanded).toBe('false');
|
|
198
198
|
});
|
|
199
199
|
|
|
200
200
|
it('the child of other checkbox should be unchecked', async () => {
|
|
201
|
-
const innerInputChecked = await page.$eval('#inner-bacon-other', node => node.checked);
|
|
201
|
+
const innerInputChecked = await page.$eval('#inner-bacon-other', (node) => node.checked);
|
|
202
202
|
expect(innerInputChecked).toBe(false);
|
|
203
203
|
});
|
|
204
204
|
});
|
|
@@ -128,7 +128,7 @@ describe('macro: content-pagination', () => {
|
|
|
128
128
|
it('renders the provided `bridgingText`', () => {
|
|
129
129
|
const $ = cheerio.load(
|
|
130
130
|
renderComponent('content-pagination', {
|
|
131
|
-
contentPaginationItems: params.contentPaginationItems.map(item => ({
|
|
131
|
+
contentPaginationItems: params.contentPaginationItems.map((item) => ({
|
|
132
132
|
...item,
|
|
133
133
|
bridgingText: 'custom bridging text:',
|
|
134
134
|
})),
|
|
@@ -177,7 +177,7 @@ describe('macro: content-pagination', () => {
|
|
|
177
177
|
it('renders the provided `bridgingText`', () => {
|
|
178
178
|
const $ = cheerio.load(
|
|
179
179
|
renderComponent('content-pagination', {
|
|
180
|
-
contentPaginationItems: params.contentPaginationItems.map(item => ({
|
|
180
|
+
contentPaginationItems: params.contentPaginationItems.map((item) => ({
|
|
181
181
|
...item,
|
|
182
182
|
bridgingText: 'custom bridging text:',
|
|
183
183
|
})),
|
|
@@ -70,7 +70,7 @@ export default class CookiesBanner {
|
|
|
70
70
|
|
|
71
71
|
updateRadios(action) {
|
|
72
72
|
const radios = [...document.querySelectorAll('.ons-js-radio')];
|
|
73
|
-
radios.forEach(radio => {
|
|
73
|
+
radios.forEach((radio) => {
|
|
74
74
|
if (action == 'reject') {
|
|
75
75
|
radio.value == 'off' ? (radio.checked = true) : (radio.checked = false);
|
|
76
76
|
} else if (action == 'accept') {
|
|
@@ -11,7 +11,7 @@ describe('script: cookies-banner', () => {
|
|
|
11
11
|
it('should show the cookie banner', async () => {
|
|
12
12
|
await setTestPage('/test', EXAMPLE_COOKIES_BANNER_PAGE);
|
|
13
13
|
|
|
14
|
-
const displayStyle = await page.$eval('.ons-cookies-banner', node => window.getComputedStyle(node).getPropertyValue('display'));
|
|
14
|
+
const displayStyle = await page.$eval('.ons-cookies-banner', (node) => window.getComputedStyle(node).getPropertyValue('display'));
|
|
15
15
|
expect(displayStyle).toBe('block');
|
|
16
16
|
});
|
|
17
17
|
describe.each([
|
|
@@ -24,7 +24,7 @@ describe('script: cookies-banner', () => {
|
|
|
24
24
|
await page.click(`.ons-js-${action}-cookies`);
|
|
25
25
|
|
|
26
26
|
const cookies = await page.cookies();
|
|
27
|
-
const ons_cookie_policy = cookies.find(cookie => cookie.name === 'ons_cookie_policy');
|
|
27
|
+
const ons_cookie_policy = cookies.find((cookie) => cookie.name === 'ons_cookie_policy');
|
|
28
28
|
const policy = JSON.parse(ons_cookie_policy.value.replace(/'/g, '"'));
|
|
29
29
|
|
|
30
30
|
expect(policy).toEqual({
|
|
@@ -41,7 +41,7 @@ describe('script: cookies-banner', () => {
|
|
|
41
41
|
await page.click(`.ons-js-${action}-cookies`);
|
|
42
42
|
|
|
43
43
|
const cookies = await page.cookies();
|
|
44
|
-
const ons_cookie_message_displayed = cookies.find(cookie => cookie.name === 'ons_cookie_message_displayed');
|
|
44
|
+
const ons_cookie_message_displayed = cookies.find((cookie) => cookie.name === 'ons_cookie_message_displayed');
|
|
45
45
|
|
|
46
46
|
expect(ons_cookie_message_displayed.value).toBe('true');
|
|
47
47
|
});
|
|
@@ -51,7 +51,7 @@ describe('script: cookies-banner', () => {
|
|
|
51
51
|
|
|
52
52
|
await page.click(`.ons-js-${action}-cookies`);
|
|
53
53
|
|
|
54
|
-
const displayStyle = await page.$eval('.ons-cookies-banner__primary', node =>
|
|
54
|
+
const displayStyle = await page.$eval('.ons-cookies-banner__primary', (node) =>
|
|
55
55
|
window.getComputedStyle(node).getPropertyValue('display'),
|
|
56
56
|
);
|
|
57
57
|
expect(displayStyle).toBe('none');
|
|
@@ -62,7 +62,7 @@ describe('script: cookies-banner', () => {
|
|
|
62
62
|
|
|
63
63
|
await page.click(`.ons-js-${action}-cookies`);
|
|
64
64
|
|
|
65
|
-
const displayStyle = await page.$eval('.ons-cookies-banner__confirmation', node =>
|
|
65
|
+
const displayStyle = await page.$eval('.ons-cookies-banner__confirmation', (node) =>
|
|
66
66
|
window.getComputedStyle(node).getPropertyValue('display'),
|
|
67
67
|
);
|
|
68
68
|
expect(displayStyle).not.toBe('none');
|
|
@@ -76,7 +76,7 @@ describe('script: cookies-banner', () => {
|
|
|
76
76
|
await page.click('.ons-js-accept-cookies');
|
|
77
77
|
await page.click('.ons-js-hide-button');
|
|
78
78
|
|
|
79
|
-
const displayStyle = await page.$eval('.ons-cookies-banner', node => window.getComputedStyle(node).getPropertyValue('display'));
|
|
79
|
+
const displayStyle = await page.$eval('.ons-cookies-banner', (node) => window.getComputedStyle(node).getPropertyValue('display'));
|
|
80
80
|
expect(displayStyle).toBe('none');
|
|
81
81
|
});
|
|
82
82
|
});
|
|
@@ -87,7 +87,7 @@ describe('script: cookies-banner', () => {
|
|
|
87
87
|
|
|
88
88
|
await setTestPage('/test', EXAMPLE_COOKIES_BANNER_PAGE);
|
|
89
89
|
|
|
90
|
-
const displayStyle = await page.$eval('.ons-cookies-banner', node => window.getComputedStyle(node).getPropertyValue('display'));
|
|
90
|
+
const displayStyle = await page.$eval('.ons-cookies-banner', (node) => window.getComputedStyle(node).getPropertyValue('display'));
|
|
91
91
|
expect(displayStyle).toBe('none');
|
|
92
92
|
});
|
|
93
93
|
});
|
|
@@ -7,18 +7,18 @@ const EXAMPLE_DETAILS_BASIC = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
const EXAMPLE_PAGE = `
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
${renderComponent('details', {
|
|
11
|
+
id: 'details-id',
|
|
12
|
+
title: 'Title for details',
|
|
13
|
+
content: 'Content for details',
|
|
14
|
+
})}
|
|
15
|
+
|
|
16
|
+
${renderComponent('details', {
|
|
17
|
+
id: 'details-id-2',
|
|
18
|
+
title: 'Title for details',
|
|
19
|
+
content: 'Content for details',
|
|
20
|
+
})}
|
|
21
|
+
`;
|
|
22
22
|
|
|
23
23
|
const RENDERED_EXAMPLE_PAGE = renderTemplate(EXAMPLE_PAGE);
|
|
24
24
|
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
{% from "components/panel/_macro.njk" import onsPanel %}
|
|
3
3
|
|
|
4
4
|
{% call onsDetails({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
%}
|
|
5
|
+
"id": "details-example-with-warning",
|
|
6
|
+
"title": "Need to answer separately from your household?"
|
|
7
|
+
}) %}
|
|
9
8
|
|
|
10
9
|
<p>If you need to answer separately from the people you live with, you can <a href="#0">request an individual access code</a> to start a separate survey.</p>
|
|
11
10
|
{% call onsPanel({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
%}
|
|
11
|
+
"variant": "warn"
|
|
12
|
+
}) %}
|
|
15
13
|
Someone in your household must still complete a survey using a household access code
|
|
16
14
|
{% endcall %}
|
|
17
15
|
|
|
@@ -167,9 +167,7 @@ describe('macro: document list', () => {
|
|
|
167
167
|
|
|
168
168
|
it('has expected `title`', () => {
|
|
169
169
|
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_BASIC] }));
|
|
170
|
-
const title = $('.ons-document-list__item-title a')
|
|
171
|
-
.html()
|
|
172
|
-
.trim();
|
|
170
|
+
const title = $('.ons-document-list__item-title a').html().trim();
|
|
173
171
|
expect(title).toBe('Crime and justice');
|
|
174
172
|
});
|
|
175
173
|
|
|
@@ -180,9 +178,7 @@ describe('macro: document list', () => {
|
|
|
180
178
|
|
|
181
179
|
it('has expected `description`', () => {
|
|
182
180
|
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_BASIC] }));
|
|
183
|
-
const title = $('.ons-document-list__item-description')
|
|
184
|
-
.html()
|
|
185
|
-
.trim();
|
|
181
|
+
const title = $('.ons-document-list__item-description').html().trim();
|
|
186
182
|
expect(title).toBe('Some description');
|
|
187
183
|
});
|
|
188
184
|
});
|
|
@@ -244,9 +240,7 @@ describe('macro: document list', () => {
|
|
|
244
240
|
}),
|
|
245
241
|
);
|
|
246
242
|
|
|
247
|
-
const hiddenText = $('.ons-document-list__item-title a .ons-u-vh')
|
|
248
|
-
.text()
|
|
249
|
-
.trim();
|
|
243
|
+
const hiddenText = $('.ons-document-list__item-title a .ons-u-vh').text().trim();
|
|
250
244
|
expect(hiddenText).toBe(', PDF document download, 499KB, 1 page');
|
|
251
245
|
});
|
|
252
246
|
|
|
@@ -257,9 +251,7 @@ describe('macro: document list', () => {
|
|
|
257
251
|
}),
|
|
258
252
|
);
|
|
259
253
|
|
|
260
|
-
const hiddenText = $('.ons-document-list__item-attribute')
|
|
261
|
-
.text()
|
|
262
|
-
.trim();
|
|
254
|
+
const hiddenText = $('.ons-document-list__item-attribute').text().trim();
|
|
263
255
|
expect(hiddenText).toBe('PDF, 499KB, 1 page');
|
|
264
256
|
});
|
|
265
257
|
});
|
|
@@ -289,17 +281,13 @@ describe('macro: document list', () => {
|
|
|
289
281
|
|
|
290
282
|
it('has expected `text`', () => {
|
|
291
283
|
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE] }));
|
|
292
|
-
const text = $('.ons-document-list__attribute-link > span')
|
|
293
|
-
.text()
|
|
294
|
-
.trim();
|
|
284
|
+
const text = $('.ons-document-list__attribute-link > span').text().trim();
|
|
295
285
|
expect(text).toBe('Poster:');
|
|
296
286
|
});
|
|
297
287
|
|
|
298
288
|
it('has expected `ref`', () => {
|
|
299
289
|
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE] }));
|
|
300
|
-
const text = $('.ons-document-list__attribute-link + span')
|
|
301
|
-
.text()
|
|
302
|
-
.trim();
|
|
290
|
+
const text = $('.ons-document-list__attribute-link + span').text().trim();
|
|
303
291
|
expect(text).toBe('some ref');
|
|
304
292
|
});
|
|
305
293
|
});
|
|
@@ -343,9 +331,7 @@ describe('macro: document list', () => {
|
|
|
343
331
|
}),
|
|
344
332
|
);
|
|
345
333
|
|
|
346
|
-
const text = $('.ons-document-list__item-attribute > span')
|
|
347
|
-
.text()
|
|
348
|
-
.trim();
|
|
334
|
+
const text = $('.ons-document-list__item-attribute > span').text().trim();
|
|
349
335
|
expect(text).toBe('Published:');
|
|
350
336
|
});
|
|
351
337
|
|
|
@@ -386,9 +372,7 @@ describe('macro: document list', () => {
|
|
|
386
372
|
}),
|
|
387
373
|
);
|
|
388
374
|
|
|
389
|
-
const text = $('.ons-document-list__item-attribute > span')
|
|
390
|
-
.text()
|
|
391
|
-
.trim();
|
|
375
|
+
const text = $('.ons-document-list__item-attribute > span').text().trim();
|
|
392
376
|
expect(text).toBe('Released:');
|
|
393
377
|
});
|
|
394
378
|
|
|
@@ -449,9 +433,7 @@ describe('macro: document list', () => {
|
|
|
449
433
|
}),
|
|
450
434
|
);
|
|
451
435
|
|
|
452
|
-
const time = $('.ons-document-list__item-attribute time')
|
|
453
|
-
.text()
|
|
454
|
-
.trim();
|
|
436
|
+
const time = $('.ons-document-list__item-attribute time').text().trim();
|
|
455
437
|
expect(time).toBe('1 January 2022');
|
|
456
438
|
});
|
|
457
439
|
});
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
width: 100%;
|
|
63
63
|
|
|
64
64
|
&:focus {
|
|
65
|
-
background-color: var(--ons-color-placeholder) !important;
|
|
65
|
+
background-color: var(--ons-color-image-placeholder) !important;
|
|
66
66
|
border: 2px solid var(--ons-color-borders-document-image-focus);
|
|
67
67
|
box-shadow: none;
|
|
68
68
|
outline: 4px solid var(--ons-color-focus) !important;
|