@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.
Files changed (182) hide show
  1. package/README.md +5 -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.dom.js +1 -1
  16. package/components/autosuggest/autosuggest.helpers.js +1 -1
  17. package/components/back-to-top/_back-to-top.scss +34 -0
  18. package/components/back-to-top/_macro.njk +17 -0
  19. package/components/back-to-top/_macro.spec.js +60 -0
  20. package/components/back-to-top/back-to-top.dom.js +12 -0
  21. package/components/back-to-top/back-to-top.js +58 -0
  22. package/components/back-to-top/back-to-top.spec.js +117 -0
  23. package/components/back-to-top/example-back-to-top.njk +37 -0
  24. package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
  25. package/components/browser-banner/_macro.spec.js +4 -12
  26. package/components/button/_macro.njk +6 -6
  27. package/components/button/_macro.spec.js +1 -5
  28. package/components/button/button.js +7 -8
  29. package/components/button/button.spec.js +17 -39
  30. package/components/call-to-action/_macro.spec.js +2 -6
  31. package/components/card/_macro.njk +25 -25
  32. package/components/card/_macro.spec.js +6 -30
  33. package/components/char-check-limit/_macro.njk +1 -1
  34. package/components/char-check-limit/_macro.spec.js +3 -7
  35. package/components/char-check-limit/character-check.spec.js +24 -20
  36. package/components/checkboxes/_checkbox-macro.njk +1 -1
  37. package/components/checkboxes/_checkbox.scss +0 -3
  38. package/components/checkboxes/_macro.spec.js +1 -5
  39. package/components/checkboxes/checkbox-with-autoselect.js +3 -3
  40. package/components/checkboxes/checkbox-with-fieldset.js +2 -2
  41. package/components/checkboxes/checkboxes-with-reveal.js +4 -2
  42. package/components/checkboxes/checkboxes.dom.js +2 -2
  43. package/components/checkboxes/checkboxes.spec.js +13 -13
  44. package/components/content-pagination/_macro.spec.js +2 -2
  45. package/components/cookies-banner/cookies-banner.dom.js +1 -1
  46. package/components/cookies-banner/cookies-banner.js +1 -1
  47. package/components/cookies-banner/cookies-banner.spec.js +7 -7
  48. package/components/details/details.spec.js +12 -12
  49. package/components/details/example-details-with-warning.njk +5 -7
  50. package/components/document-list/_macro.spec.js +9 -27
  51. package/components/document-list/document-list.scss +1 -1
  52. package/components/document-list/example-document-list-downloads.njk +3 -3
  53. package/components/document-list/example-document-list-search-result-featured.njk +1 -1
  54. package/components/document-list/example-document-list-search-results.njk +3 -3
  55. package/components/download-resources/download-resources.js +54 -54
  56. package/components/download-resources/download-resources.spec.js +3 -1
  57. package/components/error/_macro.njk +1 -1
  58. package/components/error/_macro.spec.js +2 -6
  59. package/components/feedback/_macro.spec.js +4 -20
  60. package/components/field/_macro.spec.js +1 -3
  61. package/components/fieldset/_fieldset.scss +1 -2
  62. package/components/fieldset/_macro.spec.js +3 -9
  63. package/components/footer/_footer.scss +8 -0
  64. package/components/footer/_macro.njk +8 -7
  65. package/components/footer/_macro.spec.js +14 -2
  66. package/components/helpers/grid.njk +15 -15
  67. package/components/icon/_macro.njk +7 -3
  68. package/components/icon/_macro.spec.js +4 -12
  69. package/components/image/_macro.spec.js +1 -5
  70. package/components/input/_macro.njk +22 -23
  71. package/components/input/_macro.spec.js +1 -1
  72. package/components/input/character-check.dom.js +1 -1
  73. package/components/input/input.spec.js +1 -4
  74. package/components/label/_label.scss +1 -0
  75. package/components/label/_macro.njk +2 -2
  76. package/components/label/_macro.spec.js +4 -13
  77. package/components/list/_macro.spec.js +4 -12
  78. package/components/message/_macro.njk +17 -17
  79. package/components/message/_macro.spec.js +9 -33
  80. package/components/message-list/_macro.spec.js +7 -39
  81. package/components/modal/_macro.spec.js +3 -9
  82. package/components/modal/modal.dom.js +1 -1
  83. package/components/modal/modal.spec.js +5 -5
  84. package/components/mutually-exclusive/_macro.spec.js +2 -10
  85. package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
  86. package/components/mutually-exclusive/mutually-exclusive.date.spec.js +9 -9
  87. package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
  88. package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +8 -8
  89. package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
  90. package/components/mutually-exclusive/mutually-exclusive.js +13 -13
  91. package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
  92. package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
  93. package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
  94. package/components/navigation/navigation.spec.js +0 -2
  95. package/components/pagination/_macro.spec.js +11 -53
  96. package/components/panel/_macro.njk +17 -17
  97. package/components/panel/_macro.spec.js +25 -25
  98. package/components/panel/_panel.scss +10 -9
  99. package/components/panel/example-panel-bare.njk +3 -4
  100. package/components/panel/example-panel-with-announcement.njk +6 -10
  101. package/components/panel/example-panel-with-error-summary.njk +2 -2
  102. package/components/panel/example-panel-with-information.njk +0 -1
  103. package/components/panel/example-panel-with-success-message.njk +1 -1
  104. package/components/panel/example-panel-with-warning.njk +2 -3
  105. package/components/password/password.dom.js +1 -1
  106. package/components/phase-banner/_macro.spec.js +3 -9
  107. package/components/question/_macro.njk +1 -1
  108. package/components/question/_macro.spec.js +5 -19
  109. package/components/question/_question.scss +1 -4
  110. package/components/question/example-question-interviewer-note.njk +1 -1
  111. package/components/quote/_macro.spec.js +2 -10
  112. package/components/radios/clear-radios.js +3 -3
  113. package/components/radios/radio-with-fieldset.js +4 -4
  114. package/components/radios/radios.dom.js +1 -1
  115. package/components/radios/radios.spec.js +26 -26
  116. package/components/related-content/_macro.spec.js +2 -4
  117. package/components/related-content/_section-macro.spec.js +2 -8
  118. package/components/relationships/example-relationships-error.njk +16 -18
  119. package/components/relationships/relationships.dom.js +1 -1
  120. package/components/relationships/relationships.js +2 -2
  121. package/components/reply/_macro.spec.js +3 -3
  122. package/components/reply/reply.dom.js +1 -1
  123. package/components/reply/reply.spec.js +3 -3
  124. package/components/section-navigation/_macro.spec.js +13 -21
  125. package/components/select/_macro.spec.js +6 -6
  126. package/components/share-page/_macro.spec.js +6 -14
  127. package/components/skip-to-content/_macro.spec.js +3 -11
  128. package/components/skip-to-content/skip-to-content.dom.js +1 -1
  129. package/components/skip-to-content/skip-to-content.js +1 -1
  130. package/components/skip-to-content/skip-to-content.spec.js +2 -2
  131. package/components/status/_macro.njk +2 -2
  132. package/components/status/_macro.spec.js +5 -9
  133. package/components/status/example-status-dead.njk +1 -1
  134. package/components/status/example-status-error.njk +1 -1
  135. package/components/status/example-status-pending.njk +1 -1
  136. package/components/status/example-status-small.njk +1 -1
  137. package/components/status/example-status-success.njk +1 -1
  138. package/components/summary/_macro.njk +4 -5
  139. package/components/summary/_macro.spec.js +27 -9
  140. package/components/table/_macro.spec.js +6 -10
  141. package/components/table/scrollable-table.dom.js +1 -1
  142. package/components/table/scrollable-table.js +1 -1
  143. package/components/table/sortable-table.js +4 -4
  144. package/components/table/table.spec.js +21 -17
  145. package/components/table-of-contents/_macro.njk +31 -31
  146. package/components/table-of-contents/_macro.spec.js +3 -11
  147. package/components/table-of-contents/toc.dom.js +1 -1
  148. package/components/table-of-contents/toc.spec.js +36 -32
  149. package/components/tabs/example-tabs-details.njk +1 -1
  150. package/components/tabs/tabs.dom.js +1 -1
  151. package/components/tabs/tabs.js +8 -8
  152. package/components/text-indent/_macro.spec.js +2 -6
  153. package/components/textarea/textarea.dom.js +1 -1
  154. package/components/textarea/textarea.spec.js +8 -8
  155. package/components/timeout-modal/_macro.spec.js +1 -3
  156. package/components/timeout-modal/timeout-modal.dom.js +1 -1
  157. package/components/timeout-modal/timeout-modal.spec.js +10 -10
  158. package/components/timeout-panel/_macro.njk +16 -17
  159. package/components/timeout-panel/_macro.spec.js +1 -1
  160. package/components/timeout-panel/timeout-panel.dom.js +1 -1
  161. package/components/timeout-panel/timeout-panel.spec.js +8 -8
  162. package/components/video/_macro.spec.js +1 -5
  163. package/components/video/video.dom.js +1 -1
  164. package/components/video/video.spec.js +16 -12
  165. package/css/main.css +1 -1
  166. package/favicons/safari-pinned-tab.svg +23 -23
  167. package/js/analytics.js +15 -14
  168. package/js/cookies-settings.dom.js +1 -1
  169. package/js/cookies-settings.spec.js +19 -19
  170. package/js/domready.js +1 -1
  171. package/js/fetch.js +1 -1
  172. package/js/inpagelink.js +3 -3
  173. package/js/main.js +1 -0
  174. package/js/print-button.js +1 -1
  175. package/js/timeout.js +1 -1
  176. package/package.json +2 -1
  177. package/scripts/main.es5.js +1 -1
  178. package/scripts/main.js +1 -1
  179. package/scss/base/_typography.scss +8 -2
  180. package/scss/main.scss +1 -0
  181. package/scss/overrides/hcm.scss +8 -1
  182. package/scss/vars/_colors.scss +2 -1
@@ -225,7 +225,7 @@ describe('macro: footer', () => {
225
225
 
226
226
  expect(panelSpy.occurrences).toContainEqual(
227
227
  expect.objectContaining({
228
- type: 'warn',
228
+ variant: 'warn',
229
229
  classes: 'ons-panel--warn--footer',
230
230
  }),
231
231
  );
@@ -278,7 +278,7 @@ describe('macro: footer', () => {
278
278
  it('renders expected column titles', () => {
279
279
  const $ = cheerio.load(renderComponent('footer', params));
280
280
 
281
- const titleHeadings = mapAll($('.ons-footer__heading'), node => node.text().trim());
281
+ const titleHeadings = mapAll($('.ons-footer__heading'), (node) => node.text().trim());
282
282
  expect(titleHeadings).toEqual(['First column', 'Second column']);
283
283
  });
284
284
 
@@ -411,6 +411,18 @@ describe('macro: footer', () => {
411
411
  });
412
412
  });
413
413
  });
414
+ describe('correct link for language', () => {
415
+ it('has the Welsh lang link when the default Welsh lang ons icon is present', () => {
416
+ const $ = cheerio.load(renderComponent('footer', { lang: 'cy' }));
417
+
418
+ expect($('.ons-footer__poweredBy-link').attr('href')).toBe('https://cy.ons.gov.uk/');
419
+ });
420
+ it('has the English lang link when the default English lang ons icon is present', () => {
421
+ const $ = cheerio.load(renderComponent('footer', { lang: 'en' }));
422
+
423
+ expect($('.ons-footer__poweredBy-link').attr('href')).toBe('https://www.ons.gov.uk/');
424
+ });
425
+ });
414
426
  describe('provided poweredBy logo', () => {
415
427
  describe.each([
416
428
  [
@@ -1,19 +1,19 @@
1
1
  {% macro patternLibExampleGrid(params) %}
2
- {% if params.container -%}
3
- <div class="ons-container">
4
- {% endif -%}
2
+ {% if params.container -%}
3
+ <div class="ons-container">
4
+ {% endif -%}
5
5
 
6
- <div class="ons-grid">
7
- {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) -%}
8
- {% for i in range(0, item.repeat | default(1) ) -%}
9
- <div class="ons-grid__col ons-col-{{ item.col }}@m {{ item.classes }}">
10
- <div class="ons-pl-grid-col">{{ item.col }} col</div>
11
- </div>
12
- {%- endfor %}
13
- {%- endfor %}
14
- </div>
15
-
16
- {% if params.container -%}
6
+ <div class="ons-grid">
7
+ {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) -%}
8
+ {% for i in range(0, item.repeat | default(1) ) -%}
9
+ <div class="ons-grid__col ons-col-{{ item.col }}@m {{ item.classes }}">
10
+ <div class="ons-pl-grid-col">{{ item.col }} col</div>
11
+ </div>
12
+ {%- endfor %}
13
+ {%- endfor %}
17
14
  </div>
18
- {% endif -%}
15
+
16
+ {% if params.container -%}
17
+ </div>
18
+ {% endif -%}
19
19
  {% endmacro %}
@@ -17,6 +17,10 @@
17
17
  <svg class="{% if params.iconSize %}ons-icon ons-icon--{{ params.iconSize }}{% else %}ons-icon{% endif %}{{ iconClasses }}" viewBox="0 0 17 13" xmlns="http://www.w3.org/2000/svg" focusable="false" fill="currentColor">
18
18
  <path d="M6.4.2.3 6.4c-.2.2-.2.4 0 .6l6.2 5.8c.2.2.4.1.6 0l.8-.9c.2-.2.1-.4 0-.6l-4-3.7h12.5c.2 0 .4-.2.4-.4V6c0-.2-.2-.4-.4-.4H3.8l4-4c.2-.1.2-.4.1-.5L7 .2c-.1-.1-.4-.1-.6 0z"/>
19
19
  </svg>
20
+ {%- elif params.iconType == "arrow-up" -%}
21
+ <svg class="{% if params.iconSize %}ons-icon ons-icon--{{ params.iconSize }}{% else %}ons-icon{% endif %}{{ iconClasses }}" viewBox="0 0 13 20" xmlns="http://www.w3.org/2000/svg" focusable="false" fill="currentColor">
22
+ <path fill="currentColor" d="M6.5 0L0 6.5 1.4 8l4-4v12.7h2V4l4.3 4L13 6.4z"></path>
23
+ </svg>
20
24
  {%- elif params.iconType == "check" -%}
21
25
  <svg class="{% if params.iconSize %}ons-icon ons-icon--{{ params.iconSize }}{% else %}ons-icon{% endif %}{{ iconClasses }}" viewBox="0 0 13 10" xmlns="http://www.w3.org/2000/svg" focusable="false" fill="currentColor">
22
26
  <path d="M14.35,3.9l-.71-.71a.5.5,0,0,0-.71,0h0L5.79,10.34,3.07,7.61a.51.51,0,0,0-.71,0l-.71.71a.51.51,0,0,0,0,.71l3.78,3.78a.5.5,0,0,0,.71,0h0L14.35,4.6A.5.5,0,0,0,14.35,3.9Z" transform="translate(-1.51 -3.04)"/>
@@ -73,9 +77,9 @@
73
77
  </svg>
74
78
  {%- elif params.iconType == "twitter" -%}
75
79
  <svg class="{% if params.iconSize %}ons-icon ons-icon--{{ params.iconSize }}{% else %}ons-icon{% endif %}{{ iconClasses }}" id="icon-twitter" viewBox="0 0 90.01 90.01" xmlns="http://www.w3.org/2000/svg" focusable="false" aria-hidden="true">
76
- <polygon points="24.89,23.01 57.79,66.99 65.24,66.99 32.34,23.01"/>
77
- <path d="M 45 0 L 45 0 C 20.147 0 0 20.147 0 45 v 0 c 0 24.853 20.147 45 45 45 h 0 c 24.853 0 45 -20.147 45 -45 v 0 C 90 20.147 69.853 0 45 0 z M 56.032 70.504 L 41.054 50.477 L 22.516 70.504 h -4.765 L 38.925 47.63 L 17.884 19.496 h 16.217 L 47.895 37.94 l 17.072 -18.444 h 4.765 L 50.024 40.788 l 22.225 29.716 H 56.032 z"/>
78
- </svg>
80
+ <polygon points="24.89,23.01 57.79,66.99 65.24,66.99 32.34,23.01"/>
81
+ <path d="M 45 0 L 45 0 C 20.147 0 0 20.147 0 45 v 0 c 0 24.853 20.147 45 45 45 h 0 c 24.853 0 45 -20.147 45 -45 v 0 C 90 20.147 69.853 0 45 0 z M 56.032 70.504 L 41.054 50.477 L 22.516 70.504 h -4.765 L 38.925 47.63 L 17.884 19.496 h 16.217 L 47.895 37.94 l 17.072 -18.444 h 4.765 L 50.024 40.788 l 22.225 29.716 H 56.032 z"/>
82
+ </svg>
79
83
  {%- elif params.iconType == "instagram" -%}
80
84
  <svg class="{% if params.iconSize %}ons-icon ons-icon--{{ params.iconSize }}{% else %}ons-icon{% endif %}{{ iconClasses }}" id="icon-instagram" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" focusable="false" aria-hidden="true">
81
85
  <path d="M21.34,9.46c0.66,0,1.2,0.54,1.2,1.2c0,0.66-0.54,1.2-1.2,1.2c-0.66,0-1.2-0.54-1.2-1.2C20.14,10,20.68,9.46,21.34,9.46z M16,12.67c-1.84,0-3.33,1.49-3.33,3.33c0,1.84,1.49,3.33,3.33,3.33c1.84,0,3.33-1.49,3.33-3.33C19.33,14.16,17.84,12.67,16,12.67z M16,10.86c2.84,0,5.14,2.3,5.14,5.14c0,2.84-2.3,5.14-5.14,5.14c-2.84,0-5.14-2.3-5.14-5.14C10.86,13.16,13.16,10.86,16,10.86z M16.56,7.8h-1.11c-2.17,0-2.51,0.01-3.49,0.06c-0.97,0.04-1.5,0.21-1.86,0.34C9.64,8.39,9.3,8.6,8.95,8.95C8.6,9.3,8.39,9.64,8.2,10.1c-0.14,0.35-0.3,0.88-0.34,1.86c-0.04,0.98-0.06,1.32-0.06,3.49v1.11c0,2.17,0.01,2.51,0.06,3.49c0.04,0.97,0.21,1.5,0.34,1.86c0.18,0.47,0.4,0.8,0.75,1.15c0.35,0.35,0.68,0.57,1.15,0.75c0.35,0.14,0.88,0.3,1.86,0.34c0.94,0.04,1.29,0.06,3.23,0.06h1.61c1.94,0,2.3-0.02,3.23-0.06c0.97-0.04,1.5-0.21,1.86-0.34c0.47-0.18,0.8-0.4,1.15-0.75c0.35-0.35,0.57-0.68,0.75-1.15c0.14-0.35,0.3-0.88,0.34-1.86c0.04-0.94,0.06-1.29,0.06-3.23v-1.61c0-1.94-0.02-2.3-0.06-3.23c-0.04-0.97-0.21-1.5-0.34-1.86c-0.18-0.47-0.4-0.8-0.75-1.15C22.7,8.6,22.36,8.39,21.9,8.2c-0.35-0.14-0.88-0.3-1.86-0.34C19.06,7.82,18.72,7.8,16.56,7.8z M17.03,6c1.8,0,2.18,0.02,3.1,0.06c1.06,0.05,1.79,0.22,2.43,0.46c0.66,0.26,1.22,0.6,1.77,1.15c0.56,0.56,0.9,1.11,1.15,1.77c0.25,0.64,0.42,1.36,0.46,2.43c0.05,0.99,0.06,1.35,0.06,3.58v1.09c0,2.22-0.01,2.59-0.06,3.58c-0.05,1.06-0.22,1.79-0.46,2.43c-0.26,0.66-0.6,1.22-1.15,1.77c-0.56,0.56-1.11,0.9-1.77,1.15c-0.64,0.25-1.36,0.42-2.43,0.46C19.13,25.99,18.77,26,16.55,26h-1.09c-2.22,0-2.59-0.01-3.58-0.06c-1.06-0.05-1.79-0.22-2.43-0.46c-0.66-0.26-1.22-0.6-1.77-1.15c-0.56-0.56-0.9-1.11-1.15-1.77c-0.25-0.64-0.42-1.36-0.46-2.43C6.02,19.21,6,18.83,6,17.03v-2.06c0-1.8,0.02-2.18,0.06-3.1c0.05-1.06,0.22-1.79,0.46-2.43c0.26-0.66,0.6-1.22,1.15-1.77c0.56-0.56,1.11-0.9,1.77-1.15c0.64-0.25,1.36-0.42,2.43-0.46C12.79,6.02,13.17,6,14.97,6H17.03z M16,0C7.16,0,0,7.16,0,16s7.16,16,16,16s16-7.16,16-16c0-4.24-1.69-8.31-4.69-11.31S20.24,0,16,0z"/>
@@ -33,7 +33,7 @@ describe('macro: icon', () => {
33
33
  'crest',
34
34
  'ogl',
35
35
  'circle-lined',
36
- ])('icon type: %s', iconType => {
36
+ ])('icon type: %s', (iconType) => {
37
37
  it('passes jest-axe checks', async () => {
38
38
  const $ = cheerio.load(renderComponent('icon', { iconType }));
39
39
 
@@ -77,7 +77,7 @@ describe('macro: icon', () => {
77
77
  'twitter',
78
78
  'instagram',
79
79
  'linkedin',
80
- ])('icon type: %s', iconType => {
80
+ ])('icon type: %s', (iconType) => {
81
81
  it('has style variation class for provided icon size', () => {
82
82
  const $ = cheerio.load(
83
83
  renderComponent('icon', {
@@ -101,11 +101,7 @@ describe('macro: icon', () => {
101
101
  it(`has default alt text '${expectedAltText}'`, () => {
102
102
  const $ = cheerio.load(renderComponent('icon', { iconType }));
103
103
 
104
- expect(
105
- $('title')
106
- .text()
107
- .trim(),
108
- ).toBe(expectedAltText);
104
+ expect($('title').text().trim()).toBe(expectedAltText);
109
105
  });
110
106
 
111
107
  it('has provided alt text', () => {
@@ -116,11 +112,7 @@ describe('macro: icon', () => {
116
112
  }),
117
113
  );
118
114
 
119
- expect(
120
- $('title')
121
- .text()
122
- .trim(),
123
- ).toBe('Example alt text');
115
+ expect($('title').text().trim()).toBe('Example alt text');
124
116
  });
125
117
  });
126
118
  });
@@ -42,11 +42,7 @@ describe('macro: image', () => {
42
42
  }),
43
43
  );
44
44
 
45
- expect(
46
- $('.ons-image__caption')
47
- .text()
48
- .trim(),
49
- ).toBe('Example image caption');
45
+ expect($('.ons-image__caption').text().trim()).toBe('Example image caption');
50
46
  });
51
47
 
52
48
  describe('mode: url', () => {
@@ -68,7 +68,6 @@
68
68
  "accessiblePlaceholder": params.accessiblePlaceholder,
69
69
  "inline": params.label.inline
70
70
  }) }}
71
-
72
71
  {% endif %}
73
72
 
74
73
  {% if params.prefix or params.suffix %}
@@ -103,16 +102,16 @@
103
102
  {% elif params.searchButton %}
104
103
  <span class="ons-grid--flex ons-input_search-button{% if params.label.description %} ons-input--with-text-description{% endif %}">
105
104
  {% if params.accessiblePlaceholder %}
106
- {{ onsLabel({
107
- "for": params.id,
108
- "id": params.label.id,
109
- "text": params.label.text,
110
- "classes": params.label.classes,
111
- "attributes": params.label.attributes,
112
- "accessiblePlaceholder": params.accessiblePlaceholder,
113
- "inline": params.label.inline
114
- }) }}
115
- {% endif %}
105
+ {{ onsLabel({
106
+ "for": params.id,
107
+ "id": params.label.id,
108
+ "text": params.label.text,
109
+ "classes": params.label.classes,
110
+ "attributes": params.label.attributes,
111
+ "accessiblePlaceholder": params.accessiblePlaceholder,
112
+ "inline": params.label.inline
113
+ }) }}
114
+ {% endif %}
116
115
 
117
116
  {{ input | safe }}
118
117
  {%- set buttonLabel -%}
@@ -138,23 +137,23 @@
138
137
  </span>
139
138
  {% else %}
140
139
  {% if params.accessiblePlaceholder %}
141
- <span class="ons-grid--flex {% if params.label.description %} ons-input--with-text-description{% endif %}">
140
+ <span class="ons-grid--flex {% if params.label.description %} ons-input--with-text-description{% endif %}">
142
141
  {% if params.accessiblePlaceholder %}
143
142
  {{ onsLabel({
144
- "for": params.id,
145
- "id": params.label.id,
146
- "text": params.label.text,
147
- "classes": params.label.classes,
148
- "attributes": params.label.attributes,
149
- "accessiblePlaceholder": params.accessiblePlaceholder,
150
- "inline": params.label.inline
151
- }) }}
143
+ "for": params.id,
144
+ "id": params.label.id,
145
+ "text": params.label.text,
146
+ "classes": params.label.classes,
147
+ "attributes": params.label.attributes,
148
+ "accessiblePlaceholder": params.accessiblePlaceholder,
149
+ "inline": params.label.inline
150
+ }) }}
152
151
  {% endif %}
153
152
  {% endif %}
154
153
  {{ input | safe }}
155
154
  {% if params.accessiblePlaceholder %}
156
- </span>
157
- {% endif %}
155
+ </span>
156
+ {% endif %}
158
157
  {% endif %}
159
158
  {% endset %}
160
159
 
@@ -163,7 +162,7 @@
163
162
  {% call onsCharLimit({
164
163
  "id": params.id ~ "-check",
165
164
  "limit": params.charCheckLimit.limit,
166
- "type": "check",
165
+ "variant": "check",
167
166
  "charCountSingular": params.charCheckLimit.charCountSingular,
168
167
  "charCountPlural": params.charCheckLimit.charCountPlural,
169
168
  "charCountOverLimitSingular": params.charCheckLimit.charCountOverLimitSingular,
@@ -617,7 +617,7 @@ describe('macro: input', () => {
617
617
  expect(charCheckLimitSpy.occurrences).toContainEqual({
618
618
  id: 'example-id-check',
619
619
  limit: 200,
620
- type: 'check',
620
+ variant: 'check',
621
621
  charCountSingular: 'You have {x} character remaining',
622
622
  charCountPlural: 'You have {x} characters remaining',
623
623
  charCountOverLimitSingular: '{x} character too many',
@@ -6,7 +6,7 @@ async function initialise() {
6
6
  if (checkedInputs.length) {
7
7
  const CharCheck = (await import('../char-check-limit/character-check')).default;
8
8
 
9
- checkedInputs.forEach(input => new CharCheck(input));
9
+ checkedInputs.forEach((input) => new CharCheck(input));
10
10
  }
11
11
  }
12
12
 
@@ -1,7 +1,4 @@
1
- import * as cheerio from 'cheerio';
2
-
3
- import axe from '../../tests/helpers/axe';
4
- import { renderComponent, templateFaker, setTestPage } from '../../tests/helpers/rendering';
1
+ import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
5
2
 
6
3
  const EXAMPLE_INPUT_MINIMAL = {
7
4
  id: 'example-id',
@@ -19,6 +19,7 @@
19
19
  &--placeholder {
20
20
  font-size: 1rem;
21
21
  font-weight: $font-weight-regular;
22
+ color: var(--ons-color-text-placeholder);
22
23
  left: 10px;
23
24
  position: absolute;
24
25
  top: 6px;
@@ -17,7 +17,7 @@
17
17
  </span>
18
18
  {%- endset %}
19
19
  {%- if params.description and params.accessiblePlaceholder -%}
20
- {{- description | safe -}}
20
+ {{- description | safe -}}
21
21
  {%- else -%}
22
22
  <label
23
23
  class="{% if params.inputType is not defined -%}ons-label{%- endif %}{{- ' ' + params.classes if params.classes else "" -}}{%- if params.description %} ons-label--with-description{%- endif %} {{- ' ons-label--placeholder' if params.accessiblePlaceholder else "" -}}"
@@ -43,5 +43,5 @@
43
43
  {{- description | safe -}}
44
44
  {%- endif -%}
45
45
  {%- endif %}
46
- {%- endif -%}
46
+ {%- endif -%}
47
47
  {% endmacro %}
@@ -119,12 +119,7 @@ describe('macro: label', () => {
119
119
  ])('has the provided `text` %s', (_, params) => {
120
120
  const $ = cheerio.load(renderComponent('label', params));
121
121
 
122
- expect(
123
- $('.ons-label')
124
- .text()
125
- .trim()
126
- .startsWith('Example label text'),
127
- ).toBe(true);
122
+ expect($('.ons-label').text().trim().startsWith('Example label text')).toBe(true);
128
123
  });
129
124
 
130
125
  describe('description element', () => {
@@ -147,11 +142,7 @@ describe('macro: label', () => {
147
142
  ])('has the provided `description` text %s', (_, params) => {
148
143
  const $ = cheerio.load(renderComponent('label', params));
149
144
 
150
- expect(
151
- $('.ons-label__description')
152
- .text()
153
- .trim(),
154
- ).toBe('An example description');
145
+ expect($('.ons-label__description').text().trim()).toBe('An example description');
155
146
  });
156
147
 
157
148
  it('has a default `id` attribute of `description-hint`', () => {
@@ -192,7 +183,7 @@ describe('macro: label', () => {
192
183
  expect($('.ons-label__description').hasClass('ons-input--with-description')).toBe(false);
193
184
  });
194
185
 
195
- it.each([['checkbox'], ['radio']])('has the description in an `aria-hidden` element when "%s" `inputType` is provided', inputType => {
186
+ it.each([['checkbox'], ['radio']])('has the description in an `aria-hidden` element when "%s" `inputType` is provided', (inputType) => {
196
187
  const $ = cheerio.load(
197
188
  renderComponent('label', {
198
189
  ...EXAMPLE_LABEL_WITH_DESCRIPTION,
@@ -205,7 +196,7 @@ describe('macro: label', () => {
205
196
 
206
197
  it.each([['checkbox'], ['radio']])(
207
198
  'has a duplicate description in a visually hidden element when "%s" `inputType` is provided',
208
- inputType => {
199
+ (inputType) => {
209
200
  const $ = cheerio.load(
210
201
  renderComponent('label', {
211
202
  ...EXAMPLE_LABEL_WITH_DESCRIPTION,
@@ -465,11 +465,7 @@ describe('macro: list', () => {
465
465
  }),
466
466
  );
467
467
 
468
- expect(
469
- $('.ons-list__prefix')
470
- .text()
471
- .trim(),
472
- ).toBe('[PREFIX].');
468
+ expect($('.ons-list__prefix').text().trim()).toBe('[PREFIX].');
473
469
  });
474
470
 
475
471
  it('marks `prefix` content as visually hidden when list element is not <ol>', () => {
@@ -521,11 +517,7 @@ describe('macro: list', () => {
521
517
  }),
522
518
  );
523
519
 
524
- expect(
525
- $('.ons-list__suffix')
526
- .text()
527
- .trim(),
528
- ).toBe('[SUFFIX]');
520
+ expect($('.ons-list__suffix').text().trim()).toBe('[SUFFIX]');
529
521
  });
530
522
 
531
523
  it('marks `suffix` content as visually hidden when list element is not <ol>', () => {
@@ -565,7 +557,7 @@ describe('macro: list', () => {
565
557
  });
566
558
 
567
559
  describe('icons', () => {
568
- it.each([['before'], ['after']])('renders default icon on list items when icon is positioned %s', iconPosition => {
560
+ it.each([['before'], ['after']])('renders default icon on list items when icon is positioned %s', (iconPosition) => {
569
561
  const faker = templateFaker();
570
562
  const iconsSpy = faker.spy('icon');
571
563
 
@@ -580,7 +572,7 @@ describe('macro: list', () => {
580
572
  expect(iconsSpy.occurrences[1]).toEqual({ iconType: 'check', iconSize: 'xl' });
581
573
  });
582
574
 
583
- it.each([['before'], ['after']])('renders a custom icon on specific list items when icon is positioned %s', iconPosition => {
575
+ it.each([['before'], ['after']])('renders a custom icon on specific list items when icon is positioned %s', (iconPosition) => {
584
576
  const faker = templateFaker();
585
577
  const iconsSpy = faker.spy('icon');
586
578
 
@@ -1,22 +1,22 @@
1
1
  {%- macro onsMessage(params) -%}
2
- <div class="ons-message ons-message--{{ params.type }}">
3
- <div class="ons-message__head">
4
- <dl class="ons-message__metadata" {% if params.id %} id="{{ params.id }}"{% endif %}>
5
- <div class="ons-message__sender">
6
- <dt class="ons-message__term ons-u-fw-b">{{ params.fromLabel }}:</dt>
7
- <dd class="ons-message__value ons-u-fw-b" {% if params.fromId %} id="{{ params.fromId }}"{% endif %} {% if params.fromName %} name="{{ params.fromName }}"{% endif %}>{{ params.fromValue }}</dd>
2
+ <div class="ons-message ons-message--{{ params.variant }}">
3
+ <div class="ons-message__head">
4
+ <dl class="ons-message__metadata" {% if params.id %} id="{{ params.id }}"{% endif %}>
5
+ <div class="ons-message__sender">
6
+ <dt class="ons-message__term ons-u-fw-b">{{ params.fromLabel }}:</dt>
7
+ <dd class="ons-message__value ons-u-fw-b" {% if params.fromId %} id="{{ params.fromId }}"{% endif %} {% if params.fromName %} name="{{ params.fromName }}"{% endif %}>{{ params.fromValue }}</dd>
8
+ </div>
9
+ <div class="ons-message__timestamp">
10
+ <dt class="ons-message__term ons-u-fs-s">{{ params.sentLabel }}:</dt>
11
+ <dd class="ons-message__value ons-u-fs-s" {% if params.sentId %} id="{{ params.sentId }}"{% endif %} {% if params.sentName %} name="{{ params.sentName }}"{% endif %}>{{ params.sentValue }}</dd>
12
+ </div>
13
+ </dl>
14
+ {% if params.unreadLink %}
15
+ <a class="ons-message__unread-link" {% if params.unreadLinkId %}id="{{ params.unreadLinkId }}"{% endif %} href="{{ params.unreadLink }}">{{ params.unreadLinkText }}</a>
16
+ {% endif %}
8
17
  </div>
9
- <div class="ons-message__timestamp">
10
- <dt class="ons-message__term ons-u-fs-s">{{ params.sentLabel }}:</dt>
11
- <dd class="ons-message__value ons-u-fs-s" {% if params.sentId %} id="{{ params.sentId }}"{% endif %} {% if params.sentName %} name="{{ params.sentName }}"{% endif %}>{{ params.sentValue }}</dd>
18
+ <div class="ons-message__body" {% if params.messageID %} id="{{ params.messageID }}"{% endif %}>
19
+ {{ caller() }}
12
20
  </div>
13
- </dl>
14
- {% if params.unreadLink %}
15
- <a class="ons-message__unread-link" {% if params.unreadLinkId %}id="{{ params.unreadLinkId }}"{% endif %} href="{{ params.unreadLink }}">{{ params.unreadLinkText }}</a>
16
- {% endif %}
17
21
  </div>
18
- <div class="ons-message__body" {% if params.messageID %} id="{{ params.messageID }}"{% endif %}>
19
- {{ caller() }}
20
- </div>
21
- </div>
22
22
  {%- endmacro -%}
@@ -6,7 +6,7 @@ import axe from '../../tests/helpers/axe';
6
6
  import { renderComponent } from '../../tests/helpers/rendering';
7
7
 
8
8
  const EXAMPLE_MESSAGE_MINIMAL = {
9
- type: 'sent',
9
+ variant: 'sent',
10
10
  fromLabel: 'From',
11
11
  fromValue: 'Example Sender',
12
12
  sentLabel: 'Date sent',
@@ -35,13 +35,13 @@ describe('macro: message', () => {
35
35
  it.each([
36
36
  ['sent', 'ons-message--sent'],
37
37
  ['received', 'ons-message--received'],
38
- ])('has appropriate class for provided `type` (%s -> %s)', (type, expectedClass) => {
38
+ ])('has appropriate class for provided `variant` (%s -> %s)', (variant, expectedClass) => {
39
39
  const $ = cheerio.load(
40
40
  renderComponent(
41
41
  'message',
42
42
  {
43
43
  ...EXAMPLE_MESSAGE_MINIMAL,
44
- type,
44
+ variant,
45
45
  },
46
46
  ['Message content...'],
47
47
  ),
@@ -59,21 +59,13 @@ describe('macro: message', () => {
59
59
  it('has the provided `fromLabel`', () => {
60
60
  const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
61
61
 
62
- expect(
63
- $('.ons-message__sender .ons-message__term')
64
- .text()
65
- .trim(),
66
- ).toBe('From:');
62
+ expect($('.ons-message__sender .ons-message__term').text().trim()).toBe('From:');
67
63
  });
68
64
 
69
65
  it('has the provided `fromValue`', () => {
70
66
  const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
71
67
 
72
- expect(
73
- $('.ons-message__sender .ons-message__value')
74
- .text()
75
- .trim(),
76
- ).toBe('Example Sender');
68
+ expect($('.ons-message__sender .ons-message__value').text().trim()).toBe('Example Sender');
77
69
  });
78
70
 
79
71
  it('has the provided `fromId`', () => {
@@ -85,21 +77,13 @@ describe('macro: message', () => {
85
77
  it('has the provided `sentLabel`', () => {
86
78
  const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
87
79
 
88
- expect(
89
- $('.ons-message__timestamp .ons-message__term')
90
- .text()
91
- .trim(),
92
- ).toBe('Date sent:');
80
+ expect($('.ons-message__timestamp .ons-message__term').text().trim()).toBe('Date sent:');
93
81
  });
94
82
 
95
83
  it('has the provided `sentValue`', () => {
96
84
  const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
97
85
 
98
- expect(
99
- $('.ons-message__timestamp .ons-message__value')
100
- .text()
101
- .trim(),
102
- ).toBe('Tue 4 Jul 2020 at 7:47');
86
+ expect($('.ons-message__timestamp .ons-message__value').text().trim()).toBe('Tue 4 Jul 2020 at 7:47');
103
87
  });
104
88
 
105
89
  it('has the provided `sentId`', () => {
@@ -117,20 +101,12 @@ describe('macro: message', () => {
117
101
  it('has the provided `unreadLinkText`', () => {
118
102
  const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE, ['Message content...']));
119
103
 
120
- expect(
121
- $('.ons-message__unread-link')
122
- .text()
123
- .trim(),
124
- ).toBe('Unread message');
104
+ expect($('.ons-message__unread-link').text().trim()).toBe('Unread message');
125
105
  });
126
106
 
127
107
  it('has the message content', () => {
128
108
  const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
129
109
 
130
- expect(
131
- $('.ons-message__body')
132
- .text()
133
- .trim(),
134
- ).toBe('Message content...');
110
+ expect($('.ons-message__body').text().trim()).toBe('Message content...');
135
111
  });
136
112
  });
@@ -85,31 +85,19 @@ describe('macro: message-list', () => {
85
85
  it('has `unreadText` for unread messages', () => {
86
86
  const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST));
87
87
 
88
- expect(
89
- $('#message1 .ons-message-item__unread')
90
- .text()
91
- .trim(),
92
- ).toBe('(New)');
88
+ expect($('#message1 .ons-message-item__unread').text().trim()).toBe('(New)');
93
89
  });
94
90
 
95
91
  it('has visually hidden label `fromLabel`', () => {
96
92
  const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_MINIMAL));
97
93
 
98
- expect(
99
- $('.ons-message-item__metadata-term--from:first')
100
- .text()
101
- .trim(),
102
- ).toBe('From:');
94
+ expect($('.ons-message-item__metadata-term--from:first').text().trim()).toBe('From:');
103
95
  });
104
96
 
105
97
  it('has visually hidden label `dateLabel`', () => {
106
98
  const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_MINIMAL));
107
99
 
108
- expect(
109
- $('.ons-message-item__metadata-term--date:first')
110
- .text()
111
- .trim(),
112
- ).toBe('Date:');
100
+ expect($('.ons-message-item__metadata-term--date:first').text().trim()).toBe('Date:');
113
101
  });
114
102
 
115
103
  it('has visually hidden label `hiddenReadLabel`', () => {
@@ -123,31 +111,11 @@ describe('macro: message-list', () => {
123
111
 
124
112
  const $message2 = $('.ons-message-item:nth-child(2)');
125
113
 
126
- expect(
127
- $message2
128
- .find('.ons-message-item__subject')
129
- .text()
130
- .trim(),
131
- ).toBe('Another example message subject');
114
+ expect($message2.find('.ons-message-item__subject').text().trim()).toBe('Another example message subject');
132
115
  expect($message2.find('.ons-message-item__subject').attr('id')).toBe('message2');
133
- expect(
134
- $message2
135
- .find('.ons-message-item__metadata-value--from')
136
- .text()
137
- .trim(),
138
- ).toBe('Example Sender 2');
139
- expect(
140
- $message2
141
- .find('.ons-message-item__metadata-value--date')
142
- .text()
143
- .trim(),
144
- ).toBe('Mon 1 Oct 2019 at 9:52');
145
- expect(
146
- $message2
147
- .find('.ons-message-item__body')
148
- .text()
149
- .trim(),
150
- ).toBe('Another example message.');
116
+ expect($message2.find('.ons-message-item__metadata-value--from').text().trim()).toBe('Example Sender 2');
117
+ expect($message2.find('.ons-message-item__metadata-value--date').text().trim()).toBe('Mon 1 Oct 2019 at 9:52');
118
+ expect($message2.find('.ons-message-item__body').text().trim()).toBe('Another example message.');
151
119
  expect($message2.find('.ons-message-item__link a').attr('href')).toBe('https://example.com/message/2');
152
120
  });
153
121
 
@@ -22,18 +22,14 @@ describe('macro: modal', () => {
22
22
  it('has expected `title`', () => {
23
23
  const $ = cheerio.load(renderComponent('modal', EXAMPLE_MODAL_BASIC));
24
24
 
25
- const title = $('.ons-modal__title')
26
- .html()
27
- .trim();
25
+ const title = $('.ons-modal__title').html().trim();
28
26
  expect(title).toBe('Modal title');
29
27
  });
30
28
 
31
29
  it('has expected `body`', () => {
32
30
  const $ = cheerio.load(renderComponent('modal', EXAMPLE_MODAL_BASIC));
33
31
 
34
- const title = $('.ons-modal__body')
35
- .html()
36
- .trim();
32
+ const title = $('.ons-modal__body').html().trim();
37
33
  expect(title).toBe('Modal body text');
38
34
  });
39
35
 
@@ -64,9 +60,7 @@ describe('macro: modal', () => {
64
60
  it('calls with content', () => {
65
61
  const $ = cheerio.load(renderComponent('modal', { EXAMPLE_MODAL_BASIC }, 'Example content...'));
66
62
 
67
- const content = $('.ons-modal__body')
68
- .text()
69
- .trim();
63
+ const content = $('.ons-modal__body').text().trim();
70
64
  expect(content).toBe('Example content...');
71
65
  });
72
66
 
@@ -7,7 +7,7 @@ async function modals() {
7
7
  if (modals.length && !timeouts.length) {
8
8
  const Modal = (await import('./modal')).default;
9
9
 
10
- modals.forEach(component => new Modal(component));
10
+ modals.forEach((component) => new Modal(component));
11
11
  }
12
12
  }
13
13