@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
@@ -1,9 +1,10 @@
1
- import { renderBaseTemplate, renderComponent, setTestPage } from '../../tests/helpers/rendering';
1
+ import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
2
2
 
3
3
  describe('script: table-of-contents', () => {
4
4
  beforeEach(async () => {
5
5
  await setTestPage(
6
6
  '/test',
7
+ /* eslint-disable indent */
7
8
  `
8
9
  <div class="ons-page__container ons-container">
9
10
  <div class="ons-grid ons-js-toc-container">
@@ -44,6 +45,7 @@ describe('script: table-of-contents', () => {
44
45
  </div>
45
46
  </div>
46
47
  `,
48
+ /* eslint-enable indent */
47
49
  );
48
50
  });
49
51
 
@@ -64,37 +66,38 @@ describe('script: table-of-contents-fixed-position', () => {
64
66
  beforeEach(async () => {
65
67
  await setTestPage(
66
68
  '/test',
69
+ /* eslint-disable indent */
67
70
  `
68
71
  <div class="ons-page__container ons-container">
69
- <div class="ons-grid ons-js-toc-container">
70
- <div id="sticky-container" class="ons-grid__col ons-grid__col--sticky@m ons-col-4@m">
71
- ${renderComponent('table-of-contents', {
72
- title: 'Contents',
73
- ariaLabel: 'Sections in this page',
74
- itemsList: [
75
- {
76
- url: '#section1',
77
- text: 'What is the census?',
78
- },
79
- {
80
- url: '#section2',
81
- text: 'The online census has now closed',
82
- },
83
- {
84
- url: '#section3',
85
- text: 'What happens after Census Day',
86
- },
87
- {
88
- url: '#section4',
89
- text: 'The census in Northern Ireland and Scotland',
90
- },
91
- {
92
- url: '#section5',
93
- text: 'The last census',
94
- },
95
- ],
96
- })}
97
- </div>
72
+ <div class="ons-grid ons-js-toc-container">
73
+ <div id="sticky-container" class="ons-grid__col ons-grid__col--sticky@m ons-col-4@m">
74
+ ${renderComponent('table-of-contents', {
75
+ title: 'Contents',
76
+ ariaLabel: 'Sections in this page',
77
+ itemsList: [
78
+ {
79
+ url: '#section1',
80
+ text: 'What is the census?',
81
+ },
82
+ {
83
+ url: '#section2',
84
+ text: 'The online census has now closed',
85
+ },
86
+ {
87
+ url: '#section3',
88
+ text: 'What happens after Census Day',
89
+ },
90
+ {
91
+ url: '#section4',
92
+ text: 'The census in Northern Ireland and Scotland',
93
+ },
94
+ {
95
+ url: '#section5',
96
+ text: 'The last census',
97
+ },
98
+ ],
99
+ })}
100
+ </div>
98
101
  <div class="ons-grid__col ons-col-7@m ons-push-1@m">
99
102
  <section id="section1">
100
103
  <h2>What is the census?</h2>
@@ -138,9 +141,10 @@ describe('script: table-of-contents-fixed-position', () => {
138
141
  <p>The CCS has now closed.</p>
139
142
  </section>
140
143
  </div>
144
+ </div>
141
145
  </div>
142
- </div>
143
- `,
146
+ `,
147
+ /* eslint-enable indent */
144
148
  'main',
145
149
  );
146
150
  });
@@ -23,7 +23,7 @@
23
23
  {% from "components/tabs/_macro.njk" import onsTabs %}
24
24
  {{
25
25
  onsTabs({
26
- "variants": [ 'details' ],
26
+ "variants": ['details'],
27
27
  "noInitialActiveTab": true,
28
28
  "title": 'Contents',
29
29
  "tabs": [
@@ -6,7 +6,7 @@ async function tabs() {
6
6
  if (tabs.length) {
7
7
  const Tabs = (await import('./tabs')).default;
8
8
 
9
- tabs.forEach(component => new Tabs(component));
9
+ tabs.forEach((component) => new Tabs(component));
10
10
  }
11
11
  }
12
12
 
@@ -45,7 +45,7 @@ export default class Tabs {
45
45
  setupViewportChecks() {
46
46
  const breakpoint = () => {
47
47
  let finalBreakpoint = 0;
48
- this.tabListItems.forEach(tab => {
48
+ this.tabListItems.forEach((tab) => {
49
49
  finalBreakpoint += tab.offsetWidth;
50
50
  });
51
51
  if (finalBreakpoint < 450) {
@@ -73,19 +73,19 @@ export default class Tabs {
73
73
 
74
74
  this.tabsTitle.classList.add('ons-u-vh');
75
75
  this.tabListContainer.classList.add('ons-tabs__container');
76
- this.tabPanels.forEach(panel => {
76
+ this.tabPanels.forEach((panel) => {
77
77
  panel.setAttribute('tabindex', '0');
78
78
  if (panel.querySelector('[id*="content-title"]')) {
79
79
  panel.firstElementChild.classList.add('ons-u-vh');
80
80
  }
81
81
  });
82
82
 
83
- this.tabListItems.forEach(item => {
83
+ this.tabListItems.forEach((item) => {
84
84
  item.setAttribute('role', 'presentation');
85
85
  item.classList.add(this.jsTabItemAsRowClass);
86
86
  });
87
87
 
88
- this.tabs.forEach(tab => {
88
+ this.tabs.forEach((tab) => {
89
89
  this.setAttributes(tab);
90
90
  tab.classList.add(this.jsTabAsListClass);
91
91
 
@@ -112,19 +112,19 @@ export default class Tabs {
112
112
  this.tabListContainer.classList.remove('ons-tabs__container');
113
113
  this.tabsTitle.classList.remove('ons-u-vh');
114
114
 
115
- this.tabPanels.forEach(panel => {
115
+ this.tabPanels.forEach((panel) => {
116
116
  panel.removeAttribute('tabindex', '0');
117
117
  if (panel.firstElementChild.classList.contains('ons-u-vh')) {
118
118
  panel.firstElementChild.classList.remove('ons-u-vh');
119
119
  }
120
120
  });
121
121
 
122
- this.tabListItems.forEach(item => {
122
+ this.tabListItems.forEach((item) => {
123
123
  item.removeAttribute('role', 'presentation');
124
124
  item.classList.remove(this.jsTabItemAsRowClass);
125
125
  });
126
126
 
127
- this.tabs.forEach(tab => {
127
+ this.tabs.forEach((tab) => {
128
128
  tab.removeEventListener('click', this.boundTabClick, true);
129
129
  tab.removeEventListener('keydown', this.boundTabKeydown, true);
130
130
  tab.classList.remove(this.jsTabAsListClass);
@@ -216,7 +216,7 @@ export default class Tabs {
216
216
 
217
217
  ensureTabIndexExists() {
218
218
  // Ensure that at least the first tab has a tab index when all tabs are hidden.
219
- if (!this.tabs.find(tab => tab.getAttribute('tabindex') === '0')) {
219
+ if (!this.tabs.find((tab) => tab.getAttribute('tabindex') === '0')) {
220
220
  this.tabs[0].setAttribute('tabindex', '0');
221
221
  }
222
222
  }
@@ -25,9 +25,7 @@ describe('macro: text-indent', () => {
25
25
  }),
26
26
  );
27
27
 
28
- const content = $('.ons-text-indent')
29
- .text()
30
- .trim();
28
+ const content = $('.ons-text-indent').text().trim();
31
29
  expect(content).toBe('Example text...');
32
30
  });
33
31
  });
@@ -43,9 +41,7 @@ describe('macro: text-indent', () => {
43
41
  it('has expected text', async () => {
44
42
  const $ = cheerio.load(renderComponent('text-indent', {}, 'Example content...'));
45
43
 
46
- const content = $('.ons-text-indent')
47
- .text()
48
- .trim();
44
+ const content = $('.ons-text-indent').text().trim();
49
45
  expect(content).toBe('Example content...');
50
46
  });
51
47
  });
@@ -5,7 +5,7 @@ async function initialise() {
5
5
  if (limitedInputs.length) {
6
6
  const CharLimit = (await import('../char-check-limit/character-limit')).default;
7
7
 
8
- limitedInputs.forEach(input => new CharLimit(input));
8
+ limitedInputs.forEach((input) => new CharLimit(input));
9
9
  }
10
10
  }
11
11
 
@@ -24,7 +24,7 @@ describe('script: textarea', () => {
24
24
 
25
25
  describe('Given that the char limit helper has initialised correctly', () => {
26
26
  it('the char limit readout should be visible', async () => {
27
- const hasClass = await page.$eval('#example-textarea-lim', node => node.classList.contains('ons-u-d-no'));
27
+ const hasClass = await page.$eval('#example-textarea-lim', (node) => node.classList.contains('ons-u-d-no'));
28
28
  expect(hasClass).toBe(false);
29
29
  });
30
30
  });
@@ -36,7 +36,7 @@ describe('script: textarea', () => {
36
36
  });
37
37
 
38
38
  it('then the characters remaining readout reflect the number of characters remaining', async () => {
39
- const readout = await page.$eval('#example-textarea-lim', node => node.textContent);
39
+ const readout = await page.$eval('#example-textarea-lim', (node) => node.textContent);
40
40
  expect(readout).toBe('You have 12 characters remaining');
41
41
  });
42
42
  });
@@ -47,17 +47,17 @@ describe('script: textarea', () => {
47
47
  });
48
48
 
49
49
  it('then the characters remaining readout reflect the number of characters remaining', async () => {
50
- const readout = await page.$eval('#example-textarea-lim', node => node.textContent);
50
+ const readout = await page.$eval('#example-textarea-lim', (node) => node.textContent);
51
51
  expect(readout).toBe('You have 0 characters remaining');
52
52
  });
53
53
 
54
54
  it('then the textarea should be given limit reached classes', async () => {
55
- const hasClass = await page.$eval('#example-textarea', node => node.classList.contains('ons-input--limit-reached'));
55
+ const hasClass = await page.$eval('#example-textarea', (node) => node.classList.contains('ons-input--limit-reached'));
56
56
  expect(hasClass).toBe(true);
57
57
  });
58
58
 
59
59
  it('then the readout should be given limit reached classes', async () => {
60
- const hasClass = await page.$eval('#example-textarea-lim', node => node.classList.contains('ons-input__limit--reached'));
60
+ const hasClass = await page.$eval('#example-textarea-lim', (node) => node.classList.contains('ons-input__limit--reached'));
61
61
  expect(hasClass).toBe(true);
62
62
  });
63
63
  });
@@ -75,17 +75,17 @@ describe('script: textarea', () => {
75
75
  });
76
76
 
77
77
  it('then the characters remaining readout reflect the number of characters remaining', async () => {
78
- const readout = await page.$eval('#example-textarea-lim', node => node.textContent);
78
+ const readout = await page.$eval('#example-textarea-lim', (node) => node.textContent);
79
79
  expect(readout).toBe('You have 1 character remaining');
80
80
  });
81
81
 
82
82
  it('then the textarea should not be given limit reached classes', async () => {
83
- const hasClass = await page.$eval('#example-textarea', node => node.classList.contains('ons-input--limit-reached'));
83
+ const hasClass = await page.$eval('#example-textarea', (node) => node.classList.contains('ons-input--limit-reached'));
84
84
  expect(hasClass).toBe(false);
85
85
  });
86
86
 
87
87
  it('then the readout should not be given limit reached classes', async () => {
88
- const hasClass = await page.$eval('#example-textarea-lim', node => node.classList.contains('ons-input__limit--reached'));
88
+ const hasClass = await page.$eval('#example-textarea-lim', (node) => node.classList.contains('ons-input__limit--reached'));
89
89
  expect(hasClass).toBe(false);
90
90
  });
91
91
  });
@@ -60,9 +60,7 @@ describe('macro: timeout modal', () => {
60
60
  it('has expected `textFirstLine`', () => {
61
61
  const $ = cheerio.load(renderComponent('timeout-modal', EXAMPLE_TIMEOUT_MODAL_BASIC));
62
62
 
63
- const title = $('.ons-modal__body > p')
64
- .html()
65
- .trim();
63
+ const title = $('.ons-modal__body > p').html().trim();
66
64
  expect(title).toBe('It appears you have been inactive for a while.');
67
65
  });
68
66
  });
@@ -6,7 +6,7 @@ async function modals() {
6
6
  if (timeouts.length) {
7
7
  const TimeoutModal = (await import('./timeout-modal')).default;
8
8
 
9
- timeouts.forEach(context => {
9
+ timeouts.forEach((context) => {
10
10
  let url = context.getAttribute('data-server-session-expiry-endpoint');
11
11
  let time = context.getAttribute('data-server-session-expires-at');
12
12
  new TimeoutModal(context, url, time);
@@ -28,7 +28,7 @@ describe('script: timeout modal', () => {
28
28
 
29
29
  it('displays the modal after the correct number of seconds', async () => {
30
30
  await page.waitForTimeout(2000);
31
- const modalIsVisible = await page.$eval('.ons-modal', node => node.classList.contains('ons-u-db'));
31
+ const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
32
32
  expect(modalIsVisible).toBe(true);
33
33
  });
34
34
  });
@@ -51,9 +51,9 @@ describe('script: timeout modal', () => {
51
51
  });
52
52
 
53
53
  it('shows the time counting down', async () => {
54
- const timeAtStart = await page.$eval('.ons-js-timeout-timer span', element => element.innerHTML);
54
+ const timeAtStart = await page.$eval('.ons-js-timeout-timer span', (element) => element.innerHTML);
55
55
  await page.waitForTimeout(1000);
56
- const timeAfterOneSecond = await page.$eval('.ons-js-timeout-timer span', element => element.innerHTML);
56
+ const timeAfterOneSecond = await page.$eval('.ons-js-timeout-timer span', (element) => element.innerHTML);
57
57
  expect(timeAfterOneSecond).not.toEqual(timeAtStart);
58
58
  });
59
59
  });
@@ -78,7 +78,7 @@ describe('script: timeout modal', () => {
78
78
  });
79
79
 
80
80
  it('displays the `minutes` (plural) string', async () => {
81
- const timeString = await page.$eval('.ons-js-timeout-timer span', element => element.innerHTML);
81
+ const timeString = await page.$eval('.ons-js-timeout-timer span', (element) => element.innerHTML);
82
82
  expect(timeString).toEqual(expect.stringContaining('minutes'));
83
83
  });
84
84
  });
@@ -103,7 +103,7 @@ describe('script: timeout modal', () => {
103
103
  });
104
104
 
105
105
  it('displays the `seconds` (plural) string', async () => {
106
- const timeString = await page.$eval('.ons-js-timeout-timer span', element => element.innerHTML);
106
+ const timeString = await page.$eval('.ons-js-timeout-timer span', (element) => element.innerHTML);
107
107
  expect(timeString).toEqual(expect.stringContaining('seconds'));
108
108
  });
109
109
  });
@@ -128,7 +128,7 @@ describe('script: timeout modal', () => {
128
128
  });
129
129
 
130
130
  it('displays the `minute` (singular) string', async () => {
131
- const timeString = await page.$eval('.ons-js-timeout-timer span', element => element.innerHTML);
131
+ const timeString = await page.$eval('.ons-js-timeout-timer span', (element) => element.innerHTML);
132
132
  expect(timeString).toEqual(expect.stringContaining('minute'));
133
133
  });
134
134
  });
@@ -153,7 +153,7 @@ describe('script: timeout modal', () => {
153
153
  });
154
154
 
155
155
  it('displays the `second` (singular) string', async () => {
156
- const timeString = await page.$eval('.ons-js-timeout-timer span', element => element.innerHTML);
156
+ const timeString = await page.$eval('.ons-js-timeout-timer span', (element) => element.innerHTML);
157
157
  expect(timeString).toEqual(expect.stringContaining('second'));
158
158
  });
159
159
  });
@@ -178,7 +178,7 @@ describe('script: timeout modal', () => {
178
178
  });
179
179
 
180
180
  it('displays the `countdownExpiredText` text', async () => {
181
- const timeString = await page.$eval('.ons-js-timeout-timer span', element => element.innerHTML);
181
+ const timeString = await page.$eval('.ons-js-timeout-timer span', (element) => element.innerHTML);
182
182
  expect(timeString).toEqual(expect.stringContaining('You are being signed out'));
183
183
  });
184
184
 
@@ -212,13 +212,13 @@ describe('script: timeout modal', () => {
212
212
  });
213
213
 
214
214
  it('closes the modal', async () => {
215
- const modalIsVisible = await page.$eval('.ons-modal', node => node.classList.contains('ons-u-db'));
215
+ const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
216
216
  expect(modalIsVisible).toBe(false);
217
217
  });
218
218
 
219
219
  it('restarts the timer and displays the modal after the correct number of seconds', async () => {
220
220
  await page.waitForTimeout(2000);
221
- const modalIsVisible = await page.$eval('.ons-modal', node => node.classList.contains('ons-u-db'));
221
+ const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
222
222
  expect(modalIsVisible).toBe(true);
223
223
  });
224
224
  });
@@ -1,23 +1,22 @@
1
1
  {% from "components/panel/_macro.njk" import onsPanel %}
2
2
  {% macro onsTimeoutPanel(params) %}
3
3
  {% call onsPanel({
4
- "id": params.id,
5
- "classes": "ons-js-panel-with-countdown",
6
- "type": "warn",
7
- "attributes": {
8
- "data-redirect-url": params.redirectUrl,
9
- "data-server-session-expires-at": params.sessionExpiresAt,
10
- "data-countdown-text": params.countdownText,
11
- "data-countdown-expired-text": params.countdownExpiredText,
12
- "data-minutes-text-singular": params.minutesTextSingular,
13
- "data-minutes-text-plural": params.minutesTextPlural,
14
- "data-seconds-text-singular": params.secondsTextSingular,
15
- "data-seconds-text-plural": params.secondsTextPlural,
16
- "data-full-stop": params.endWithFullStop,
17
- "aria-describedby": "timeout-time-remaining"
18
- }
19
- })
20
- %}
4
+ "id": params.id,
5
+ "classes": "ons-js-panel-with-countdown",
6
+ "variant": "warn",
7
+ "attributes": {
8
+ "data-redirect-url": params.redirectUrl,
9
+ "data-server-session-expires-at": params.sessionExpiresAt,
10
+ "data-countdown-text": params.countdownText,
11
+ "data-countdown-expired-text": params.countdownExpiredText,
12
+ "data-minutes-text-singular": params.minutesTextSingular,
13
+ "data-minutes-text-plural": params.minutesTextPlural,
14
+ "data-seconds-text-singular": params.secondsTextSingular,
15
+ "data-seconds-text-plural": params.secondsTextPlural,
16
+ "data-full-stop": params.endWithFullStop,
17
+ "aria-describedby": "timeout-time-remaining"
18
+ }
19
+ }) %}
21
20
  <noscript><p class="ons-js-nojs-text">{{ params.nojsText }}</p></noscript>
22
21
  <p class="ons-js-timeout-timer" aria-hidden="true" aria-relevant="additions"></p>
23
22
  <p class="ons-js-timeout-timer-acc ons-u-vh" role="status" id="timeout-time-remaining"></p>
@@ -36,7 +36,7 @@ describe('macro: timeout panel', () => {
36
36
  expect(panelSpy.occurrences[0]).toEqual({
37
37
  id: 'countdown',
38
38
  classes: 'ons-js-panel-with-countdown',
39
- type: 'warn',
39
+ variant: 'warn',
40
40
  attributes: {
41
41
  'data-redirect-url': '#!',
42
42
  'data-server-session-expires-at': '000-000-000',
@@ -6,7 +6,7 @@ async function timeoutPanels() {
6
6
  if (panels.length) {
7
7
  const Timeout = (await import('../../js/timeout')).default;
8
8
 
9
- panels.forEach(context => {
9
+ panels.forEach((context) => {
10
10
  let time = context.getAttribute('data-server-session-expires-at');
11
11
  new Timeout(context, null, time, false, true);
12
12
  });
@@ -28,9 +28,9 @@ describe('script: timeout panel', () => {
28
28
  });
29
29
 
30
30
  it('shows the time counting down', async () => {
31
- const timeAtStart = await page.$eval('.ons-js-timeout-timer', element => element.innerHTML);
31
+ const timeAtStart = await page.$eval('.ons-js-timeout-timer', (element) => element.innerHTML);
32
32
  await page.waitForTimeout(1000);
33
- const timeAfterOneSecond = await page.$eval('.ons-js-timeout-timer', element => element.innerHTML);
33
+ const timeAfterOneSecond = await page.$eval('.ons-js-timeout-timer', (element) => element.innerHTML);
34
34
  expect(timeAfterOneSecond).not.toEqual(timeAtStart);
35
35
  });
36
36
  });
@@ -49,7 +49,7 @@ describe('script: timeout panel', () => {
49
49
  });
50
50
 
51
51
  it('displays the `minutes` (plural) string', async () => {
52
- const timeString = await page.$eval('.ons-js-timeout-timer', element => element.innerHTML);
52
+ const timeString = await page.$eval('.ons-js-timeout-timer', (element) => element.innerHTML);
53
53
  expect(timeString).toEqual(expect.stringContaining('minutes'));
54
54
  });
55
55
  });
@@ -68,7 +68,7 @@ describe('script: timeout panel', () => {
68
68
  });
69
69
 
70
70
  it('displays the `seconds` (plural) string', async () => {
71
- const timeString = await page.$eval('.ons-js-timeout-timer span', element => element.innerHTML);
71
+ const timeString = await page.$eval('.ons-js-timeout-timer span', (element) => element.innerHTML);
72
72
  expect(timeString).toEqual(expect.stringContaining('seconds'));
73
73
  });
74
74
  });
@@ -87,7 +87,7 @@ describe('script: timeout panel', () => {
87
87
  });
88
88
 
89
89
  it('displays the `minute` (singular) string', async () => {
90
- const timeString = await page.$eval('.ons-js-timeout-timer', element => element.innerHTML);
90
+ const timeString = await page.$eval('.ons-js-timeout-timer', (element) => element.innerHTML);
91
91
  expect(timeString).toEqual(expect.stringContaining('minute'));
92
92
  });
93
93
  });
@@ -106,7 +106,7 @@ describe('script: timeout panel', () => {
106
106
  });
107
107
 
108
108
  it('displays the `second` (singular) string', async () => {
109
- const timeString = await page.$eval('.ons-js-timeout-timer span', element => element.innerHTML);
109
+ const timeString = await page.$eval('.ons-js-timeout-timer span', (element) => element.innerHTML);
110
110
  expect(timeString).toEqual(expect.stringContaining('second'));
111
111
  });
112
112
  });
@@ -125,7 +125,7 @@ describe('script: timeout panel', () => {
125
125
  });
126
126
 
127
127
  it('displays the `countdownExpiredText` text', async () => {
128
- const timeString = await page.$eval('.ons-js-timeout-timer', element => element.innerHTML);
128
+ const timeString = await page.$eval('.ons-js-timeout-timer', (element) => element.innerHTML);
129
129
  expect(timeString).toEqual(expect.stringContaining('You are being signed out'));
130
130
  });
131
131
 
@@ -154,7 +154,7 @@ describe('script: timeout panel', () => {
154
154
  });
155
155
 
156
156
  it('displays the `nojsText` text', async () => {
157
- const nojsText = await page.$eval('.ons-js-nojs-text', element => element.innerHTML);
157
+ const nojsText = await page.$eval('.ons-js-nojs-text', (element) => element.innerHTML);
158
158
  expect(nojsText.trim()).toBe('For security, your answers will only be available to view for another 1 minute');
159
159
  });
160
160
  });
@@ -46,11 +46,7 @@ describe('macro: video', () => {
46
46
  it('outputs the provided link text', () => {
47
47
  const $ = cheerio.load(renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
48
48
 
49
- expect(
50
- $('.ons-video__link-text')
51
- .text()
52
- .trim(),
53
- ).toBe('Example link text');
49
+ expect($('.ons-video__link-text').text().trim()).toBe('Example link text');
54
50
  });
55
51
 
56
52
  it('outputs a hyperlink with the provided `url`', () => {
@@ -6,7 +6,7 @@ async function video() {
6
6
  if (videos.length) {
7
7
  const Video = (await import('./video')).default;
8
8
 
9
- videos.forEach(component => new Video(component));
9
+ videos.forEach((component) => new Video(component));
10
10
  }
11
11
  }
12
12
 
@@ -22,14 +22,14 @@ describe('script: video', () => {
22
22
  it('should show the placeholder content', async () => {
23
23
  await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
24
24
 
25
- const displayStyle = await page.$eval('.ons-js-video-placeholder', node => window.getComputedStyle(node).getPropertyValue('display'));
25
+ const displayStyle = await page.$eval('.ons-js-video-placeholder', (node) => window.getComputedStyle(node).getPropertyValue('display'));
26
26
  expect(displayStyle).toBe('block');
27
27
  });
28
28
 
29
29
  it('should not show the iframe', async () => {
30
30
  await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
31
31
 
32
- const displayStyle = await page.$eval('.ons-js-video-iframe', node => window.getComputedStyle(node).getPropertyValue('display'));
32
+ const displayStyle = await page.$eval('.ons-js-video-iframe', (node) => window.getComputedStyle(node).getPropertyValue('display'));
33
33
  expect(displayStyle).toBe('none');
34
34
  });
35
35
 
@@ -44,29 +44,31 @@ describe('script: video', () => {
44
44
  });
45
45
 
46
46
  it('should hide the placeholder content', async () => {
47
- const displayStyle = await page.$eval('.ons-js-video-placeholder', node => window.getComputedStyle(node).getPropertyValue('display'));
47
+ const displayStyle = await page.$eval('.ons-js-video-placeholder', (node) =>
48
+ window.getComputedStyle(node).getPropertyValue('display'),
49
+ );
48
50
  expect(displayStyle).toBe('none');
49
51
  }, 10000);
50
52
 
51
53
  it('should show the iframe', async () => {
52
- const displayStyle = await page.$eval('.ons-js-video-iframe', node => window.getComputedStyle(node).getPropertyValue('display'));
54
+ const displayStyle = await page.$eval('.ons-js-video-iframe', (node) => window.getComputedStyle(node).getPropertyValue('display'));
53
55
  expect(displayStyle).toBe('block');
54
56
  }, 10000);
55
57
 
56
58
  it('should add the correct modifier class', async () => {
57
- const hasClass = await page.$eval('.ons-js-video', node => node.classList.contains('ons-video--hasIframe'));
59
+ const hasClass = await page.$eval('.ons-js-video', (node) => node.classList.contains('ons-video--hasIframe'));
58
60
  expect(hasClass).toBe(true);
59
61
  }, 10000);
60
62
 
61
63
  it('should not add dnt to YouTube videos', async () => {
62
- const src = await page.$eval('.ons-js-video-iframe', node => node.getAttribute('src'));
64
+ const src = await page.$eval('.ons-js-video-iframe', (node) => node.getAttribute('src'));
63
65
  expect(src.includes('?dnt=1')).toBe(false);
64
66
  }, 10000);
65
67
 
66
68
  it('should add dnt to Vimeo videos', async () => {
67
69
  await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_VIMEO));
68
70
 
69
- const src = await page.$eval('.ons-js-video-iframe', node => node.getAttribute('src'));
71
+ const src = await page.$eval('.ons-js-video-iframe', (node) => node.getAttribute('src'));
70
72
  expect(src.includes('?dnt=1')).toBe(true);
71
73
  }, 10000);
72
74
  });
@@ -82,21 +84,23 @@ describe('script: video', () => {
82
84
  });
83
85
 
84
86
  it('should hide the placeholder content', async () => {
85
- const displayStyle = await page.$eval('.ons-js-video-placeholder', node => window.getComputedStyle(node).getPropertyValue('display'));
87
+ const displayStyle = await page.$eval('.ons-js-video-placeholder', (node) =>
88
+ window.getComputedStyle(node).getPropertyValue('display'),
89
+ );
86
90
  expect(displayStyle).toBe('none');
87
91
  });
88
92
 
89
93
  it('should show the iframe', async () => {
90
- const displayStyle = await page.$eval('.ons-js-video-iframe', node => window.getComputedStyle(node).getPropertyValue('display'));
94
+ const displayStyle = await page.$eval('.ons-js-video-iframe', (node) => window.getComputedStyle(node).getPropertyValue('display'));
91
95
  expect(displayStyle).toBe('block');
92
96
  });
93
97
 
94
98
  it('should add the correct modifier class', async () => {
95
- const hasClass = await page.$eval('.ons-js-video', node => node.classList.contains('ons-video--hasIframe'));
99
+ const hasClass = await page.$eval('.ons-js-video', (node) => node.classList.contains('ons-video--hasIframe'));
96
100
  expect(hasClass).toBe(true);
97
101
  }, 10000);
98
102
  it('should not add dnt to YouTube videos', async () => {
99
- const src = await page.$eval('.ons-js-video-iframe', node => node.getAttribute('src'));
103
+ const src = await page.$eval('.ons-js-video-iframe', (node) => node.getAttribute('src'));
100
104
  expect(src.includes('?dnt=1')).toBe(false);
101
105
  }, 10000);
102
106
 
@@ -108,7 +112,7 @@ describe('script: video', () => {
108
112
  );
109
113
  await page.click('.ons-js-accept-cookies');
110
114
 
111
- const src = await page.$eval('.ons-js-video-iframe', node => node.getAttribute('src'));
115
+ const src = await page.$eval('.ons-js-video-iframe', (node) => node.getAttribute('src'));
112
116
  expect(src.includes('?dnt=1')).toBe(true);
113
117
  }, 10000);
114
118
  });