@ons/design-system 68.0.0 → 68.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +6 -0
  2. package/components/access-code/_macro.njk +1 -1
  3. package/components/access-code/_macro.spec.js +2 -10
  4. package/components/access-code/access-code.dom.js +1 -1
  5. package/components/access-code/access-code.spec.js +2 -2
  6. package/components/access-code/example-access-code-error.njk +9 -14
  7. package/components/access-code/example-access-code.njk +3 -5
  8. package/components/accordion/accordion.js +4 -4
  9. package/components/address-input/_macro.spec.js +3 -15
  10. package/components/address-input/autosuggest.address.dom.js +1 -1
  11. package/components/address-input/autosuggest.address.js +3 -2
  12. package/components/address-input/autosuggest.address.setter.js +3 -3
  13. package/components/address-input/autosuggest.address.spec.js +66 -69
  14. package/components/address-output/_macro.spec.js +6 -30
  15. package/components/autosuggest/_autosuggest.scss +1 -1
  16. package/components/autosuggest/autosuggest.dom.js +1 -1
  17. package/components/autosuggest/autosuggest.helpers.js +1 -1
  18. package/components/back-to-top/_back-to-top.scss +34 -0
  19. package/components/back-to-top/_macro.njk +17 -0
  20. package/components/back-to-top/_macro.spec.js +60 -0
  21. package/components/back-to-top/back-to-top.dom.js +12 -0
  22. package/components/back-to-top/back-to-top.js +58 -0
  23. package/components/back-to-top/back-to-top.spec.js +117 -0
  24. package/components/back-to-top/example-back-to-top.njk +37 -0
  25. package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
  26. package/components/browser-banner/_macro.spec.js +4 -12
  27. package/components/button/_macro.njk +6 -6
  28. package/components/button/_macro.spec.js +1 -5
  29. package/components/button/button.js +7 -8
  30. package/components/button/button.spec.js +17 -39
  31. package/components/call-to-action/_macro.spec.js +2 -6
  32. package/components/card/_macro.njk +25 -25
  33. package/components/card/_macro.spec.js +10 -34
  34. package/components/char-check-limit/_macro.njk +1 -1
  35. package/components/char-check-limit/_macro.spec.js +3 -7
  36. package/components/char-check-limit/character-check.spec.js +24 -20
  37. package/components/checkboxes/_checkbox-macro.njk +1 -1
  38. package/components/checkboxes/_checkbox.scss +0 -3
  39. package/components/checkboxes/_macro.spec.js +1 -5
  40. package/components/checkboxes/checkbox-with-autoselect.js +3 -3
  41. package/components/checkboxes/checkbox-with-fieldset.js +2 -2
  42. package/components/checkboxes/checkboxes-with-reveal.js +4 -2
  43. package/components/checkboxes/checkboxes.dom.js +2 -2
  44. package/components/checkboxes/checkboxes.spec.js +13 -13
  45. package/components/content-pagination/_macro.spec.js +2 -2
  46. package/components/cookies-banner/cookies-banner.dom.js +1 -1
  47. package/components/cookies-banner/cookies-banner.js +1 -1
  48. package/components/cookies-banner/cookies-banner.spec.js +7 -7
  49. package/components/date-input/_macro.njk +71 -69
  50. package/components/date-input/_macro.spec.js +20 -5
  51. package/components/date-input/example-date-input-double-field.njk +27 -0
  52. package/components/date-input/example-date-input-single-field.njk +18 -0
  53. package/components/details/details.spec.js +12 -12
  54. package/components/details/example-details-with-warning.njk +5 -7
  55. package/components/document-list/_macro.spec.js +9 -27
  56. package/components/document-list/document-list.scss +1 -1
  57. package/components/document-list/example-document-list-downloads.njk +3 -3
  58. package/components/document-list/example-document-list-search-result-featured.njk +1 -1
  59. package/components/document-list/example-document-list-search-results.njk +3 -3
  60. package/components/download-resources/download-resources.js +54 -54
  61. package/components/download-resources/download-resources.spec.js +3 -1
  62. package/components/duration/_macro.njk +52 -48
  63. package/components/duration/_macro.spec.js +112 -4
  64. package/components/duration/example-duration-error-for-single-field.njk +1 -1
  65. package/components/duration/example-duration-single-field.njk +24 -0
  66. package/components/error/_macro.njk +1 -1
  67. package/components/error/_macro.spec.js +2 -6
  68. package/components/feedback/_macro.njk +1 -1
  69. package/components/feedback/_macro.spec.js +4 -20
  70. package/components/field/_field-group.scss +3 -4
  71. package/components/field/_macro.spec.js +1 -3
  72. package/components/fieldset/_fieldset.scss +1 -2
  73. package/components/fieldset/_macro.spec.js +3 -9
  74. package/components/footer/_footer.scss +8 -0
  75. package/components/footer/_macro.njk +8 -7
  76. package/components/footer/_macro.spec.js +14 -2
  77. package/components/header/_macro.njk +1 -1
  78. package/components/header/_macro.spec.js +1 -1
  79. package/components/helpers/grid.njk +15 -15
  80. package/components/icon/_macro.njk +17 -13
  81. package/components/icon/_macro.spec.js +8 -16
  82. package/components/image/_macro.spec.js +1 -5
  83. package/components/input/_macro.njk +22 -23
  84. package/components/input/_macro.spec.js +1 -1
  85. package/components/input/character-check.dom.js +1 -1
  86. package/components/input/input.spec.js +1 -4
  87. package/components/label/_label.scss +1 -0
  88. package/components/label/_macro.njk +3 -3
  89. package/components/label/_macro.spec.js +4 -13
  90. package/components/list/_macro.spec.js +4 -12
  91. package/components/message/_macro.njk +17 -17
  92. package/components/message/_macro.spec.js +9 -33
  93. package/components/message-list/_macro.spec.js +7 -39
  94. package/components/metadata/_macro.njk +10 -10
  95. package/components/modal/_macro.spec.js +3 -9
  96. package/components/modal/modal.dom.js +1 -1
  97. package/components/modal/modal.spec.js +5 -5
  98. package/components/multiple-input-fields/_macro.njk +49 -0
  99. package/components/mutually-exclusive/_macro.spec.js +2 -10
  100. package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
  101. package/components/mutually-exclusive/mutually-exclusive.date.spec.js +128 -14
  102. package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
  103. package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +129 -8
  104. package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
  105. package/components/mutually-exclusive/mutually-exclusive.js +13 -13
  106. package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
  107. package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
  108. package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
  109. package/components/navigation/navigation.spec.js +0 -2
  110. package/components/pagination/_macro.spec.js +11 -53
  111. package/components/panel/_macro.njk +17 -17
  112. package/components/panel/_macro.spec.js +25 -25
  113. package/components/panel/_panel.scss +10 -9
  114. package/components/panel/example-panel-bare.njk +3 -4
  115. package/components/panel/example-panel-with-announcement.njk +6 -10
  116. package/components/panel/example-panel-with-error-summary.njk +2 -2
  117. package/components/panel/example-panel-with-information.njk +0 -1
  118. package/components/panel/example-panel-with-success-message.njk +1 -1
  119. package/components/panel/example-panel-with-warning.njk +2 -3
  120. package/components/password/password.dom.js +1 -1
  121. package/components/phase-banner/_macro.spec.js +3 -9
  122. package/components/question/_macro.njk +1 -1
  123. package/components/question/_macro.spec.js +5 -19
  124. package/components/question/_question.scss +1 -4
  125. package/components/question/example-question-interviewer-note.njk +1 -1
  126. package/components/quote/_macro.spec.js +2 -10
  127. package/components/radios/clear-radios.js +3 -3
  128. package/components/radios/radio-with-fieldset.js +4 -4
  129. package/components/radios/radios.dom.js +1 -1
  130. package/components/radios/radios.spec.js +26 -26
  131. package/components/related-content/_macro.spec.js +2 -4
  132. package/components/related-content/_section-macro.spec.js +2 -8
  133. package/components/relationships/example-relationships-error.njk +16 -18
  134. package/components/relationships/relationships.dom.js +1 -1
  135. package/components/relationships/relationships.js +2 -2
  136. package/components/reply/_macro.spec.js +3 -3
  137. package/components/reply/reply.dom.js +1 -1
  138. package/components/reply/reply.spec.js +3 -3
  139. package/components/section-navigation/_macro.njk +12 -12
  140. package/components/section-navigation/_macro.spec.js +13 -21
  141. package/components/select/_macro.spec.js +6 -6
  142. package/components/share-page/_macro.spec.js +6 -14
  143. package/components/skip-to-content/_macro.spec.js +3 -11
  144. package/components/skip-to-content/skip-to-content.dom.js +1 -1
  145. package/components/skip-to-content/skip-to-content.js +1 -1
  146. package/components/skip-to-content/skip-to-content.spec.js +2 -2
  147. package/components/status/_macro.njk +2 -2
  148. package/components/status/_macro.spec.js +5 -9
  149. package/components/status/example-status-dead.njk +1 -1
  150. package/components/status/example-status-error.njk +1 -1
  151. package/components/status/example-status-pending.njk +1 -1
  152. package/components/status/example-status-small.njk +1 -1
  153. package/components/status/example-status-success.njk +1 -1
  154. package/components/summary/_macro.njk +7 -8
  155. package/components/summary/_macro.spec.js +27 -9
  156. package/components/table/_macro.spec.js +6 -10
  157. package/components/table/scrollable-table.dom.js +1 -1
  158. package/components/table/scrollable-table.js +1 -1
  159. package/components/table/sortable-table.js +4 -4
  160. package/components/table/table.spec.js +21 -17
  161. package/components/table-of-contents/_macro.njk +31 -31
  162. package/components/table-of-contents/_macro.spec.js +3 -11
  163. package/components/table-of-contents/toc.dom.js +1 -1
  164. package/components/table-of-contents/toc.spec.js +36 -32
  165. package/components/tabs/example-tabs-details.njk +1 -1
  166. package/components/tabs/tabs.dom.js +1 -1
  167. package/components/tabs/tabs.js +8 -8
  168. package/components/text-indent/_macro.spec.js +2 -6
  169. package/components/textarea/textarea.dom.js +1 -1
  170. package/components/textarea/textarea.spec.js +8 -8
  171. package/components/timeout-modal/_macro.spec.js +1 -3
  172. package/components/timeout-modal/timeout-modal.dom.js +1 -1
  173. package/components/timeout-modal/timeout-modal.spec.js +10 -10
  174. package/components/timeout-panel/_macro.njk +16 -17
  175. package/components/timeout-panel/_macro.spec.js +1 -1
  176. package/components/timeout-panel/timeout-panel.dom.js +1 -1
  177. package/components/timeout-panel/timeout-panel.spec.js +8 -8
  178. package/components/video/_macro.spec.js +1 -5
  179. package/components/video/video.dom.js +1 -1
  180. package/components/video/video.spec.js +16 -12
  181. package/css/main.css +1 -1
  182. package/favicons/safari-pinned-tab.svg +23 -23
  183. package/js/analytics.js +15 -14
  184. package/js/cookies-settings.dom.js +1 -1
  185. package/js/cookies-settings.spec.js +19 -19
  186. package/js/domready.js +1 -1
  187. package/js/fetch.js +1 -1
  188. package/js/inpagelink.js +3 -3
  189. package/js/main.js +1 -0
  190. package/js/print-button.js +1 -1
  191. package/js/timeout.js +1 -1
  192. package/package.json +2 -1
  193. package/scripts/main.es5.js +1 -1
  194. package/scripts/main.js +1 -1
  195. package/scss/base/_typography.scss +8 -2
  196. package/scss/main.scss +1 -0
  197. package/scss/overrides/hcm.scss +8 -1
  198. package/scss/vars/_colors.scss +2 -1
  199. package/components/date-field-input/_macro.njk +0 -86
@@ -64,14 +64,14 @@ describe('script: radios', () => {
64
64
  });
65
65
 
66
66
  it('radios with other options should be given aria-expanded attributes', async () => {
67
- const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
67
+ const ariaExpandedOption1 = await page.$eval('#email', (node) => node.getAttribute('aria-expanded'));
68
68
  expect(ariaExpandedOption1).toBe('false');
69
- const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
69
+ const ariaExpandedOption2 = await page.$eval('#phone', (node) => node.getAttribute('aria-expanded'));
70
70
  expect(ariaExpandedOption2).toBe('false');
71
71
  });
72
72
 
73
73
  it('radios with "open" other options should not be given aria-expanded attributes', async () => {
74
- const hasAriaExpandedOption3 = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
74
+ const hasAriaExpandedOption3 = await page.$eval('#text', (node) => node.hasAttribute('aria-expanded'));
75
75
  expect(hasAriaExpandedOption3).toBe(false);
76
76
  });
77
77
 
@@ -81,27 +81,27 @@ describe('script: radios', () => {
81
81
  });
82
82
 
83
83
  it('then the checked radio aria-expanded attribute should be set to true', async () => {
84
- const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
84
+ const ariaExpandedOption1 = await page.$eval('#email', (node) => node.getAttribute('aria-expanded'));
85
85
  expect(ariaExpandedOption1).toBe('true');
86
86
  });
87
87
 
88
88
  it('then the unchecked radio aria-expanded attribute should be set to false', async () => {
89
- const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
89
+ const ariaExpandedOption2 = await page.$eval('#phone', (node) => node.getAttribute('aria-expanded'));
90
90
  expect(ariaExpandedOption2).toBe('false');
91
91
  });
92
92
 
93
93
  it('then the unchecked radio aria-expanded attribute of "open" radio should not be set', async () => {
94
- const hasAriaExpanded = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
94
+ const hasAriaExpanded = await page.$eval('#text', (node) => node.hasAttribute('aria-expanded'));
95
95
  expect(hasAriaExpanded).toBe(false);
96
96
  });
97
97
 
98
98
  it('then the clear button should be visible', async () => {
99
- const isHidden = await page.$eval('.ons-js-clear-btn', node => node.classList.contains('ons-u-db-no-js_enabled'));
99
+ const isHidden = await page.$eval('.ons-js-clear-btn', (node) => node.classList.contains('ons-u-db-no-js_enabled'));
100
100
  expect(isHidden).toBe(false);
101
101
  });
102
102
 
103
103
  it('then the aria live message should announce that the answer can be cleared', async () => {
104
- const alertText = await page.$eval('.ons-js-clear-radio-alert', node => node.innerHTML);
104
+ const alertText = await page.$eval('.ons-js-clear-radio-alert', (node) => node.innerHTML);
105
105
  expect(alertText).toBe('You can clear your answer by clicking the clear selection button under the radio buttons');
106
106
  });
107
107
 
@@ -111,17 +111,17 @@ describe('script: radios', () => {
111
111
  });
112
112
 
113
113
  it('then the checked radio aria-expanded attribute should be set to true', async () => {
114
- const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
114
+ const ariaExpandedOption2 = await page.$eval('#phone', (node) => node.getAttribute('aria-expanded'));
115
115
  expect(ariaExpandedOption2).toBe('true');
116
116
  });
117
117
 
118
118
  it('then the unchecked radio aria-expanded attribute should be set to false', async () => {
119
- const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
119
+ const ariaExpandedOption1 = await page.$eval('#email', (node) => node.getAttribute('aria-expanded'));
120
120
  expect(ariaExpandedOption1).toBe('false');
121
121
  });
122
122
 
123
123
  it('then the unchecked radio aria-expanded attribute of "open" radio should not be set', async () => {
124
- const hasAriaExpanded = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
124
+ const hasAriaExpanded = await page.$eval('#text', (node) => node.hasAttribute('aria-expanded'));
125
125
  expect(hasAriaExpanded).toBe(false);
126
126
  });
127
127
  });
@@ -129,30 +129,30 @@ describe('script: radios', () => {
129
129
 
130
130
  describe('the clear button is clicked', () => {
131
131
  beforeEach(async () => {
132
- await page.$eval('.ons-js-clear-btn', node => node.click());
132
+ await page.$eval('.ons-js-clear-btn', (node) => node.click());
133
133
  });
134
134
 
135
135
  it('then the clear button should not be visible', async () => {
136
- const isHidden = await page.$eval('.ons-js-clear-btn', node => node.classList.contains('ons-u-db-no-js_enabled'));
136
+ const isHidden = await page.$eval('.ons-js-clear-btn', (node) => node.classList.contains('ons-u-db-no-js_enabled'));
137
137
  expect(isHidden).toBe(true);
138
138
  });
139
139
 
140
140
  it('then the aria live message should announce that the answer has been cleared', async () => {
141
- const alertText = await page.$eval('.ons-js-clear-radio-alert', node => node.innerHTML);
141
+ const alertText = await page.$eval('.ons-js-clear-radio-alert', (node) => node.innerHTML);
142
142
  expect(alertText).toBe('You have cleared your answer');
143
143
  });
144
144
 
145
145
  it('then all radios should not be checked', async () => {
146
- const checkedRadios = await page.$$eval('.ons-js-radio', nodes => nodes.map(node => node.checked));
146
+ const checkedRadios = await page.$$eval('.ons-js-radio', (nodes) => nodes.map((node) => node.checked));
147
147
  expect(checkedRadios).not.toContain(true);
148
148
  });
149
149
 
150
150
  it('then all other input fields should be empty', async () => {
151
- const emailOtherValue = await page.$eval('#email-other', node => node.value);
151
+ const emailOtherValue = await page.$eval('#email-other', (node) => node.value);
152
152
  expect(emailOtherValue).toBe('');
153
- const telOtherValue = await page.$eval('#tel-other', node => node.value);
153
+ const telOtherValue = await page.$eval('#tel-other', (node) => node.value);
154
154
  expect(telOtherValue).toBe('');
155
- const textOtherValue = await page.$eval('#text-other', node => node.value);
155
+ const textOtherValue = await page.$eval('#text-other', (node) => node.value);
156
156
  expect(textOtherValue).toBe('');
157
157
  });
158
158
  });
@@ -163,7 +163,7 @@ describe('script: radios', () => {
163
163
  });
164
164
 
165
165
  it('then the radio button should be checked', async () => {
166
- const isRadioChecked = await page.$eval('#text', node => node.checked);
166
+ const isRadioChecked = await page.$eval('#text', (node) => node.checked);
167
167
  expect(isRadioChecked).toBe(true);
168
168
  });
169
169
  });
@@ -174,13 +174,13 @@ describe('script: radios', () => {
174
174
  });
175
175
 
176
176
  it('then the input should have a tab index of 0', async () => {
177
- const tabIndex = await page.$eval('#text-other', node => node.getAttribute('tabindex'));
177
+ const tabIndex = await page.$eval('#text-other', (node) => node.getAttribute('tabindex'));
178
178
  expect(tabIndex).toBe('0');
179
179
  });
180
180
  });
181
181
  });
182
182
 
183
- describe('reveal and fieldset', function() {
183
+ describe('reveal and fieldset', function () {
184
184
  const params = {
185
185
  legend: 'What are your favourite pizza toppings?',
186
186
  name: 'food-other',
@@ -237,7 +237,7 @@ describe('script: radios', () => {
237
237
  });
238
238
 
239
239
  it('radios with other options should be given aria-expanded attributes', async () => {
240
- const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
240
+ const ariaExpanded = await page.$eval('#other-radio', (node) => node.getAttribute('aria-expanded'));
241
241
  expect(ariaExpanded).toBe('false');
242
242
  });
243
243
 
@@ -247,7 +247,7 @@ describe('script: radios', () => {
247
247
  });
248
248
 
249
249
  it('has aria-expanded attribute should be set to true', async () => {
250
- const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
250
+ const ariaExpanded = await page.$eval('#other-radio', (node) => node.getAttribute('aria-expanded'));
251
251
  expect(ariaExpanded).toBe('true');
252
252
  });
253
253
 
@@ -257,7 +257,7 @@ describe('script: radios', () => {
257
257
  });
258
258
 
259
259
  it('the radio with an other input aria-expanded attribute changes', async () => {
260
- const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
260
+ const ariaExpanded = await page.$eval('#other-radio', (node) => node.getAttribute('aria-expanded'));
261
261
  expect(ariaExpanded).toBe('false');
262
262
  });
263
263
  });
@@ -273,12 +273,12 @@ describe('script: radios', () => {
273
273
  });
274
274
 
275
275
  it('the other radio aria-expanded attribute should be set to false', async () => {
276
- const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
276
+ const ariaExpanded = await page.$eval('#other-radio', (node) => node.getAttribute('aria-expanded'));
277
277
  expect(ariaExpanded).toBe('false');
278
278
  });
279
279
 
280
280
  it('the child of other checkbox should be unchecked', async () => {
281
- const innerInputChecked = await page.$eval('#inner-bacon-other', node => node.checked);
281
+ const innerInputChecked = await page.$eval('#inner-bacon-other', (node) => node.checked);
282
282
  expect(innerInputChecked).toBe(false);
283
283
  });
284
284
  });
@@ -82,9 +82,7 @@ describe('macro: related-content', () => {
82
82
  it('calls with content', () => {
83
83
  const $ = cheerio.load(renderComponent('related-content', { EXAMPLE_RELATED_CONTENT_GENERAL }, 'Example content...'));
84
84
 
85
- const content = $('.ons-related-content')
86
- .text()
87
- .trim();
85
+ const content = $('.ons-related-content').text().trim();
88
86
  expect(content).toEqual(expect.stringContaining('Example content...'));
89
87
  });
90
88
  });
@@ -105,7 +103,7 @@ describe('macro: related-content', () => {
105
103
  it('has the `aria-labelledby` attribute for each section of links', () => {
106
104
  const $ = cheerio.load(renderComponent('related-content', EXAMPLE_RELATED_CONTENT_LINKS));
107
105
 
108
- const values = mapAll($('.ons-related-content__navigation'), node => node.attr('aria-labelledby'));
106
+ const values = mapAll($('.ons-related-content__navigation'), (node) => node.attr('aria-labelledby'));
109
107
  expect(values).toEqual(['related-articles', 'related-links']);
110
108
  });
111
109
 
@@ -20,11 +20,7 @@ describe('macro: related-content/section', () => {
20
20
 
21
21
  it('has the provided `title` text', () => {
22
22
  const $ = cheerio.load(renderComponent('related-content/section', EXAMPLE_RELATED_SECTION_CONTENT));
23
- expect(
24
- $('.ons-related-content__title')
25
- .text()
26
- .trim(),
27
- ).toEqual('Related information');
23
+ expect($('.ons-related-content__title').text().trim()).toEqual('Related information');
28
24
  });
29
25
 
30
26
  it('has the `id` attribute for the title', () => {
@@ -35,9 +31,7 @@ describe('macro: related-content/section', () => {
35
31
  it('has the provided content', () => {
36
32
  const $ = cheerio.load(renderComponent('related-content/section', { EXAMPLE_RELATED_SECTION_CONTENT }, 'Example content...'));
37
33
 
38
- const content = $('.ons-related-content__content')
39
- .text()
40
- .trim();
34
+ const content = $('.ons-related-content__content').text().trim();
41
35
  expect(content).toEqual(expect.stringContaining('Example content...'));
42
36
  });
43
37
  });
@@ -25,24 +25,22 @@ layout: ~
25
25
 
26
26
  {% block main %}
27
27
 
28
- {% call
29
- onsPanel({
30
- title: "There is a problem with your answer",
31
- type: "error"
32
- })
33
- %}
34
- {{
35
- onsList({
36
- "element": "ol",
37
- "itemsList": [
38
- {
39
- "text": "Select a relationship",
40
- "url": "#relationship-error",
41
- "variants": "inPageLink"
42
- }
43
- ]
44
- })
45
- }}
28
+ {% call onsPanel({
29
+ "title": "There is a problem with your answer",
30
+ "variant": "error"
31
+ }) %}
32
+ {{
33
+ onsList({
34
+ "element": "ol",
35
+ "itemsList": [
36
+ {
37
+ "text": "Select a relationship",
38
+ "url": "#relationship-error",
39
+ "variants": "inPageLink"
40
+ }
41
+ ]
42
+ })
43
+ }}
46
44
  {% endcall %}
47
45
  {% call onsQuestion({
48
46
  "title": "Thinking of Joe Bloggs, Amanda Bloggs is their <strong>…</strong>",
@@ -6,6 +6,6 @@ domready(async () => {
6
6
  if (relationships.length) {
7
7
  const Relationships = (await import('./relationships')).default;
8
8
 
9
- relationships.forEach(element => new Relationships(element));
9
+ relationships.forEach((element) => new Relationships(element));
10
10
  }
11
11
  });
@@ -7,7 +7,7 @@ export default class Relationships {
7
7
  this.radios = [...context.querySelectorAll('input[type=radio]')];
8
8
  this.playback = context.querySelector('.ons-js-relationships-playback');
9
9
 
10
- this.radios.forEach(radio => radio.addEventListener('change', this.setPlayback.bind(this)));
10
+ this.radios.forEach((radio) => radio.addEventListener('change', this.setPlayback.bind(this)));
11
11
 
12
12
  this.setPlayback();
13
13
 
@@ -15,7 +15,7 @@ export default class Relationships {
15
15
  }
16
16
 
17
17
  setPlayback() {
18
- const radio = this.radios.find(radio => radio.checked);
18
+ const radio = this.radios.find((radio) => radio.checked);
19
19
 
20
20
  if (radio) {
21
21
  const title = radio.getAttribute('data-title');
@@ -13,9 +13,9 @@ const EXAMPLE_TEXTAREA = {
13
13
  description: 'Reply description',
14
14
  },
15
15
  charCheckLimit: {
16
- limit: 300,
17
- charCountSingular: '{x} more character needed',
18
- charCountPlural: '{x} more characters needed',
16
+ limit: 300,
17
+ charCountSingular: '{x} more character needed',
18
+ charCountPlural: '{x} more characters needed',
19
19
  },
20
20
  rows: 5,
21
21
  };
@@ -6,7 +6,7 @@ async function initialise() {
6
6
  if (replyInputs.length) {
7
7
  const ReplyInput = (await import('./reply-input')).default;
8
8
 
9
- replyInputs.forEach(input => new ReplyInput(input));
9
+ replyInputs.forEach((input) => new ReplyInput(input));
10
10
  }
11
11
  }
12
12
 
@@ -29,7 +29,7 @@ describe('script: reply', () => {
29
29
 
30
30
  it('the button has classes applied', async () => {
31
31
  await setTestPage('/test', renderComponent('reply', EXAMPLE_REPLY));
32
- const disabledButton = await page.$eval('#reply-button', element => element.classList.contains('ons-btn--disabled'));
32
+ const disabledButton = await page.$eval('#reply-button', (element) => element.classList.contains('ons-btn--disabled'));
33
33
  expect(disabledButton).toBe(true);
34
34
  });
35
35
  });
@@ -49,7 +49,7 @@ describe('script: reply', () => {
49
49
  await page.focus('#reply-textarea');
50
50
  await page.keyboard.type('Sausages');
51
51
 
52
- const disabledButton = await page.$eval('#reply-button', element => element.classList.contains('ons-btn--disabled'));
52
+ const disabledButton = await page.$eval('#reply-button', (element) => element.classList.contains('ons-btn--disabled'));
53
53
  expect(disabledButton).toBe(false);
54
54
  });
55
55
  });
@@ -71,7 +71,7 @@ describe('script: reply', () => {
71
71
  await page.keyboard.type('s');
72
72
  await page.keyboard.press('Backspace');
73
73
 
74
- const disabledButton = await page.$eval('#reply-button', element => element.classList.contains('ons-btn--disabled'));
74
+ const disabledButton = await page.$eval('#reply-button', (element) => element.classList.contains('ons-btn--disabled'));
75
75
  expect(disabledButton).toBe(true);
76
76
  });
77
77
  });
@@ -1,11 +1,11 @@
1
1
  {% macro onsSectionNavigation(params) %}
2
- {% set headingLevel = params.headingLevel | int | default(2) %}
3
- {% set sectionTitleHeadingLevel = headingLevel + 1 %}
2
+ {% set headingLevel = params.headingLevel | default(2) %}
3
+ {% set sectionTitleHeadingLevel = headingLevel + 1 %}
4
4
  <nav class="ons-section-nav{% if params.variants == 'vertical' %} ons-section-nav--vertical{% endif %} {% if params.classes %} {{ params.classes }} {% endif %}"{% if params.id %} id="{{ params.id }}"{% endif %} aria-labelledby="{{ params.hiddenTitleId | default("section-menu-nav-title")}}">
5
- <h{{ headingLevel }} class="ons-u-vh" id="{{ params.hiddenTitleId | default("section-menu-nav-title") }}">{{ params.hiddenTitle | default("Pages in this section") }}</h{{ headingLevel }}>
5
+ <h{{ headingLevel }} class="ons-u-vh" id="{{ params.hiddenTitleId | default("section-menu-nav-title") }}">{{ params.hiddenTitle | default("Pages in this section") }}</h{{ headingLevel }}>
6
6
  {% if params.sections %}
7
7
  {% for section in params.sections %}
8
- {% set sectionItemHeadingLevel = headingLevel + 2 if section.title else headingLevel + 1 %}
8
+ {% set sectionItemHeadingLevel = headingLevel + 2 if section.title else headingLevel + 1 %}
9
9
  <div class="ons-section-nav__sub">
10
10
  {% if section.title %}
11
11
  <h{{ sectionTitleHeadingLevel }} class="ons-u-fs-r--b ons-u-mb-s">{{ section.title }}</h{{ sectionTitleHeadingLevel }}>
@@ -18,12 +18,12 @@
18
18
  {% set isCurrent = false %}
19
19
  {% endif %}
20
20
  <li class="ons-section-nav__item{% if item.classes %}{{ ' ' + item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
21
- {% if isCurrent == true %}
22
- <h{{ sectionItemHeadingLevel }} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ sectionItemHeadingLevel }}>
23
- {% else %}
24
- <a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
25
- {% endif %}
26
- {% if item.anchors and isCurrent == true %}
21
+ {% if isCurrent == true %}
22
+ <h{{ sectionItemHeadingLevel }} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ sectionItemHeadingLevel }}>
23
+ {% else %}
24
+ <a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
25
+ {% endif %}
26
+ {% if item.anchors and isCurrent == true %}
27
27
  <ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
28
28
  {% for anchor in item.anchors %}
29
29
  <li class="ons-section-nav__item ons-list__item">
@@ -43,7 +43,7 @@
43
43
  {% endif %}
44
44
  <ul class="ons-section-nav__list">
45
45
  {% for item in params.itemsList %}
46
- {% set sectionItemHeadingLevel = headingLevel + 2 if params.title else headingLevel + 1 %}
46
+ {% set sectionItemHeadingLevel = headingLevel + 2 if params.title else headingLevel + 1 %}
47
47
  {% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.title|lower) %}
48
48
  {% set isCurrent = true %}
49
49
  {% else %}
@@ -51,7 +51,7 @@
51
51
  {% endif %}
52
52
  <li class="ons-section-nav__item{% if item.classes %}{{ ' ' + item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
53
53
  {% if isCurrent == true %}
54
- <h{{ sectionItemHeadingLevel}} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ headingLevel + 2 if section.title else headingLevel + 1 }}>
54
+ <h{{ sectionItemHeadingLevel }} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ headingLevel + 2 if section.title else headingLevel + 1 }}>
55
55
  {% else %}
56
56
  <a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
57
57
  {% endif %}
@@ -145,10 +145,10 @@ describe('macro: section-navigation', () => {
145
145
  it('renders top level navigation items', () => {
146
146
  const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION));
147
147
 
148
- const itemLabels = mapAll($('.ons-section-nav__item .ons-section-nav__link'), node => node.text().trim());
148
+ const itemLabels = mapAll($('.ons-section-nav__item .ons-section-nav__link'), (node) => node.text().trim());
149
149
  expect(itemLabels).toEqual(['Results', 'Dashboard']);
150
150
 
151
- const itemLinks = mapAll($('.ons-section-nav__item .ons-section-nav__link'), node => node.attr('href'));
151
+ const itemLinks = mapAll($('.ons-section-nav__item .ons-section-nav__link'), (node) => node.attr('href'));
152
152
  expect(itemLinks).toEqual(['/results', '/results/dashboard']);
153
153
  });
154
154
 
@@ -173,11 +173,7 @@ describe('macro: section-navigation', () => {
173
173
  it('marks the current item with a class when `currentPath` is provided', () => {
174
174
  const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION));
175
175
 
176
- expect(
177
- $('.ons-section-nav__item--active')
178
- .text()
179
- .trim(),
180
- ).toBe('Results');
176
+ expect($('.ons-section-nav__item--active').text().trim()).toBe('Results');
181
177
  });
182
178
 
183
179
  it('marks the current item with a class when `tabQuery` is provided', () => {
@@ -189,11 +185,7 @@ describe('macro: section-navigation', () => {
189
185
  }),
190
186
  );
191
187
 
192
- expect(
193
- $('.ons-section-nav__item--active')
194
- .text()
195
- .trim(),
196
- ).toBe('Dashboard');
188
+ expect($('.ons-section-nav__item--active').text().trim()).toBe('Dashboard');
197
189
  });
198
190
 
199
191
  it('marks the current item with `aria-current` when `currentPath` is provided', () => {
@@ -226,12 +218,14 @@ describe('macro: section-navigation', () => {
226
218
  it('renders the expected anchor navigation items', () => {
227
219
  const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION_VERTICAL));
228
220
 
229
- const itemLabels = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), node =>
221
+ const itemLabels = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), (node) =>
230
222
  node.text().trim(),
231
223
  );
232
224
  expect(itemLabels).toEqual(['Sub section 1', 'Sub section 2', 'Sub section 3']);
233
225
 
234
- const itemLinks = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), node => node.attr('href'));
226
+ const itemLinks = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), (node) =>
227
+ node.attr('href'),
228
+ );
235
229
  expect(itemLinks).toEqual(['#sub-section-1', '#sub-section-2', '#sub-section-3']);
236
230
  });
237
231
  });
@@ -247,17 +241,15 @@ describe('macro: section-navigation', () => {
247
241
  it('renders itemsLists, anchors and heading for each section', () => {
248
242
  const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION_VERTICAL_WITH_SECTIONS));
249
243
 
250
- const anchors = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), node => node.text().trim());
244
+ const anchors = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), (node) =>
245
+ node.text().trim(),
246
+ );
251
247
  expect(anchors).toEqual(['Sub section 1', 'Sub section 2', 'Sub section 3']);
252
248
 
253
- const itemLists = mapAll($('.ons-section-nav__item .ons-section-nav__link'), node => node.text().trim());
249
+ const itemLists = mapAll($('.ons-section-nav__item .ons-section-nav__link'), (node) => node.text().trim());
254
250
  expect(itemLists).toEqual(['Section 1', 'Section 2', 'Sub section 1', 'Sub section 2', 'Sub section 3', 'Section 3']);
255
251
 
256
- const headings = mapAll($('h3'), node =>
257
- $(node)
258
- .text()
259
- .trim(),
260
- );
252
+ const headings = mapAll($('h3'), (node) => $(node).text().trim());
261
253
  expect(headings).toEqual(['Section Title']);
262
254
  });
263
255
  });
@@ -155,35 +155,35 @@ describe('macro: select', () => {
155
155
  it('has expected text', () => {
156
156
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
157
157
 
158
- const values = mapAll($('select > option'), node => node.text().trim());
158
+ const values = mapAll($('select > option'), (node) => node.text().trim());
159
159
  expect(values).toEqual(['First option', 'Second option', 'Disabled option']);
160
160
  });
161
161
 
162
162
  it('has a provided `id` attribute', () => {
163
163
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
164
164
 
165
- const values = mapAll($('select > option'), node => node.attr('id'));
165
+ const values = mapAll($('select > option'), (node) => node.attr('id'));
166
166
  expect(values).toEqual([undefined, 'second-option', undefined]);
167
167
  });
168
168
 
169
169
  it('marks the correct option as selected', () => {
170
170
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
171
171
 
172
- const values = mapAll($('select > option'), node => node.attr('selected'));
172
+ const values = mapAll($('select > option'), (node) => node.attr('selected'));
173
173
  expect(values).toEqual([undefined, 'selected', undefined]);
174
174
  });
175
175
 
176
176
  it('marks the correct option as disabled', () => {
177
177
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
178
178
 
179
- const values = mapAll($('select > option'), node => node.attr('disabled'));
179
+ const values = mapAll($('select > option'), (node) => node.attr('disabled'));
180
180
  expect(values).toEqual([undefined, undefined, 'disabled']);
181
181
  });
182
182
 
183
183
  it('has a provided `value` attribute', () => {
184
184
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
185
185
 
186
- const values = mapAll($('select > option'), node => node.attr('value'));
186
+ const values = mapAll($('select > option'), (node) => node.attr('value'));
187
187
  expect(values).toEqual(['1', '2', '3']);
188
188
  });
189
189
 
@@ -195,7 +195,7 @@ describe('macro: select', () => {
195
195
  }),
196
196
  );
197
197
 
198
- const values = mapAll($('select > option'), node => node.attr('value'));
198
+ const values = mapAll($('select > option'), (node) => node.attr('value'));
199
199
  expect(values).toEqual(['First option', 'Second option']);
200
200
  });
201
201
  });
@@ -24,11 +24,7 @@ describe('macro: share-page', () => {
24
24
  it('wraps title in <h2> element by default', () => {
25
25
  const $ = cheerio.load(renderComponent('share-page', EXAMPLE_SHARE_PAGE));
26
26
 
27
- expect(
28
- $('h2')
29
- .text()
30
- .trim(),
31
- ).toBe('Share page');
27
+ expect($('h2').text().trim()).toBe('Share page');
32
28
  });
33
29
 
34
30
  it('wraps title in custom element when `titleTag` is provided', () => {
@@ -39,11 +35,7 @@ describe('macro: share-page', () => {
39
35
  }),
40
36
  );
41
37
 
42
- expect(
43
- $('h4')
44
- .text()
45
- .trim(),
46
- ).toBe('Share page');
38
+ expect($('h4').text().trim()).toBe('Share page');
47
39
  });
48
40
 
49
41
  it('uses the provided icon size', () => {
@@ -65,7 +57,7 @@ describe('macro: share-page', () => {
65
57
 
66
58
  faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
67
59
 
68
- const twitterItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Twitter');
60
+ const twitterItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Twitter');
69
61
  expect(twitterItem.url).toBe(
70
62
  'https://twitter.com/intent/tweet?original_referer&text=An%20example%20page&url=https%3A%2F%2Fexample.com%2Fan-example-page',
71
63
  );
@@ -77,7 +69,7 @@ describe('macro: share-page', () => {
77
69
 
78
70
  faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
79
71
 
80
- const twitterItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Twitter');
72
+ const twitterItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Twitter');
81
73
  expect(twitterItem.rel).toContain('noreferrer');
82
74
  expect(twitterItem.rel).toContain('external');
83
75
  expect(twitterItem.target).toBe('_blank');
@@ -91,7 +83,7 @@ describe('macro: share-page', () => {
91
83
 
92
84
  faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
93
85
 
94
- const facebookItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Facebook');
86
+ const facebookItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Facebook');
95
87
  expect(facebookItem.url).toBe('https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fexample.com%2Fan-example-page');
96
88
  });
97
89
 
@@ -101,7 +93,7 @@ describe('macro: share-page', () => {
101
93
 
102
94
  faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
103
95
 
104
- const facebookItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Facebook');
96
+ const facebookItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Facebook');
105
97
  expect(facebookItem.rel).toContain('noreferrer');
106
98
  expect(facebookItem.rel).toContain('external');
107
99
  expect(facebookItem.target).toBe('_blank');
@@ -3,7 +3,7 @@
3
3
  import * as cheerio from 'cheerio';
4
4
 
5
5
  import axe from '../../tests/helpers/axe';
6
- import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
6
+ import { renderComponent } from '../../tests/helpers/rendering';
7
7
 
8
8
  describe('macro: skip-to-content', () => {
9
9
  it('passes jest-axe checks', async () => {
@@ -48,11 +48,7 @@ describe('macro: skip-to-content', () => {
48
48
  }),
49
49
  );
50
50
 
51
- expect(
52
- $('.ons-skip-to-content')
53
- .text()
54
- .trim(),
55
- ).toBe('Skip to the content');
51
+ expect($('.ons-skip-to-content').text().trim()).toBe('Skip to the content');
56
52
  });
57
53
 
58
54
  it('has skip link with the default text if no text provided`', async () => {
@@ -62,10 +58,6 @@ describe('macro: skip-to-content', () => {
62
58
  }),
63
59
  );
64
60
 
65
- expect(
66
- $('.ons-skip-to-content')
67
- .text()
68
- .trim(),
69
- ).toBe('Skip to content');
61
+ expect($('.ons-skip-to-content').text().trim()).toBe('Skip to content');
70
62
  });
71
63
  });
@@ -4,7 +4,7 @@ import skipToMain from './skip-to-content';
4
4
  async function initaliseSkipToLink() {
5
5
  const links = [...document.querySelectorAll('.ons-skip-to-content')];
6
6
  if (links.length) {
7
- links.forEach(link => {
7
+ links.forEach((link) => {
8
8
  skipToMain(link);
9
9
  });
10
10
  }
@@ -1,6 +1,6 @@
1
1
  export default function skipToMain(link) {
2
2
  const id = link.getAttribute('href').replace('#', '');
3
- link.addEventListener('click', event => {
3
+ link.addEventListener('click', (event) => {
4
4
  event.preventDefault();
5
5
  document.getElementById(id).tabIndex = -1;
6
6
  document.getElementById(id).style.outline = 'none';