@ons/design-system 50.0.1 → 53.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 +35 -15
  2. package/components/access-code/_macro.njk +1 -1
  3. package/components/access-code/_macro.spec.js +162 -0
  4. package/components/access-code/uac.spec.js +26 -0
  5. package/components/accordion/_macro.spec.js +224 -0
  6. package/components/accordion/accordion.spec.js +134 -0
  7. package/components/address-input/_macro.njk +1 -1
  8. package/components/address-input/_macro.spec.js +465 -0
  9. package/components/address-input/autosuggest.address.js +5 -4
  10. package/components/address-input/autosuggest.address.setter.js +9 -3
  11. package/components/address-input/autosuggest.address.spec.js +733 -0
  12. package/components/address-output/_macro.njk +6 -6
  13. package/components/address-output/_macro.spec.js +122 -0
  14. package/components/autosuggest/_macro.njk +1 -1
  15. package/components/autosuggest/_macro.spec.js +229 -0
  16. package/components/autosuggest/autosuggest.helpers.js +2 -3
  17. package/components/autosuggest/autosuggest.helpers.spec.js +85 -0
  18. package/components/autosuggest/autosuggest.js +4 -2
  19. package/components/autosuggest/autosuggest.spec.js +625 -0
  20. package/components/autosuggest/autosuggest.ui.js +6 -2
  21. package/components/breadcrumbs/_macro.spec.js +129 -0
  22. package/components/button/_button.scss +75 -33
  23. package/components/button/_macro.njk +6 -6
  24. package/components/button/_macro.spec.js +446 -0
  25. package/components/button/button.spec.js +290 -0
  26. package/components/call-to-action/_macro.njk +3 -1
  27. package/components/call-to-action/_macro.spec.js +52 -0
  28. package/components/card/_macro.njk +26 -19
  29. package/components/card/_macro.spec.js +261 -0
  30. package/components/char-check-limit/_macro.spec.js +73 -0
  31. package/components/char-check-limit/character-check.spec.js +196 -0
  32. package/components/char-check-limit/character-limit.js +1 -1
  33. package/components/checkboxes/_checkbox-macro.spec.js +419 -0
  34. package/components/checkboxes/_macro.njk +1 -3
  35. package/components/checkboxes/_macro.spec.js +306 -0
  36. package/components/checkboxes/checkbox-with-autoselect.js +2 -1
  37. package/components/checkboxes/checkboxes.spec.js +208 -0
  38. package/components/code-highlight/_macro.spec.js +56 -0
  39. package/components/code-highlight/code-highlight.spec.js +18 -0
  40. package/components/collapsible/_macro.spec.js +204 -0
  41. package/components/collapsible/collapsible.js +2 -1
  42. package/components/collapsible/collapsible.spec.js +236 -0
  43. package/components/content-pagination/_macro.spec.js +199 -0
  44. package/components/cookies-banner/_macro.njk +1 -1
  45. package/components/cookies-banner/_macro.spec.js +171 -0
  46. package/components/cookies-banner/cookies-banner.spec.js +90 -0
  47. package/components/date-input/_macro.njk +6 -3
  48. package/components/date-input/_macro.spec.js +286 -0
  49. package/components/document-list/_macro.njk +3 -5
  50. package/components/document-list/_macro.spec.js +491 -0
  51. package/components/download-resources/download-resources.spec.js +540 -0
  52. package/components/duration/_macro.njk +7 -6
  53. package/components/duration/_macro.spec.js +251 -0
  54. package/components/error/_macro.spec.js +97 -0
  55. package/components/external-link/_macro.njk +5 -2
  56. package/components/external-link/_macro.spec.js +77 -0
  57. package/components/feedback/_macro.njk +5 -3
  58. package/components/feedback/_macro.spec.js +122 -0
  59. package/components/field/_macro.njk +2 -2
  60. package/components/field/_macro.spec.js +97 -0
  61. package/components/fieldset/_macro.njk +3 -3
  62. package/components/fieldset/_macro.spec.js +173 -0
  63. package/components/footer/_footer.scss +19 -4
  64. package/components/footer/_macro.njk +106 -137
  65. package/components/footer/_macro.spec.js +678 -0
  66. package/components/header/_header.scss +65 -46
  67. package/components/header/_macro.njk +173 -121
  68. package/components/header/_macro.spec.js +618 -0
  69. package/components/hero/_hero.scss +30 -143
  70. package/components/hero/_macro.njk +12 -23
  71. package/components/hero/_macro.spec.js +218 -0
  72. package/components/icons/_macro.njk +258 -30
  73. package/components/icons/_macro.spec.js +140 -0
  74. package/components/images/_macro.njk +1 -1
  75. package/components/images/_macro.spec.js +121 -0
  76. package/components/input/_input-type.scss +12 -5
  77. package/components/input/_input.scss +8 -0
  78. package/components/input/_macro.njk +4 -5
  79. package/components/input/_macro.spec.js +658 -0
  80. package/components/label/_macro.spec.js +189 -0
  81. package/components/language-selector/_macro.njk +1 -1
  82. package/components/language-selector/_macro.spec.js +137 -0
  83. package/components/lists/_list.scss +4 -0
  84. package/components/lists/_macro.njk +4 -7
  85. package/components/lists/_macro.spec.js +618 -0
  86. package/components/message/_macro.spec.js +137 -0
  87. package/components/message-list/_macro.njk +7 -7
  88. package/components/message-list/_macro.spec.js +159 -0
  89. package/components/metadata/_macro.spec.js +167 -0
  90. package/components/modal/_macro.njk +6 -6
  91. package/components/modal/_macro.spec.js +87 -0
  92. package/components/modal/modal.spec.js +59 -0
  93. package/components/mutually-exclusive/_macro.njk +2 -2
  94. package/components/mutually-exclusive/_macro.spec.js +184 -0
  95. package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +203 -0
  96. package/components/mutually-exclusive/mutually-exclusive.date.spec.js +142 -0
  97. package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +141 -0
  98. package/components/mutually-exclusive/mutually-exclusive.email.spec.js +117 -0
  99. package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +213 -0
  100. package/components/mutually-exclusive/mutually-exclusive.number.spec.js +125 -0
  101. package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +131 -0
  102. package/components/navigation/_macro.njk +45 -38
  103. package/components/navigation/_macro.spec.js +329 -0
  104. package/components/navigation/_navigation.scss +20 -4
  105. package/components/navigation/navigation.dom.js +1 -1
  106. package/components/navigation/navigation.spec.js +232 -0
  107. package/components/pagination/_macro.njk +1 -1
  108. package/components/pagination/_macro.spec.js +411 -0
  109. package/components/panel/_macro.njk +6 -6
  110. package/components/panel/_macro.spec.js +423 -0
  111. package/components/password/_macro.spec.js +137 -0
  112. package/components/password/password.spec.js +40 -0
  113. package/components/phase-banner/_macro.spec.js +73 -0
  114. package/components/promotional-banner/_macro.spec.js +97 -0
  115. package/components/question/_macro.njk +16 -22
  116. package/components/question/_macro.spec.js +309 -0
  117. package/components/quote/_macro.spec.js +81 -0
  118. package/components/radios/_macro.njk +3 -6
  119. package/components/radios/_macro.spec.js +575 -0
  120. package/components/radios/radios.spec.js +180 -0
  121. package/components/related-content/_macro.njk +14 -21
  122. package/components/related-content/_macro.spec.js +133 -0
  123. package/components/related-content/_section-macro.njk +10 -0
  124. package/components/related-content/_section-macro.spec.js +43 -0
  125. package/components/relationships/_macro.spec.js +108 -0
  126. package/components/relationships/relationships.spec.js +84 -0
  127. package/components/reply/_macro.njk +2 -2
  128. package/components/reply/_macro.spec.js +69 -0
  129. package/components/reply/reply.spec.js +78 -0
  130. package/components/search/_macro.njk +14 -12
  131. package/components/search/_macro.spec.js +44 -0
  132. package/components/search/_search.scss +7 -7
  133. package/components/section-navigation/_macro.njk +7 -2
  134. package/components/section-navigation/_macro.spec.js +206 -0
  135. package/components/select/_macro.njk +3 -3
  136. package/components/select/_macro.spec.js +203 -0
  137. package/components/select/select.spec.js +56 -0
  138. package/components/share-page/_macro.njk +6 -4
  139. package/components/share-page/_macro.spec.js +110 -0
  140. package/components/skip-to-content/_macro.spec.js +57 -0
  141. package/components/skip-to-content/skip-to-content.spec.js +44 -0
  142. package/components/status/_macro.spec.js +77 -0
  143. package/components/summary/_macro.njk +5 -5
  144. package/components/summary/_macro.spec.js +472 -0
  145. package/components/table/_macro.njk +2 -2
  146. package/components/table/_macro.spec.js +557 -0
  147. package/components/table/table.spec.js +155 -0
  148. package/components/table-of-contents/_macro.njk +35 -35
  149. package/components/table-of-contents/_macro.spec.js +178 -0
  150. package/components/table-of-contents/toc.js +29 -25
  151. package/components/table-of-contents/toc.spec.js +61 -0
  152. package/components/tabs/_macro.njk +1 -1
  153. package/components/tabs/_macro.spec.js +79 -0
  154. package/components/tabs/tabs.spec.js +162 -0
  155. package/components/text-indent/_macro.spec.js +52 -0
  156. package/components/textarea/_macro.njk +5 -3
  157. package/components/textarea/_macro.spec.js +300 -0
  158. package/components/textarea/textarea.spec.js +98 -0
  159. package/components/timeline/_macro.njk +3 -3
  160. package/components/timeline/_macro.spec.js +81 -0
  161. package/components/timeout-modal/_macro.spec.js +68 -0
  162. package/components/timeout-modal/timeout-modal.spec.js +226 -0
  163. package/components/timeout-panel/_macro.njk +0 -1
  164. package/components/timeout-panel/_macro.spec.js +54 -0
  165. package/components/timeout-panel/timeout-panel.dom.js +1 -2
  166. package/components/timeout-panel/timeout-panel.spec.js +161 -0
  167. package/components/upload/_macro.spec.js +75 -0
  168. package/components/video/_macro.spec.js +34 -0
  169. package/css/census.css +3 -1
  170. package/css/ids.css +2 -0
  171. package/css/main.css +1 -1
  172. package/img/dummy-brand-logo.svg +1 -0
  173. package/js/cookies-settings.spec.js +154 -0
  174. package/layout/_template.njk +7 -4
  175. package/package.json +10 -23
  176. package/scripts/main.es5.js +2 -2
  177. package/scripts/main.js +1 -1
  178. package/scss/ids.scss +2 -0
  179. package/scss/settings/_census.scss +141 -0
  180. package/scss/settings/_ids.scss +48 -0
  181. package/scss/utilities/_margin.scss +1 -0
  182. package/scss/vars/_colors.scss +5 -2
@@ -1,40 +1,47 @@
1
1
  {% macro onsNavigation(params) %}
2
2
  {% from "components/button/_macro.njk" import onsButton %}
3
3
  {% from "components/autosuggest/_macro.njk" import onsAutosuggest %}
4
- <div class="ons-navigation-wrapper">
5
- <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
6
- {% if params.siteSearchAutosuggest is defined and params.siteSearchAutosuggest and isPatternLib is defined and isPatternLib %}
4
+ <div class="ons-navigation-wrapper{% if params.variants == 'neutral' %} ons-navigation-wrapper--neutral{% endif %}">
5
+ <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
6
+ {% if params.navigation.siteSearchAutosuggest is defined and params.navigation.siteSearchAutosuggest and isPatternLib is defined and isPatternLib %}
7
7
  <div class="ons-navigation-search ons-js-navigation-search">
8
+ {% set autosuggestClasses = "ons-input-search ons-input-search--icon" %}
9
+ {% set autosuggestLabelClasses = "ons-u-pl-m" %}
10
+ {% if params.variants == "neutral" %}
11
+ {% set autosuggestClasses = autosuggestClasses + ' ons-input-search--dark' %}
12
+ {% else %}
13
+ {% set autosuggestLabelClasses = autosuggestLabelClasses + ' ons-label--white' %}
14
+ {% endif %}
8
15
  {{ onsAutosuggest({
9
16
  "id": "ons-site-search",
10
17
  "containerClasses": "ons-autosuggest-input--header",
11
- "classes": "ons-input--ghost ons-input-search ons-input-search--icon",
18
+ "classes": autosuggestClasses,
12
19
  "label": {
13
- "text": params.siteSearchAutosuggest.label,
20
+ "text": params.navigation.siteSearchAutosuggest.label,
14
21
  "id": "ons-site-search-label",
15
- "classes": "ons-label--white ons-u-pl-m"
22
+ "classes": autosuggestLabelClasses
16
23
  },
17
24
  "accessiblePlaceholder": true,
18
25
  "autocomplete": "off",
19
- "instructions": params.siteSearchAutosuggest.instructions,
20
- "ariaYouHaveSelected":params.siteSearchAutosuggest.ariaYouHaveSelected,
21
- "ariaMinChars": params.siteSearchAutosuggest.ariaMinChars,
22
- "ariaResultsLabel": params.siteSearchAutosuggest.ariaResultsLabel,
23
- "ariaOneResult": params.siteSearchAutosuggest.ariaOneResult,
24
- "ariaNResults": params.siteSearchAutosuggest.ariaNResults,
25
- "ariaLimitedResults": params.siteSearchAutosuggest.ariaLimitedResults,
26
- "moreResults": params.siteSearchAutosuggest.moreResults,
27
- "resultsTitle": params.siteSearchAutosuggest.resultsTitle,
28
- "autosuggestData": params.siteSearchAutosuggest.autosuggestData,
29
- "noResults": params.siteSearchAutosuggest.noResults,
30
- "typeMore": params.siteSearchAutosuggest.typeMore
26
+ "instructions": params.navigation.siteSearchAutosuggest.instructions,
27
+ "ariaYouHaveSelected":params.navigation.siteSearchAutosuggest.ariaYouHaveSelected,
28
+ "ariaMinChars": params.navigation.siteSearchAutosuggest.ariaMinChars,
29
+ "ariaResultsLabel": params.navigation.siteSearchAutosuggest.ariaResultsLabel,
30
+ "ariaOneResult": params.navigation.siteSearchAutosuggest.ariaOneResult,
31
+ "ariaNResults": params.navigation.siteSearchAutosuggest.ariaNResults,
32
+ "ariaLimitedResults": params.navigation.siteSearchAutosuggest.ariaLimitedResults,
33
+ "moreResults": params.navigation.siteSearchAutosuggest.moreResults,
34
+ "resultsTitle": params.navigation.siteSearchAutosuggest.resultsTitle,
35
+ "autosuggestData": params.navigation.siteSearchAutosuggest.autosuggestData,
36
+ "noResults": params.navigation.siteSearchAutosuggest.noResults,
37
+ "typeMore": params.navigation.siteSearchAutosuggest.typeMore
31
38
  }) }}
32
39
  </div>
33
40
  {% endif %}
34
- <nav class="ons-navigation ons-js-navigation" id="{{ params.id }}" aria-label="{{ params.ariaLabel | default("Main menu") }}" data-analytics="header-navigation">
41
+ <nav class="ons-navigation ons-navigation--main ons-js-navigation" id="{{ params.navigation.id }}" aria-label="{{ params.navigation.ariaLabel | default("Main menu") }}" data-analytics="header-navigation">
35
42
  <ul class="ons-navigation__list">
36
- {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
37
- <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.currentPath) or (item.url != (params.siteBasePath | default('/')) and item.url in params.currentPath) }}">
43
+ {% for item in (params.navigation.itemsList if params.navigation.itemsList is iterable else params.navigation.itemsList.items()) %}
44
+ <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (item.url != (params.navigation.siteBasePath | default('/')) and item.url in params.navigation.currentPath) }}">
38
45
  <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
39
46
  </li>
40
47
  {% endfor %}
@@ -42,45 +49,45 @@
42
49
  </nav>
43
50
  </div>
44
51
  </div>
45
- {% if params.subNavigation is defined and params.subNavigation %}
46
- <nav class="ons-navigation ons-navigation--sub ons-u-d-no@xxs@l{{ ' ' + params.subNavigation.classes if params.subNavigation.classes is defined and params.subNavigation.classes }}" id="{{ params.subNavigation.id }}" aria-label="{{ params.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
47
- <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
52
+ {% if params.navigation.subNavigation is defined and params.navigation.subNavigation %}
53
+ <nav class="ons-navigation ons-navigation--sub ons-u-d-no@xxs@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes is defined and params.navigation.subNavigation.classes }}" id="{{ params.navigation.subNavigation.id }}" aria-label="{{ params.navigation.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
54
+ <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
48
55
  <ul class="ons-navigation__list ons-navigation__list">
49
- {% for item in (params.subNavigation.itemsList if params.subNavigation.itemsList is iterable else params.subNavigation.itemsList.items()) %}
50
- <li class="ons-navigation__item ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.subNavigation.currentPath) or (item.url != (params.subNavigation.siteBasePath | default('/')) and item.url in params.subNavigation.currentPath) }}">
56
+ {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
57
+ <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url != (params.navigation.subNavigation.siteBasePath | default('/')) and item.url in params.navigation.subNavigation.currentPath) }}">
51
58
  <a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
52
59
  </li>
53
60
  {% endfor %}
54
61
  </ul>
55
62
  </div>
56
63
  </nav>
57
- <div class="ons-u-d-no@l{{ ' ' + params.subNavigation.classes if params.subNavigation.classes is defined and params.subNavigation.classes }}">
64
+ <div class="ons-u-d-no@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes is defined and params.navigation.subNavigation.classes }}">
58
65
  {{ onsButton({
59
- "text": params.currentPageTitle,
66
+ "text": params.navigation.currentPageTitle,
60
67
  "classes": "ons-u-d-no ons-js-sub-navigation-button ons-btn--dropdown",
61
68
  "buttonStyle": "mobile",
62
69
  "attributes": {
63
70
  "aria-label": "Toggle section navigation",
64
- "aria-controls": params.subNavigation.id,
71
+ "aria-controls": params.navigation.subNavigation.id,
65
72
  "aria-haspopup": "true",
66
73
  "aria-expanded": "false"
67
74
  }
68
75
  }) }}
69
- <nav class="ons-navigation ons-navigation--sub-mobile ons-u-d-no proto-ons-js-secondary-nav ons-u-mt-xs" id="{{ params.subNavigation.id }}" aria-label="{{ params.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
70
- <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
71
- <ul class="ons-navigation__list">
76
+ <nav class="ons-navigation ons-navigation--sub-mobile ons-u-d-no ons-js-secondary-nav ons-u-mt-xs" id="{{ params.navigation.subNavigation.id }}--mobile" aria-hidden="true" aria-label="{{ params.navigation.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
77
+ <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
78
+ <ul class="ons-navigation__list ons-navigation__list--parent">
72
79
  <li class="ons-navigation__item">
73
- <a class="ons-navigation__link" href="{{ params.subNavigation.overviewURL }}">{{ params.subNavigation.overviewText | default('Overview') }}</a>
80
+ <a class="ons-navigation__link" href="{{ params.navigation.subNavigation.overviewURL }}">{{ params.navigation.subNavigation.overviewText | default('Overview') }}</a>
74
81
  </li>
75
- {% for item in (params.subNavigation.itemsList if params.subNavigation.itemsList is iterable else params.subNavigation.itemsList.items()) %}
76
- <li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.subNavigation.currentPath) or (item.url != (params.subNavigation.siteBasePath | default('/')) and item.url in params.subNavigation.currentPath) }}">
77
- <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
82
+ {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
83
+ <li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url != (params.navigation.subNavigation.siteBasePath | default('/')) and item.url in params.navigation.subNavigation.currentPath) }}">
84
+ <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}--mobile" {% endif %}>{{ item.title }}</a>
78
85
  {% if item.sections %}
79
86
  {% for section in item.sections %}
80
87
  {% if section.sectionTitle %}<h3 class="ons-navigation__list-header">{{ section.sectionTitle }}</h3>{% endif %}
81
- <ul class="ons-navigation__list ons-list--dashed ons-u-ml-s ons-u-mt-xs">
88
+ <ul class="ons-navigation__list ons-navigation__list--child ons-list--dashed ons-u-ml-s ons-u-mt-xs">
82
89
  {% for child in section.children %}
83
- <li class="ons-navigation__item ons-list__item {{ ' ons-navigation__item--active' if (child.url == params.subNavigation.currentPath) or (child.url != (params.subNavigation.sitsiteBasePatheBasePath | default('/')) and child.url in params.subNavigation.currentPath) }}">
90
+ <li class="ons-navigation__item ons-list__item {{ ' ons-navigation__item--active' if (child.url == params.navigation.subNavigation.currentPath) or (child.url != (params.navigation.subNavigation.sitsiteBasePatheBasePath | default('/')) and child.url in params.navigation.subNavigation.currentPath) }}">
84
91
  <a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.id is defined and child.id %}id="{{ child.id }}" {% endif %}>{{ child.title }}</a>
85
92
  </li>
86
93
  {% endfor %}
@@ -0,0 +1,329 @@
1
+ /** @jest-environment jsdom */
2
+
3
+ import * as cheerio from 'cheerio';
4
+
5
+ import axe from '../../tests/helpers/axe';
6
+ import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
7
+ import { mapAll } from '../../tests/helpers/cheerio';
8
+
9
+ const PARAMS = {
10
+ id: 'main-nav',
11
+ ariaLabel: 'Main menu',
12
+ currentPath: '#1',
13
+ currentPageTitle: 'Main nav item 2',
14
+ itemsList: [
15
+ {
16
+ title: 'Main nav item 1',
17
+ url: '#0',
18
+ classes: 'custom-class-main-item-1',
19
+ id: 'main-item-1',
20
+ },
21
+ {
22
+ title: 'Main nav item 2',
23
+ url: '#1',
24
+ classes: 'custom-class-main-item-2',
25
+ id: 'main-item-2',
26
+ },
27
+ ],
28
+ subNavigation: {
29
+ id: 'sub-nav',
30
+ overviewURL: '#overview',
31
+ overviewText: 'Overview',
32
+ ariaLabel: 'Section menu',
33
+ currentPath: '#1',
34
+ itemsList: [
35
+ {
36
+ title: 'Sub nav item 1',
37
+ url: '#0',
38
+ classes: 'custom-class-sub-item-1',
39
+ id: 'sub-item-1',
40
+ },
41
+ {
42
+ title: 'Sub nav item 2',
43
+ url: '#1',
44
+ classes: 'custom-class-sub-item-2',
45
+ id: 'sub-item-2',
46
+ sections: [
47
+ {
48
+ sectionTitle: 'Section 1',
49
+ children: [
50
+ {
51
+ title: 'Child item 1',
52
+ url: '#0',
53
+ },
54
+ {
55
+ title: 'Child item 2',
56
+ url: '#1',
57
+ },
58
+ ],
59
+ },
60
+ ],
61
+ },
62
+ ],
63
+ },
64
+ };
65
+
66
+ const SITE_SEARCH_AUTOSUGGEST = {
67
+ label: 'Search the design system',
68
+ instructions:
69
+ "Use up and down keys to navigate results once you've typed more than two characters. Use the enter key to select a result. Touch device users, explore by touch or with swipe gestures.",
70
+ ariaYouHaveSelected: 'You have selected',
71
+ ariaMinChars: 'Enter 3 or more characters for results.',
72
+ ariaResultsLabel: 'Search results',
73
+ ariaOneResult: 'There is one result available.',
74
+ ariaNResults: 'There are {n} results available.',
75
+ ariaLimitedResults: 'Results have been limited to 10 results. Type more characters to improve your search',
76
+ moreResults: 'Continue entering to improve results',
77
+ resultsTitle: 'Search results',
78
+ autosuggestData: '/search-index.json',
79
+ noResults: 'No results found',
80
+ typeMore: 'Continue entering to get results',
81
+ };
82
+
83
+ describe('macro: navigation', () => {
84
+ describe('level: container', () => {
85
+ it('passes jest-axe checks', async () => {
86
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
87
+
88
+ const results = await axe($.html());
89
+ expect(results).toHaveNoViolations();
90
+ });
91
+
92
+ it('has the correct container if `fullWidth`', () => {
93
+ const $ = cheerio.load(renderComponent('navigation', { navigation: { ...PARAMS, fullWidth: true } }));
94
+
95
+ expect($('.ons-container').hasClass('ons-container--full-width')).toBe(true);
96
+ });
97
+
98
+ it('has the correct container if `wide`', () => {
99
+ const $ = cheerio.load(renderComponent('navigation', { navigation: { ...PARAMS, wide: true } }));
100
+
101
+ expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
102
+ });
103
+
104
+ it('has the search autosuggest with correct output', () => {
105
+ const faker = templateFaker();
106
+ const autosuggestSpy = faker.spy('autosuggest', { suppressOutput: true });
107
+
108
+ faker.renderComponent('navigation', {
109
+ navigation: {
110
+ ...PARAMS,
111
+ siteSearchAutosuggest: {
112
+ ...SITE_SEARCH_AUTOSUGGEST,
113
+ },
114
+ },
115
+ });
116
+
117
+ expect(autosuggestSpy.occurrences[0]).toEqual({
118
+ ...SITE_SEARCH_AUTOSUGGEST,
119
+ accessiblePlaceholder: true,
120
+ autocomplete: 'off',
121
+ id: 'ons-site-search',
122
+ containerClasses: 'ons-autosuggest-input--header',
123
+ classes: 'ons-input-search ons-input-search--icon',
124
+ label: {
125
+ text: 'Search the design system',
126
+ id: 'ons-site-search-label',
127
+ classes: 'ons-u-pl-m ons-label--white',
128
+ },
129
+ });
130
+ });
131
+ });
132
+
133
+ describe('level: main navigation', () => {
134
+ it('has the provided `id` attribute', () => {
135
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
136
+
137
+ expect($('.ons-navigation--main').attr('id')).toBe('main-nav');
138
+ });
139
+
140
+ it('has the provided `aria-label` attribute', () => {
141
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
142
+
143
+ expect($('.ons-navigation--main').attr('aria-label')).toBe('Main menu');
144
+ });
145
+
146
+ it('has the correct link href for each list item', () => {
147
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
148
+
149
+ const values = mapAll($('.ons-navigation--main .ons-navigation__link'), node => node.attr('href'));
150
+ expect(values).toEqual(['#0', '#1']);
151
+ });
152
+
153
+ it('has the correct link text for each list item', () => {
154
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
155
+
156
+ const values = mapAll($('.ons-navigation--main .ons-navigation__link'), node => node.text().trim());
157
+ expect(values).toEqual(['Main nav item 1', 'Main nav item 2']);
158
+ });
159
+
160
+ it('has the provided custom class for each list item', () => {
161
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
162
+
163
+ expect($('.ons-navigation--main .ons-navigation__list > .ons-navigation__item').hasClass('custom-class-main-item-1')).toBe(true);
164
+ expect($('.ons-navigation--main .ons-navigation__list .ons-navigation__item:last-child').hasClass('custom-class-main-item-2')).toBe(
165
+ true,
166
+ );
167
+ });
168
+
169
+ it('has the provided id for each list item', () => {
170
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
171
+
172
+ expect($('.ons-navigation--main .ons-navigation__list > .ons-navigation__item .ons-navigation__link').attr('id')).toBe('main-item-1');
173
+ expect($('.ons-navigation--main .ons-navigation__list .ons-navigation__item:last-child .ons-navigation__link').attr('id')).toBe(
174
+ 'main-item-2',
175
+ );
176
+ });
177
+
178
+ it('has the active class on the correct item', () => {
179
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
180
+
181
+ expect(
182
+ $('.ons-navigation--main .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
183
+ ).toBe(true);
184
+ });
185
+ });
186
+
187
+ describe('level: sub navigation', () => {
188
+ it('renders a button with expected parameters', () => {
189
+ const faker = templateFaker();
190
+ const buttonSpy = faker.spy('button', { suppressOutput: true });
191
+
192
+ faker.renderComponent('navigation', { navigation: PARAMS });
193
+
194
+ expect(buttonSpy.occurrences).toContainEqual({
195
+ text: 'Main nav item 2',
196
+ classes: 'ons-u-d-no ons-js-sub-navigation-button ons-btn--dropdown',
197
+ buttonStyle: 'mobile',
198
+ attributes: {
199
+ 'aria-label': 'Toggle section navigation',
200
+ 'aria-controls': 'sub-nav',
201
+ 'aria-haspopup': 'true',
202
+ 'aria-expanded': 'false',
203
+ },
204
+ });
205
+ });
206
+
207
+ it('has the provided `id` attribute', () => {
208
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
209
+
210
+ expect($('.ons-navigation--sub').attr('id')).toBe('sub-nav');
211
+ });
212
+
213
+ it('has the provided `aria-label` attribute', () => {
214
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
215
+
216
+ expect($('.ons-navigation--sub').attr('aria-label')).toBe('Section menu');
217
+ });
218
+
219
+ it('has the correct link href for each list item', () => {
220
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
221
+
222
+ const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), node => node.attr('href'));
223
+ expect(values).toEqual(['#0', '#1']);
224
+ });
225
+
226
+ it('has the correct link text for each list item', () => {
227
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
228
+
229
+ const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), node => node.text().trim());
230
+ expect(values).toEqual(['Sub nav item 1', 'Sub nav item 2']);
231
+ });
232
+
233
+ it('has the provided custom class for each list item', () => {
234
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
235
+
236
+ expect($('.ons-navigation--sub .ons-navigation__list > .ons-navigation__item').hasClass('custom-class-sub-item-1')).toBe(true);
237
+ expect($('.ons-navigation--sub .ons-navigation__list .ons-navigation__item:last-child').hasClass('custom-class-sub-item-2')).toBe(
238
+ true,
239
+ );
240
+ });
241
+
242
+ it('has the provided id for each list item', () => {
243
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
244
+
245
+ expect($('.ons-navigation--sub .ons-navigation__list > .ons-navigation__item .ons-navigation__link').attr('id')).toBe('sub-item-1');
246
+ expect($('.ons-navigation--sub .ons-navigation__list .ons-navigation__item:last-child .ons-navigation__link').attr('id')).toBe(
247
+ 'sub-item-2',
248
+ );
249
+ });
250
+
251
+ it('has the active class on the correct item', () => {
252
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
253
+
254
+ expect(
255
+ $('.ons-navigation--sub .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
256
+ ).toBe(true);
257
+ });
258
+ });
259
+
260
+ describe('level: sub navigation mobile', () => {
261
+ it('has the provided `id` attribute', () => {
262
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
263
+
264
+ expect($('.ons-navigation--sub-mobile').attr('id')).toBe('sub-nav--mobile');
265
+ });
266
+
267
+ it('has the provided `aria-label` attribute', () => {
268
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
269
+
270
+ expect($('.ons-navigation--sub-mobile').attr('aria-label')).toBe('Section menu');
271
+ });
272
+
273
+ it('has the correct link href for each list item', () => {
274
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
275
+
276
+ const values = mapAll(
277
+ $('.ons-navigation__list--parent > li a').not('.ons-navigation__list--parent li .ons-navigation__list--child a'),
278
+ node => node.attr('href'),
279
+ );
280
+ expect(values).toEqual(['#overview', '#0', '#1']);
281
+ });
282
+
283
+ it('has the correct link text for each list item', () => {
284
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
285
+
286
+ const values = mapAll(
287
+ $('.ons-navigation__list--parent > li a').not('.ons-navigation__list--parent li .ons-navigation__list--child a'),
288
+ node => node.text().trim(),
289
+ );
290
+ expect(values).toEqual(['Overview', 'Sub nav item 1', 'Sub nav item 2']);
291
+ });
292
+
293
+ it('has the active class on the correct item', () => {
294
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
295
+
296
+ expect(
297
+ $('.ons-navigation--sub-mobile .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
298
+ ).toBe(true);
299
+ });
300
+
301
+ it('has the correct text for the child section title', () => {
302
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
303
+
304
+ expect($('.ons-navigation__list-header').text()).toBe('Section 1');
305
+ });
306
+
307
+ it('has the correct link href for each child list item', () => {
308
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
309
+
310
+ const values = mapAll($('.ons-navigation__list--child > li a'), node => node.attr('href'));
311
+ expect(values).toEqual(['#0', '#1']);
312
+ });
313
+
314
+ it('has the correct link text for each child list item', () => {
315
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
316
+
317
+ const values = mapAll($('.ons-navigation__list--child > li a'), node => node.text().trim());
318
+ expect(values).toEqual(['Child item 1', 'Child item 2']);
319
+ });
320
+
321
+ it('has the active class on the correct child item', () => {
322
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
323
+
324
+ expect(
325
+ $('.ons-navigation--sub-mobile .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
326
+ ).toBe(true);
327
+ });
328
+ });
329
+ });
@@ -18,6 +18,7 @@
18
18
  padding: 1rem;
19
19
 
20
20
  @include mq(l) {
21
+ background: none;
21
22
  bottom: 65px;
22
23
  padding: 0;
23
24
  position: absolute;
@@ -80,7 +81,7 @@
80
81
  .ons-navigation--sub & {
81
82
  &:hover,
82
83
  &--active {
83
- border-color: $color-text-link;
84
+ border-color: $color-branded;
84
85
  }
85
86
  }
86
87
  }
@@ -89,8 +90,8 @@
89
90
  &__link {
90
91
  color: $color-white;
91
92
  display: block;
92
- margin: 0 0.35rem;
93
- padding: 0.1rem 0.55rem;
93
+ margin: 0 0.75rem;
94
+ padding: 0.1rem 0;
94
95
  text-decoration: none;
95
96
 
96
97
  &--section {
@@ -109,7 +110,7 @@
109
110
  color: $color-text-link;
110
111
  &:hover,
111
112
  &:focus {
112
- color: $color-text-link;
113
+ color: $color-text-link-hover;
113
114
  }
114
115
  }
115
116
 
@@ -124,4 +125,19 @@
124
125
  &__item--active > &__link {
125
126
  font-weight: 700;
126
127
  }
128
+
129
+ &-wrapper {
130
+ &--neutral {
131
+ background: $color-header-light;
132
+ .ons-navigation__item {
133
+ &--active,
134
+ &:hover {
135
+ border-color: $color-branded;
136
+ }
137
+ .ons-navigation__link {
138
+ color: $color-branded-text;
139
+ }
140
+ }
141
+ }
142
+ }
127
143
  }
@@ -5,7 +5,7 @@ domready(async () => {
5
5
  const navigationEl = document.querySelector('.ons-js-navigation');
6
6
  const navigationHideClass = 'ons-u-d-no@xxs@l';
7
7
  const toggleSubNavigationBtn = document.querySelector('.ons-js-sub-navigation-button');
8
- const subNavigationEl = document.querySelector('.proto-ons-js-secondary-nav');
8
+ const subNavigationEl = document.querySelector('.ons-js-secondary-nav');
9
9
  const subNavigationHideClass = 'ons-u-d-no';
10
10
  const toggleSearchBtn = document.querySelector('.ons-js-toggle-search');
11
11
  const searchEl = document.querySelector('.ons-js-navigation-search');