@ons/design-system 54.0.1 → 55.2.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 (108) hide show
  1. package/components/access-code/_macro.njk +3 -3
  2. package/components/accordion/_macro.njk +1 -1
  3. package/components/address-input/_macro.njk +7 -7
  4. package/components/address-output/_macro.njk +7 -7
  5. package/components/autosuggest/_macro.njk +19 -19
  6. package/components/breadcrumbs/_macro.njk +3 -3
  7. package/components/browser-banner/_macro.njk +1 -1
  8. package/components/browser-banner/_macro.spec.js +31 -0
  9. package/components/button/_button.scss +21 -7
  10. package/components/button/_macro.njk +25 -25
  11. package/components/button/_macro.spec.js +2 -2
  12. package/components/call-to-action/_macro.njk +1 -1
  13. package/components/card/_macro.njk +10 -10
  14. package/components/checkboxes/_checkbox-macro.njk +9 -9
  15. package/components/checkboxes/_checkbox.scss +43 -10
  16. package/components/checkboxes/_macro.njk +10 -10
  17. package/components/checkboxes/checkbox-with-fieldset.js +6 -5
  18. package/components/checkboxes/checkboxes.dom.js +6 -9
  19. package/components/code-highlight/_macro.njk +1 -1
  20. package/components/collapsible/_collapsible.scss +2 -1
  21. package/components/collapsible/_macro.njk +7 -7
  22. package/components/date-input/_macro.njk +5 -5
  23. package/components/document-list/_macro.njk +29 -29
  24. package/components/document-list/document-list.scss +2 -0
  25. package/components/download-resources/download-resources.js +19 -0
  26. package/components/download-resources/download-resources.spec.js +95 -0
  27. package/components/duration/_macro.njk +9 -9
  28. package/components/duration/_macro.spec.js +0 -3
  29. package/components/error/_macro.njk +1 -1
  30. package/components/external-link/_macro.njk +2 -2
  31. package/components/external-link/_macro.spec.js +2 -2
  32. package/components/feedback/_macro.njk +2 -2
  33. package/components/field/_macro.njk +5 -5
  34. package/components/fieldset/_fieldset.scss +11 -1
  35. package/components/fieldset/_macro.njk +15 -14
  36. package/components/fieldset/_macro.spec.js +27 -5
  37. package/components/footer/_footer.scss +1 -0
  38. package/components/footer/_macro.njk +18 -18
  39. package/components/footer/_macro.spec.js +18 -0
  40. package/components/header/_header.scss +7 -2
  41. package/components/header/_macro.njk +63 -37
  42. package/components/header/_macro.spec.js +82 -14
  43. package/components/hero/_macro.njk +16 -16
  44. package/components/hero/_macro.spec.js +1 -1
  45. package/components/icons/_macro.njk +2 -2
  46. package/components/images/_macro.njk +3 -3
  47. package/components/input/_input-type.scss +7 -0
  48. package/components/input/_input.scss +13 -2
  49. package/components/input/_macro.njk +40 -34
  50. package/components/input/_macro.spec.js +64 -59
  51. package/components/label/_label.scss +1 -1
  52. package/components/label/_macro.njk +27 -15
  53. package/components/label/_macro.spec.js +31 -0
  54. package/components/language-selector/_macro.njk +1 -1
  55. package/components/lists/_macro.njk +22 -22
  56. package/components/lists/_macro.spec.js +2 -2
  57. package/components/message/_macro.njk +6 -6
  58. package/components/message/_message.scss +1 -0
  59. package/components/message-list/_macro.njk +1 -1
  60. package/components/metadata/_macro.njk +2 -2
  61. package/components/modal/_macro.njk +6 -6
  62. package/components/modal/_modal.scss +10 -9
  63. package/components/mutually-exclusive/_macro.njk +1 -1
  64. package/components/mutually-exclusive/mutually-exclusive.js +3 -1
  65. package/components/navigation/_macro.njk +9 -10
  66. package/components/navigation/_macro.spec.js +0 -1
  67. package/components/pagination/_macro.njk +3 -3
  68. package/components/pagination/_pagination.scss +1 -0
  69. package/components/panel/_macro.njk +38 -43
  70. package/components/panel/_macro.spec.js +24 -33
  71. package/components/panel/_panel.scss +13 -5
  72. package/components/phase-banner/_macro.njk +1 -1
  73. package/components/phase-banner/_macro.spec.js +31 -0
  74. package/components/phase-banner/_phase-banner.scss +1 -0
  75. package/components/promotional-banner/_macro.njk +2 -2
  76. package/components/question/_macro.njk +18 -18
  77. package/components/quote/_macro.njk +2 -2
  78. package/components/radios/_macro.njk +8 -8
  79. package/components/radios/_radio.scss +15 -3
  80. package/components/radios/check-radios.js +5 -1
  81. package/components/related-content/_macro.njk +2 -2
  82. package/components/relationships/_macro.njk +2 -2
  83. package/components/reply/_macro.njk +2 -2
  84. package/components/section-navigation/_macro.njk +2 -2
  85. package/components/select/_macro.njk +8 -8
  86. package/components/share-page/_macro.njk +2 -2
  87. package/components/skip-to-content/_skip.scss +2 -1
  88. package/components/status/_macro.njk +2 -2
  89. package/components/summary/_macro.njk +25 -25
  90. package/components/table/_macro.njk +13 -12
  91. package/components/table/_macro.spec.js +0 -27
  92. package/components/table/_table.scss +13 -6
  93. package/components/table/sortable-table.js +1 -0
  94. package/components/table-of-contents/_macro.njk +4 -4
  95. package/components/tabs/_tabs.scss +5 -3
  96. package/components/textarea/_macro.njk +8 -8
  97. package/components/timeline/_macro.njk +1 -1
  98. package/components/video/_macro.njk +1 -1
  99. package/css/census.css +1 -1
  100. package/css/ids.css +1 -1
  101. package/css/main.css +1 -1
  102. package/layout/_template.njk +57 -44
  103. package/package.json +1 -1
  104. package/scripts/main.es5.js +1 -1
  105. package/scripts/main.js +1 -1
  106. package/scss/base/_global.scss +1 -0
  107. package/scss/overrides/hcm.scss +205 -46
  108. package/scss/patternlib.scss +1 -0
@@ -3,6 +3,7 @@
3
3
  .ons-message {
4
4
  border-radius: math.div($grid-gutters, 2);
5
5
  margin-bottom: 2rem;
6
+ outline: 1px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show background
6
7
 
7
8
  &--sent {
8
9
  background: $color-info-tint;
@@ -4,7 +4,7 @@
4
4
  <li class="ons-message-item" aria-labelledby="{{ message.id }}">
5
5
  <h3 class="ons-message-item__subject" id="{{ message.id }}">
6
6
  <a href="{{ message.url }}" class="ons-u-fs-r--b">{{ message.subject }}</a>
7
- {% if message.unread is defined and message.unread %}<span class="ons-message-item__unread ons-u-fs-s">({{ params.unreadText }})</span>{% endif %}
7
+ {% if message.unread %}<span class="ons-message-item__unread ons-u-fs-s">({{ params.unreadText }})</span>{% endif %}
8
8
  </h3>
9
9
  <dl class="ons-message-item__metadata" aria-label="{{ params.ariaLabelMetaData | default("Message metadata") }}">
10
10
  <dt class="ons-message-item__metadata-term ons-message-item__metadata-term--from ons-u-vh">{{ params.fromLabel }}:</dt>
@@ -1,12 +1,12 @@
1
1
  {% macro onsMetadata(params) %}
2
- <dl class="ons-metadata ons-metadata__list ons-grid ons-grid--gutterless ons-u-cf{{ (' ' + params.classes) if params.classes is defined and params.classes }}"{% if params.id is defined and params.id %} id="{{ params.id }}" {% endif %}{% if params.metadataLabel is defined and params.metadataLabel %} title="{{ params.metadataLabel }}" aria-label="{{ params.metadataLabel }}"{% endif %}>
2
+ <dl class="ons-metadata ons-metadata__list ons-grid ons-grid--gutterless ons-u-cf{{ (' ' + params.classes) if params.classes }}"{% if params.id %} id="{{ params.id }}" {% endif %}{% if params.metadataLabel %} title="{{ params.metadataLabel }}" aria-label="{{ params.metadataLabel }}"{% endif %}>
3
3
  {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
4
4
  {% if item.term | length %}
5
5
  <dt class="ons-metadata__term ons-grid__col ons-col-{{ params.termCol }}@m">{{ item.term }}</dt>
6
6
  {% endif %}
7
7
  {% for description in item.descriptions %}
8
8
  {% if description.description | length %}
9
- <dd {% if description.id is defined and description.id %}id="{{ description.id }}" {% endif %}class="ons-metadata__value ons-grid__col ons-col-{{ params.descriptionCol }}@m">{{ description.description }}</dd>
9
+ <dd {% if description.id %}id="{{ description.id }}" {% endif %}class="ons-metadata__value ons-grid__col ons-col-{{ params.descriptionCol }}@m">{{ description.description }}</dd>
10
10
  {% endif %}
11
11
  {% endfor %}
12
12
  {% endfor %}
@@ -1,19 +1,19 @@
1
1
  {% macro onsModal(params) %}
2
2
  {% set modalId = params.id | default('dialog') %}
3
- <dialog class="ons-modal ons-js-modal {{ params.classes if params.classes is defined and params.classes else '' }}"
3
+ <dialog class="ons-modal ons-js-modal {{ params.classes if params.classes else '' }}"
4
4
  id="{{ modalId }}"
5
5
  role="dialog"
6
6
  aria-labelledby="ons-modal-title"
7
- {% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}
7
+ {% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}
8
8
  >
9
9
  <div class="ons-modal__content">
10
- <h1 id="ons-modal-title" class="ons-modal__title">
10
+ <h2 id="ons-modal-title" class="ons-modal__title">
11
11
  {{ params.title }}
12
- </h1>
12
+ </h2>
13
13
  <div class="ons-modal__body">
14
- {{ (params.body if params.body is defined and params.body else "") | safe }}{{ caller() if caller }}
14
+ {{ (params.body if params.body else "") | safe }}{{ caller() if caller }}
15
15
  </div>
16
- {% if params.btnText is defined and params.btnText %}
16
+ {% if params.btnText %}
17
17
  {% from "components/button/_macro.njk" import onsButton %}
18
18
  {{ onsButton({
19
19
  "text": params.btnText,
@@ -5,12 +5,19 @@ $backdrop-colour: rgba(0, 0, 0, 0.8);
5
5
  border-radius: 0.4rem;
6
6
  box-shadow: 0 0 7px 0 #000;
7
7
  display: none;
8
+ left: 0;
8
9
  margin-left: 2rem;
9
10
  margin-right: 2rem;
10
- max-width: 500px;
11
+ outline: 2px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show box-shadows
11
12
  padding: 2rem;
12
- position: relative;
13
- width: auto;
13
+ position: fixed;
14
+ top: 0;
15
+
16
+ @media screen and (min-width: 600px) {
17
+ margin-left: auto;
18
+ margin-right: auto;
19
+ max-width: 500px;
20
+ }
14
21
 
15
22
  &-ie11 & {
16
23
  background: $color-white;
@@ -23,12 +30,6 @@ $backdrop-colour: rgba(0, 0, 0, 0.8);
23
30
  transform: translate(0, -50%);
24
31
  }
25
32
 
26
- @media screen and (min-width: 600px) {
27
- margin-left: auto;
28
- margin-right: auto;
29
- width: 100%;
30
- }
31
-
32
33
  &::backdrop {
33
34
  backdrop-filter: blur(3px);
34
35
  background: $backdrop-colour;
@@ -21,7 +21,7 @@
21
21
  }) %}
22
22
  <div class="ons-js-mutually-exclusive ons-mutually-exclusive">
23
23
  {{ content | safe }}
24
- {% if params.autosuggestResults is defined and params.autosuggestResults %}
24
+ {% if params.autosuggestResults %}
25
25
  {{ params.autosuggestResults | safe }}
26
26
  {% endif %}
27
27
  {% if exclusiveOptionsLength == 1 %}
@@ -106,8 +106,10 @@ export default class MutuallyExclusive {
106
106
  let labelText;
107
107
 
108
108
  if (label) {
109
- if (label.classList.contains(inputAbbrClass)) {
109
+ if (label.classList.contains(inputAbbrClass) && label.querySelector('abbr')) {
110
110
  labelText = label.getAttribute('title');
111
+ } else if (label.classList.contains(inputAbbrClass) && label.querySelector('span')) {
112
+ labelText = label.querySelector('span').innerText;
111
113
  } else if (label.classList.contains(inputLegendClass) && label.querySelector('h1')) {
112
114
  labelText = label.querySelector('h1').innerText;
113
115
  } else {
@@ -2,8 +2,8 @@
2
2
  {% from "components/button/_macro.njk" import onsButton %}
3
3
  {% from "components/autosuggest/_macro.njk" import onsAutosuggest %}
4
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 %}
5
+ <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth or params.navigation.fullWidth }}{{ ' ons-container--wide' if params.wide or params.navigation.wide }}">
6
+ {% if params.navigation.siteSearchAutosuggest and isPatternLib %}
7
7
  <div class="ons-navigation-search ons-js-navigation-search">
8
8
  {% set autosuggestClasses = "ons-input-search ons-input-search--icon" %}
9
9
  {% set autosuggestLabelClasses = "ons-u-pl-m" %}
@@ -42,26 +42,26 @@
42
42
  <ul class="ons-navigation__list">
43
43
  {% for item in (params.navigation.itemsList if params.navigation.itemsList is iterable else params.navigation.itemsList.items()) %}
44
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) }}">
45
- <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}{% if item.ariaLabel is defined and item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %}>{{ item.title }}</a>
45
+ <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id %}id="{{ item.id }}" {% endif %}{% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %}>{{ item.title }}</a>
46
46
  </li>
47
47
  {% endfor %}
48
48
  </ul>
49
49
  </nav>
50
50
  </div>
51
51
  </div>
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">
52
+ {% if 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 }}" id="{{ params.navigation.subNavigation.id }}" aria-label="{{ params.navigation.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
54
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 }}">
55
55
  <ul class="ons-navigation__list ons-navigation__list">
56
56
  {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
57
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) }}">
58
- <a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel is defined and item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
58
+ <a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
59
59
  </li>
60
60
  {% endfor %}
61
61
  </ul>
62
62
  </div>
63
63
  </nav>
64
- <div class="ons-u-d-no@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes is defined and params.navigation.subNavigation.classes }}">
64
+ <div class="ons-u-d-no@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes }}">
65
65
  {{ onsButton({
66
66
  "text": params.navigation.currentPageTitle,
67
67
  "classes": "ons-u-d-no ons-js-sub-navigation-button ons-btn--dropdown",
@@ -69,7 +69,6 @@
69
69
  "attributes": {
70
70
  "aria-label": "Toggle section navigation",
71
71
  "aria-controls": params.navigation.subNavigation.id,
72
- "aria-haspopup": "true",
73
72
  "aria-expanded": "false"
74
73
  }
75
74
  }) }}
@@ -81,14 +80,14 @@
81
80
  </li>
82
81
  {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
83
82
  <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.ariaLabel is defined and item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id is defined and item.id %}id="{{ item.id }}--mobile" {% endif %}>{{ item.title }}</a>
83
+ <a class="ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}--mobile" {% endif %}>{{ item.title }}</a>
85
84
  {% if item.sections %}
86
85
  {% for section in item.sections %}
87
86
  {% if section.sectionTitle %}<h3 class="ons-navigation__list-header">{{ section.sectionTitle }}</h3>{% endif %}
88
87
  <ul class="ons-navigation__list ons-navigation__list--child ons-list--dashed ons-u-ml-s ons-u-mt-xs">
89
88
  {% for child in section.children %}
90
89
  <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) }}">
91
- <a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.ariaLabel is defined and child.ariaLabel %}aria-label="{{ child.ariaLabel }}" {% endif %} {% if child.id is defined and child.id %}id="{{ child.id }}" {% endif %}>{{ child.title }}</a>
90
+ <a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.ariaLabel %}aria-label="{{ child.ariaLabel }}" {% endif %} {% if child.id %}id="{{ child.id }}" {% endif %}>{{ child.title }}</a>
92
91
  </li>
93
92
  {% endfor %}
94
93
  </ul>
@@ -211,7 +211,6 @@ describe('macro: navigation', () => {
211
211
  attributes: {
212
212
  'aria-label': 'Toggle section navigation',
213
213
  'aria-controls': 'sub-nav',
214
- 'aria-haspopup': 'true',
215
214
  'aria-expanded': 'false',
216
215
  },
217
216
  });
@@ -1,7 +1,7 @@
1
1
  {% macro onsPagination(params) %}
2
2
  {% set currentPageIndex = "" %}
3
3
  {% for page in params.pages %}
4
- {% if page.current is defined and page.current %}
4
+ {% if page.current %}
5
5
  {% set currentPageIndex = loop.index %}
6
6
  {% endif %}
7
7
  {% endfor %}
@@ -25,7 +25,7 @@
25
25
  {% endif %}
26
26
 
27
27
 
28
- <nav class="ons-pagination {{ params.classes }}{% if params.hideRangeIndicator is defined and params.hideRangeIndicator %} ons-pagination--no-indicator{% endif %}" aria-label="Pagination ({{ position }})">
28
+ <nav class="ons-pagination {{ params.classes }}{% if params.hideRangeIndicator %} ons-pagination--no-indicator{% endif %}" aria-label="Pagination ({{ position }})">
29
29
  <div class="ons-pagination__position">{{ position }}</div>
30
30
  <ul class="ons-pagination__items">
31
31
  {% if currentPageIndex != 1 %}
@@ -45,7 +45,7 @@
45
45
  {% endif %}
46
46
  {% for page in params.pages %}
47
47
  {% if loop.index >= middlePagesStart and loop.index <= middlePagesEnd %}
48
- <li class="ons-pagination__item{% if page.current is defined and page.current == true %} ons-pagination__item--current{% endif %}">
48
+ <li class="ons-pagination__item{% if page.current == true %} ons-pagination__item--current{% endif %}">
49
49
  <a href="{{ page.url }}" class="ons-pagination__link"
50
50
  {%- if page.current -%}
51
51
  aria-current="true" aria-label="Current page ({{ position }})"
@@ -45,6 +45,7 @@ $pagination-item-width: 2.5rem;
45
45
  &__item--current &__link {
46
46
  background: $color-text-link-hover;
47
47
  color: $color-white;
48
+ outline: 2px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show backgrounds
48
49
  text-decoration: none;
49
50
  }
50
51
 
@@ -1,6 +1,6 @@
1
1
  {% macro onsPanel(params) %}
2
2
 
3
- {% if params is defined and params and params.classes is defined and params.classes %}
3
+ {% if params.classes %}
4
4
  {% set classes = ' ' + params.classes %}
5
5
  {% endif %}
6
6
 
@@ -8,37 +8,37 @@
8
8
  {% set noTitleClass = ' ons-panel--no-title' %}
9
9
  {% endif %}
10
10
 
11
- {% if params is defined and params and params.type is defined and params.type %}
11
+ {% if params.type %}
12
12
  {% set typeClass = ' ons-panel--' + params.type %}
13
13
  {% else %}
14
14
  {% set typeClass = ' ons-panel--info' %}
15
15
  {% endif %}
16
16
 
17
- {% if params is defined and params.type == "warn-branded" %}
18
- {% set containerClass = 'ons-census-warning' %}
17
+ {% if params.type == "warn-branded" %}
18
+ {% set containerClass = 'ons-branded-warning' %}
19
19
  {% endif %}
20
20
 
21
- {% if params is defined and params.type == "announcement" %}
21
+ {% if params.type == "announcement" %}
22
22
  {% set containerClass = 'ons-announcement' %}
23
23
  {% endif %}
24
24
 
25
- {% if params is defined and params and params.spacious is defined and params.spacious %}
25
+ {% if params.spacious %}
26
26
  {% set spaciousClass = ' ons-panel--spacious' %}
27
27
  {% endif %}
28
28
 
29
- {% if params is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
29
+ {% if params.type == "warn-branded" or params.type == "announcement" %}
30
30
  <div class="{{containerClass}}">
31
31
  <div class="ons-container">
32
32
  {% endif %}
33
33
 
34
- <div {% if params is defined and params and params.type == 'error' and params.title is defined and params.title %}aria-labelledby="error-summary-title" role="alert" tabindex="-1" {% if params.dsExample != true %}autofocus="autofocus" {% endif %}{% endif %}class="ons-panel{{ typeClass }}{{ iconClass }}{{ noTitleClass }}{{ spaciousClass }}{{ classes }}"{% if params is defined and params and params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params is defined and params and params.attributes is mapping and params.attributes.items is defined and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params is defined and params and params.id is defined and params.id %} id="{{params.id}}"{% endif %}>
34
+ <div {% if (params.type == 'error' and params.title) or params.type == 'success' %}aria-labelledby="alert" role="alert" tabindex="-1" {% if params.dsExample != true %}autofocus="autofocus" {% endif %}{% endif %}class="ons-panel{{ typeClass }}{{ iconClass }}{{ noTitleClass }}{{ spaciousClass }}{{ classes }}"{% if params and params.attributes %}{% for attribute, value in (params.attributes.items() if params and params.attributes is mapping and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params and params.id %} id="{{params.id}}"{% endif %}>
35
35
 
36
- {% if params is defined and params and params.type == "warn" or params.type == "warn-branded" %}
36
+ {% if params.type == "warn" or params.type == "warn-branded" %}
37
37
  <span class="ons-panel__icon" aria-hidden="true">!</span>
38
38
  <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Warning: ") }}</span>
39
39
  {% endif %}
40
40
 
41
- {% if params is defined and params and params.type == "announcement" %}
41
+ {% if params.type == "announcement" %}
42
42
  {% from "components/icons/_macro.njk" import onsIcon %}
43
43
  <span class="ons-panel__icon" aria-hidden="true">
44
44
  {{
@@ -50,48 +50,43 @@
50
50
  <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Announcement: ") }}</span>
51
51
  {% endif %}
52
52
 
53
- {% if params is defined and params %}
54
- {% if params.title is defined and params.title %}
55
- {% if params is defined and params and params.type == 'error' %}
56
- {% set defaultTitleTag = "h2" %}
57
- {% else %}
58
- {% set defaultTitleTag = "div" %}
59
- {% endif %}
60
- {% set titleTag = params.titleTag | default(defaultTitleTag) %}
61
- <div class="ons-panel__header">
62
- <{{ titleTag }} id="error-summary-title" {% if params is defined and params and params.type is defined and params.type %}data-qa="{{ params.type }}-header"{% endif %} class="ons-panel__title ons-u-fs-r--b">{{ params.title | safe }}</{{ titleTag }}>
63
- </div>
53
+ {% if params.title %}
54
+ {% if params.type == 'error' %}
55
+ {% set defaultTitleTag = "h2" %}
64
56
  {% else %}
65
- {% if params.type is not defined or params.type == "branded" or params.type == "info" %}
66
- <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Important information: ") }}</span>
67
- {% else %}
68
- {% if params.type is defined and params.type == "success" %}
69
- <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Completed: ") }}</span>
70
- {% elif params.type is defined and params.type == "error" %}
71
- <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Error: ") }}</span>
72
- {% endif %}
73
- {% endif %}
57
+ {% set defaultTitleTag = "div" %}
74
58
  {% endif %}
75
-
76
- {% if params.iconType is defined and params.iconType %}
77
- {% from "components/icons/_macro.njk" import onsIcon %}
78
- <span class= "ons-panel__icon ons-u-fs-{{ params.iconSize | default('r') }}">
79
- {{
80
- onsIcon({
81
- "iconType": params.iconType,
82
- "iconSize": params.iconSize
83
- })
84
- }}
85
- </span>
59
+ {% set titleTag = params.titleTag | default(defaultTitleTag) %}
60
+ <div class="ons-panel__header">
61
+ <{{ titleTag }} id="alert"{% if params.type %} data-qa="{{ params.type }}-header"{% endif %} class="ons-panel__title ons-u-fs-r--b">{{ params.title | safe }}</{{ titleTag }}>
62
+ </div>
63
+ {% else %}
64
+ {% if not params.type or params.type == "branded" or params.type == "info" or params.type == "bare" %}
65
+ <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Important information: ") }}</span>
66
+ {% elif params.type == 'error' or params.type == 'success' %}
67
+ {% set defaultText = "Completed" if params.type == "success" else "Error" %}
68
+ <span{% if params.type == "success" %} id="alert"{% endif %} class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default(defaultText ~ ": ") }}</span>
86
69
  {% endif %}
87
70
  {% endif %}
88
71
 
89
- <div class="ons-panel__body{% if params is defined and params and params.iconSize is defined and params.iconSize %} ons-svg-icon-margin--{{ params.iconSize }}{% endif %}">{{ (params.body if params else "") | safe }}
72
+ {% if params.iconType %}
73
+ {% from "components/icons/_macro.njk" import onsIcon %}
74
+ <span class= "ons-panel__icon ons-u-fs-{{ params.iconSize | default('r') }}">
75
+ {{
76
+ onsIcon({
77
+ "iconType": params.iconType,
78
+ "iconSize": params.iconSize
79
+ })
80
+ }}
81
+ </span>
82
+ {% endif %}
83
+
84
+ <div class="ons-panel__body{% if params.iconSize %} ons-svg-icon-margin--{{ params.iconSize }}{% endif %}">{{ (params.body if params else "") | safe }}
90
85
  {{ caller() if caller }}
91
86
  </div>
92
87
  </div>
93
88
 
94
- {% if params is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
89
+ {% if params.type == "warn-branded" or params.type == "announcement" %}
95
90
  </div>
96
91
  </div>
97
92
  {% endif %}
@@ -13,6 +13,7 @@ const EXAMPLE_PANEL_BASIC = {
13
13
  describe('macro: panel', () => {
14
14
  describe.each([
15
15
  ['info', 'Important information:'],
16
+ ['bare', 'Important information:'],
16
17
  ['error', 'Error:'],
17
18
  ['warn', 'Warning:'],
18
19
  ['warn-branded', 'Warning:'],
@@ -186,50 +187,53 @@ describe('macro: panel', () => {
186
187
  });
187
188
  });
188
189
 
189
- describe('mode: error', () => {
190
+ describe.each([
191
+ ['error', 'h2'],
192
+ ['success', 'div'],
193
+ ])('mode: %s', (panelType, tagEl) => {
190
194
  it('has the default id set', () => {
191
195
  const $ = cheerio.load(
192
196
  renderComponent('panel', {
193
197
  ...EXAMPLE_PANEL_BASIC,
194
- title: 'Error title',
195
- type: 'error',
198
+ title: 'Title',
199
+ type: panelType,
196
200
  }),
197
201
  );
198
202
 
199
- expect($('#error-summary-title').length).toBe(1);
203
+ expect($('#alert').length).toBe(1);
200
204
  });
201
205
 
202
- it('has H2 as the default title tag', () => {
206
+ it('has the correct default title tag', () => {
203
207
  const $ = cheerio.load(
204
208
  renderComponent('panel', {
205
209
  ...EXAMPLE_PANEL_BASIC,
206
- title: 'Error title',
207
- type: 'error',
210
+ title: 'Title',
211
+ type: panelType,
208
212
  }),
209
213
  );
210
214
 
211
215
  const titleTag = $('.ons-panel__title')[0].tagName;
212
- expect(titleTag).toBe('h2');
216
+ expect(titleTag).toBe(tagEl);
213
217
  });
214
218
 
215
219
  it('has aria-labelledby attribute set with default value', () => {
216
220
  const $ = cheerio.load(
217
221
  renderComponent('panel', {
218
222
  ...EXAMPLE_PANEL_BASIC,
219
- title: 'Error title',
220
- type: 'error',
223
+ title: 'Title',
224
+ type: panelType,
221
225
  }),
222
226
  );
223
227
 
224
- expect($('.ons-panel').attr('aria-labelledby')).toBe('error-summary-title');
228
+ expect($('.ons-panel').attr('aria-labelledby')).toBe('alert');
225
229
  });
226
230
 
227
231
  it('has the role attribute set to alert', () => {
228
232
  const $ = cheerio.load(
229
233
  renderComponent('panel', {
230
234
  ...EXAMPLE_PANEL_BASIC,
231
- title: 'Error title',
232
- type: 'error',
235
+ title: 'Title',
236
+ type: panelType,
233
237
  }),
234
238
  );
235
239
 
@@ -240,8 +244,8 @@ describe('macro: panel', () => {
240
244
  const $ = cheerio.load(
241
245
  renderComponent('panel', {
242
246
  ...EXAMPLE_PANEL_BASIC,
243
- title: 'Error title',
244
- type: 'error',
247
+ title: 'Title',
248
+ type: panelType,
245
249
  }),
246
250
  );
247
251
 
@@ -252,8 +256,8 @@ describe('macro: panel', () => {
252
256
  const $ = cheerio.load(
253
257
  renderComponent('panel', {
254
258
  ...EXAMPLE_PANEL_BASIC,
255
- title: 'Error title',
256
- type: 'error',
259
+ title: 'Title',
260
+ type: panelType,
257
261
  }),
258
262
  );
259
263
 
@@ -264,8 +268,8 @@ describe('macro: panel', () => {
264
268
  const $ = cheerio.load(
265
269
  renderComponent('panel', {
266
270
  ...EXAMPLE_PANEL_BASIC,
267
- title: 'Error title',
268
- type: 'error',
271
+ title: 'Title',
272
+ type: panelType,
269
273
  dsExample: true,
270
274
  }),
271
275
  );
@@ -313,19 +317,6 @@ describe('macro: panel', () => {
313
317
  });
314
318
  });
315
319
 
316
- describe('mode: bare', () => {
317
- it('has the correct class set', () => {
318
- const $ = cheerio.load(
319
- renderComponent('panel', {
320
- ...EXAMPLE_PANEL_BASIC,
321
- type: 'bare',
322
- }),
323
- );
324
-
325
- expect($('.ons-panel').hasClass('ons-panel--bare')).toBe(true);
326
- });
327
- });
328
-
329
320
  describe('mode: warn', () => {
330
321
  it('has a default "!" prefix', () => {
331
322
  const $ = cheerio.load(
@@ -352,7 +343,7 @@ describe('macro: panel', () => {
352
343
  }),
353
344
  );
354
345
 
355
- expect($('.ons-census-warning').length).toBe(1);
346
+ expect($('.ons-branded-warning').length).toBe(1);
356
347
  expect($('.ons-container').length).toBe(1);
357
348
  });
358
349
 
@@ -3,6 +3,7 @@
3
3
  &--#{$name} {
4
4
  background: $color-bg;
5
5
  border-color: $color;
6
+ outline: 1px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show background
6
7
  }
7
8
 
8
9
  &--#{$name} & {
@@ -13,7 +14,7 @@
13
14
  }
14
15
  }
15
16
 
16
- .ons-census-warning {
17
+ .ons-branded-warning {
17
18
  background: $color-branded-tertiary;
18
19
  }
19
20
 
@@ -21,6 +22,11 @@
21
22
  background-color: $color-black;
22
23
  }
23
24
 
25
+ .ons-branded-warning,
26
+ .ons-announcement {
27
+ outline: 2px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show background
28
+ }
29
+
24
30
  .ons-panel {
25
31
  border-radius: 0;
26
32
  position: relative;
@@ -37,12 +43,11 @@
37
43
  &:focus {
38
44
  box-shadow: none;
39
45
  outline: 4px solid $color-focus !important;
40
- outline-offset: 0;
41
46
  }
42
47
 
43
48
  &__header {
44
49
  border-radius: 0;
45
- color: $color-white;
50
+ color: $color-text-inverse;
46
51
  margin: 0;
47
52
  padding: 0.75rem 1rem;
48
53
  }
@@ -111,6 +116,7 @@
111
116
  &--warn {
112
117
  border: 0 !important;
113
118
  margin-bottom: 1rem;
119
+ outline: none !important;
114
120
  padding: 0;
115
121
 
116
122
  &--footer {
@@ -125,6 +131,7 @@
125
131
  border: 0 !important;
126
132
  color: $color-white;
127
133
  margin-bottom: 0;
134
+ outline: none !important;
128
135
  padding: 1rem 0 !important;
129
136
  a {
130
137
  color: inherit;
@@ -137,7 +144,7 @@
137
144
 
138
145
  &--announcement {
139
146
  a:focus {
140
- box-shadow: 0 -2px #fd0, 0 4px #fd0 !important; // Override focus style because the black border is not visible on a black background
147
+ box-shadow: 0 -2px $color-focus, 0 4px $color-text-inverse-link !important; // Override focus style because the black border is not visible on a black background
141
148
  }
142
149
  }
143
150
 
@@ -178,6 +185,7 @@
178
185
  line-height: 2rem;
179
186
  min-height: 2rem;
180
187
  min-width: 2rem;
188
+ outline: 2px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show background
181
189
  text-align: center;
182
190
  }
183
191
  }
@@ -245,6 +253,6 @@
245
253
  @include panel-type(success, $color-success, $color-success-tint);
246
254
  @include panel-type(info, $color-info, $color-info-tint);
247
255
  @include panel-type(branded, $color-branded, $color-branded-tint);
248
- @include panel-type(warn, $color-white, $color-white);
256
+ @include panel-type(warn, transparent, transparent);
249
257
  @include panel-type(warn-branded, $color-branded-tertiary, $color-branded-tertiary);
250
258
  @include panel-type(announcement, $color-black, $color-black);
@@ -1,6 +1,6 @@
1
1
  {% macro onsPhaseBanner(params) %}
2
2
  <div class="ons-phase-banner">
3
- <div class="ons-container{{ ' ons-container--wide' if params.wide }}">
3
+ <div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
4
4
  <div class="ons-grid ons-grid--flex ons-grid--gutterless ons-grid--vertical-top ons-grid--no-wrap">
5
5
  {% if not params.hideBadge %}
6
6
  <div class="ons-grid__col ons-col-auto ons-u-flex-no-grow ons-u-flex-no-shrink">
@@ -70,4 +70,35 @@ describe('macro: phase-banner', () => {
70
70
 
71
71
  expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
72
72
  });
73
+
74
+ it('does not have `container--wide` class when `wide` is not set', () => {
75
+ const $ = cheerio.load(
76
+ renderComponent('phase-banner', {
77
+ ...EXAMPLE_PHASE_BANNER_MINIMAL,
78
+ }),
79
+ );
80
+
81
+ expect($('.ons-container').hasClass('ons-container--wide')).toBe(false);
82
+ });
83
+
84
+ it('has `container--full-width` class when `fullWidth` is true', () => {
85
+ const $ = cheerio.load(
86
+ renderComponent('phase-banner', {
87
+ ...EXAMPLE_PHASE_BANNER_MINIMAL,
88
+ fullWidth: true,
89
+ }),
90
+ );
91
+
92
+ expect($('.ons-container').hasClass('ons-container--full-width')).toBe(true);
93
+ });
94
+
95
+ it('does not have `container--full-width` class when `fullWidth` is not set', () => {
96
+ const $ = cheerio.load(
97
+ renderComponent('phase-banner', {
98
+ ...EXAMPLE_PHASE_BANNER_MINIMAL,
99
+ }),
100
+ );
101
+
102
+ expect($('.ons-container').hasClass('ons-container--full-width')).toBe(false);
103
+ });
73
104
  });