@ons/design-system 50.0.0 → 52.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 (166) 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/_macro.njk +5 -5
  23. package/components/button/_macro.spec.js +446 -0
  24. package/components/button/button.spec.js +290 -0
  25. package/components/call-to-action/_macro.njk +3 -1
  26. package/components/call-to-action/_macro.spec.js +52 -0
  27. package/components/card/_macro.njk +26 -19
  28. package/components/card/_macro.spec.js +261 -0
  29. package/components/char-check-limit/_macro.spec.js +73 -0
  30. package/components/char-check-limit/character-check.spec.js +196 -0
  31. package/components/char-check-limit/character-limit.js +1 -1
  32. package/components/checkboxes/_checkbox-macro.spec.js +419 -0
  33. package/components/checkboxes/_macro.njk +1 -3
  34. package/components/checkboxes/_macro.spec.js +306 -0
  35. package/components/checkboxes/checkbox-with-autoselect.js +2 -1
  36. package/components/checkboxes/checkboxes.spec.js +208 -0
  37. package/components/code-highlight/_macro.spec.js +56 -0
  38. package/components/code-highlight/code-highlight.spec.js +18 -0
  39. package/components/collapsible/_macro.spec.js +204 -0
  40. package/components/collapsible/collapsible.js +2 -1
  41. package/components/collapsible/collapsible.spec.js +236 -0
  42. package/components/content-pagination/_macro.spec.js +199 -0
  43. package/components/cookies-banner/_macro.njk +1 -1
  44. package/components/cookies-banner/_macro.spec.js +171 -0
  45. package/components/cookies-banner/cookies-banner.spec.js +90 -0
  46. package/components/date-input/_macro.njk +6 -3
  47. package/components/date-input/_macro.spec.js +286 -0
  48. package/components/document-list/_macro.njk +3 -5
  49. package/components/document-list/_macro.spec.js +491 -0
  50. package/components/download-resources/download-resources.spec.js +540 -0
  51. package/components/duration/_macro.njk +7 -6
  52. package/components/duration/_macro.spec.js +251 -0
  53. package/components/error/_macro.spec.js +97 -0
  54. package/components/external-link/_macro.spec.js +60 -0
  55. package/components/feedback/_macro.njk +5 -3
  56. package/components/feedback/_macro.spec.js +122 -0
  57. package/components/field/_macro.njk +2 -2
  58. package/components/field/_macro.spec.js +97 -0
  59. package/components/fieldset/_macro.njk +3 -3
  60. package/components/fieldset/_macro.spec.js +173 -0
  61. package/components/footer/_macro.njk +12 -49
  62. package/components/footer/_macro.spec.js +549 -0
  63. package/components/header/_macro.njk +3 -3
  64. package/components/header/_macro.spec.js +562 -0
  65. package/components/hero/_hero.scss +0 -3
  66. package/components/hero/_macro.njk +4 -4
  67. package/components/hero/_macro.spec.js +224 -0
  68. package/components/icons/_macro.njk +15 -15
  69. package/components/icons/_macro.spec.js +140 -0
  70. package/components/images/_macro.njk +1 -1
  71. package/components/images/_macro.spec.js +121 -0
  72. package/components/input/_input-type.scss +12 -5
  73. package/components/input/_macro.njk +4 -5
  74. package/components/input/_macro.spec.js +658 -0
  75. package/components/label/_macro.spec.js +189 -0
  76. package/components/language-selector/_macro.spec.js +129 -0
  77. package/components/lists/_list.scss +4 -0
  78. package/components/lists/_macro.njk +4 -7
  79. package/components/lists/_macro.spec.js +618 -0
  80. package/components/message/_macro.spec.js +137 -0
  81. package/components/message-list/_macro.njk +7 -7
  82. package/components/message-list/_macro.spec.js +159 -0
  83. package/components/metadata/_macro.spec.js +167 -0
  84. package/components/modal/_macro.njk +6 -6
  85. package/components/modal/_macro.spec.js +87 -0
  86. package/components/modal/modal.js +0 -16
  87. package/components/modal/modal.spec.js +59 -0
  88. package/components/mutually-exclusive/_macro.njk +2 -2
  89. package/components/mutually-exclusive/_macro.spec.js +184 -0
  90. package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +203 -0
  91. package/components/mutually-exclusive/mutually-exclusive.date.spec.js +142 -0
  92. package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +141 -0
  93. package/components/mutually-exclusive/mutually-exclusive.email.spec.js +117 -0
  94. package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +213 -0
  95. package/components/mutually-exclusive/mutually-exclusive.number.spec.js +125 -0
  96. package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +131 -0
  97. package/components/navigation/_macro.njk +6 -6
  98. package/components/navigation/_macro.spec.js +327 -0
  99. package/components/navigation/navigation.dom.js +1 -1
  100. package/components/navigation/navigation.spec.js +232 -0
  101. package/components/pagination/_macro.njk +1 -1
  102. package/components/pagination/_macro.spec.js +411 -0
  103. package/components/panel/_macro.njk +6 -6
  104. package/components/panel/_macro.spec.js +423 -0
  105. package/components/password/_macro.spec.js +137 -0
  106. package/components/password/password.spec.js +40 -0
  107. package/components/phase-banner/_macro.spec.js +73 -0
  108. package/components/promotional-banner/_macro.spec.js +97 -0
  109. package/components/question/_macro.njk +16 -22
  110. package/components/question/_macro.spec.js +309 -0
  111. package/components/quote/_macro.spec.js +81 -0
  112. package/components/radios/_macro.njk +3 -6
  113. package/components/radios/_macro.spec.js +575 -0
  114. package/components/radios/radios.spec.js +180 -0
  115. package/components/related-content/_macro.njk +1 -0
  116. package/components/related-content/_macro.spec.js +142 -0
  117. package/components/relationships/_macro.spec.js +108 -0
  118. package/components/relationships/relationships.spec.js +84 -0
  119. package/components/reply/_macro.njk +2 -2
  120. package/components/reply/_macro.spec.js +69 -0
  121. package/components/reply/reply.spec.js +78 -0
  122. package/components/search/_macro.njk +14 -12
  123. package/components/search/_macro.spec.js +44 -0
  124. package/components/search/_search.scss +7 -7
  125. package/components/section-navigation/_macro.njk +7 -2
  126. package/components/section-navigation/_macro.spec.js +206 -0
  127. package/components/select/_macro.njk +3 -3
  128. package/components/select/_macro.spec.js +203 -0
  129. package/components/select/select.spec.js +56 -0
  130. package/components/share-page/_macro.njk +2 -2
  131. package/components/share-page/_macro.spec.js +110 -0
  132. package/components/skip-to-content/_macro.spec.js +57 -0
  133. package/components/skip-to-content/skip-to-content.spec.js +44 -0
  134. package/components/status/_macro.spec.js +77 -0
  135. package/components/summary/_macro.njk +5 -5
  136. package/components/summary/_macro.spec.js +472 -0
  137. package/components/table/_macro.njk +2 -2
  138. package/components/table/_macro.spec.js +557 -0
  139. package/components/table/table.spec.js +155 -0
  140. package/components/table-of-contents/_macro.njk +35 -35
  141. package/components/table-of-contents/_macro.spec.js +178 -0
  142. package/components/table-of-contents/toc.js +29 -25
  143. package/components/table-of-contents/toc.spec.js +61 -0
  144. package/components/tabs/_macro.njk +1 -1
  145. package/components/tabs/_macro.spec.js +79 -0
  146. package/components/tabs/tabs.spec.js +162 -0
  147. package/components/text-indent/_macro.spec.js +52 -0
  148. package/components/textarea/_macro.njk +5 -3
  149. package/components/textarea/_macro.spec.js +300 -0
  150. package/components/textarea/textarea.spec.js +98 -0
  151. package/components/timeline/_macro.njk +3 -3
  152. package/components/timeline/_macro.spec.js +81 -0
  153. package/components/timeout-modal/_macro.spec.js +68 -0
  154. package/components/timeout-modal/timeout-modal.spec.js +226 -0
  155. package/components/timeout-panel/_macro.njk +0 -1
  156. package/components/timeout-panel/_macro.spec.js +54 -0
  157. package/components/timeout-panel/timeout-panel.dom.js +1 -2
  158. package/components/timeout-panel/timeout-panel.spec.js +161 -0
  159. package/components/upload/_macro.spec.js +75 -0
  160. package/components/video/_macro.spec.js +34 -0
  161. package/css/census.css +1 -1
  162. package/css/main.css +1 -1
  163. package/js/cookies-settings.spec.js +154 -0
  164. package/package.json +10 -23
  165. package/scripts/main.es5.js +1 -1
  166. package/scripts/main.js +2 -2
@@ -0,0 +1,140 @@
1
+ /** @jest-environment jsdom */
2
+
3
+ import * as cheerio from 'cheerio';
4
+
5
+ import axe from '../../tests/helpers/axe';
6
+ import { renderComponent } from '../../tests/helpers/rendering';
7
+
8
+ describe('macro: icons', () => {
9
+ describe.each([
10
+ 'arrow-forward',
11
+ 'arrow-next',
12
+ 'arrow-previous',
13
+ 'check',
14
+ 'chevron',
15
+ 'download',
16
+ 'exit',
17
+ 'external-link',
18
+ 'lock',
19
+ 'person',
20
+ 'print',
21
+ 'quote',
22
+ 'search',
23
+ 'sort-sprite',
24
+ 'facebook',
25
+ 'twitter',
26
+ 'instagram',
27
+ 'linkedin',
28
+ 'loader',
29
+ 'census-logo-cy',
30
+ 'census-logo-en',
31
+ 'ons-logo-en',
32
+ 'ons-logo-cy',
33
+ 'ons-logo-stacked-en',
34
+ 'ons-logo-stacked-cy',
35
+ 'nisra-logo-en',
36
+ 'nisra-logo-en-mobile',
37
+ 'nisra-logo-black-en',
38
+ 'ni-finance-logo',
39
+ 'ni-finance-logo-mobile',
40
+ 'crest',
41
+ 'ogl',
42
+ 'circle-lined',
43
+ ])('icon type: %s', iconType => {
44
+ it('passes jest-axe checks', async () => {
45
+ const $ = cheerio.load(renderComponent('icons', { iconType }));
46
+
47
+ const results = await axe($.html());
48
+ expect(results).toHaveNoViolations();
49
+ });
50
+
51
+ it('has an svg element', () => {
52
+ const $ = cheerio.load(renderComponent('icons', { iconType }));
53
+
54
+ expect($('svg').length).toBe(1);
55
+ });
56
+
57
+ it('has additionally provided style classes', () => {
58
+ const $ = cheerio.load(
59
+ renderComponent('icons', {
60
+ iconType,
61
+ classes: 'extra-class another-extra-class',
62
+ }),
63
+ );
64
+
65
+ expect($('svg').hasClass('extra-class')).toBe(true);
66
+ expect($('svg').hasClass('another-extra-class')).toBe(true);
67
+ });
68
+ });
69
+
70
+ describe.each([
71
+ 'arrow-next',
72
+ 'arrow-previous',
73
+ 'check',
74
+ 'chevron',
75
+ 'download',
76
+ 'exit',
77
+ 'external-link',
78
+ 'lock',
79
+ 'person',
80
+ 'print',
81
+ 'quote',
82
+ 'search',
83
+ 'facebook',
84
+ 'twitter',
85
+ 'instagram',
86
+ 'linkedin',
87
+ ])('icon type: %s', iconType => {
88
+ it('has style variation class for provided icon size', () => {
89
+ const $ = cheerio.load(
90
+ renderComponent('icons', {
91
+ iconType,
92
+ iconSize: 'xxl',
93
+ }),
94
+ );
95
+
96
+ expect($('svg').hasClass('ons-svg-icon--xxl')).toBe(true);
97
+ });
98
+ });
99
+
100
+ describe.each([
101
+ ['census-logo-cy', 'Logo Cyfrifiad 2021'],
102
+ ['census-logo-en', 'Census 2021 logo'],
103
+ ['ons-logo-en', 'Office for National Statistics logo'],
104
+ ['ons-logo-cy', 'Logo Swyddfa Ystadegau Gwladol'],
105
+ ['ons-logo-stacked-en', 'Office for National Statistics logo'],
106
+ ['ons-logo-stacked-cy', 'Logo Swyddfa Ystadegau Gwladol'],
107
+ ['nisra-logo-en', 'Nisra logo'],
108
+ ['nisra-logo-en-mobile', 'Nisra logo'],
109
+ ['nisra-logo-black-en', 'Nisra logo'],
110
+ ['ni-finance-logo', 'Northern Ireland Department of Finance logo'],
111
+ ['ni-finance-logo-mobile', 'Northern Ireland Department of Finance logo'],
112
+ ['crest', 'Royal coat of arms of the United Kingdom'],
113
+ ['ogl', 'Open Government License logo'],
114
+ ])('icon type: %s', (iconType, expectedAltText) => {
115
+ it(`has default alt text '${expectedAltText}'`, () => {
116
+ const $ = cheerio.load(renderComponent('icons', { iconType }));
117
+
118
+ expect(
119
+ $('title')
120
+ .text()
121
+ .trim(),
122
+ ).toBe(expectedAltText);
123
+ });
124
+
125
+ it('has provided alt text', () => {
126
+ const $ = cheerio.load(
127
+ renderComponent('icons', {
128
+ iconType,
129
+ altText: 'Example alt text',
130
+ }),
131
+ );
132
+
133
+ expect(
134
+ $('title')
135
+ .text()
136
+ .trim(),
137
+ ).toBe('Example alt text');
138
+ });
139
+ });
140
+ });
@@ -2,7 +2,7 @@
2
2
  <figure class="ons-figure">
3
3
 
4
4
  {% if params.image is defined and params.image %}
5
- <img class="ons-figure__image" srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x" src="{{ params.image.smallSrc }}" alt="{{ params.alt }}">
5
+ <img class="ons-figure__image" {% if params.image.largeSrc is defined and params.image.largeSrc %}srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %}src="{{ params.image.smallSrc }}" alt="{{ params.alt if params.alt is defined and params.alt else '' }}">
6
6
  {% else %}
7
7
  <img class="ons-figure__image" src="{{ params.url }}" alt="{{ params.alt }}">
8
8
  {% endif %}
@@ -0,0 +1,121 @@
1
+ /** @jest-environment jsdom */
2
+
3
+ import * as cheerio from 'cheerio';
4
+
5
+ import axe from '../../tests/helpers/axe';
6
+ import { renderComponent } from '../../tests/helpers/rendering';
7
+
8
+ const EXAMPLE_IMAGE_URL_MINIMAL = {
9
+ url: 'example.png',
10
+ };
11
+
12
+ const EXAMPLE_IMAGE_IMAGE_MINIMAL = {
13
+ image: {
14
+ smallSrc: 'example-small.png',
15
+ largeSrc: 'example-large.png',
16
+ },
17
+ };
18
+
19
+ describe('macro: images', () => {
20
+ it('outputs a `figure` element', () => {
21
+ const $ = cheerio.load(renderComponent('images', EXAMPLE_IMAGE_URL_MINIMAL));
22
+
23
+ expect($('.ons-figure')[0].tagName).toBe('figure');
24
+ });
25
+
26
+ it('outputs a `figurecaption` element when `caption` is provided', () => {
27
+ const $ = cheerio.load(
28
+ renderComponent('images', {
29
+ ...EXAMPLE_IMAGE_URL_MINIMAL,
30
+ caption: 'Example image caption',
31
+ }),
32
+ );
33
+
34
+ expect($('.ons-figure__caption')[0].tagName).toBe('figcaption');
35
+ });
36
+
37
+ it('outputs a `figurecaption` element with provided `caption` text', () => {
38
+ const $ = cheerio.load(
39
+ renderComponent('images', {
40
+ ...EXAMPLE_IMAGE_URL_MINIMAL,
41
+ caption: 'Example image caption',
42
+ }),
43
+ );
44
+
45
+ expect(
46
+ $('.ons-figure__caption')
47
+ .text()
48
+ .trim(),
49
+ ).toBe('Example image caption');
50
+ });
51
+
52
+ describe('mode: url', () => {
53
+ it('passes jest-axe checks', async () => {
54
+ const $ = cheerio.load(renderComponent('images', EXAMPLE_IMAGE_URL_MINIMAL));
55
+
56
+ const results = await axe($.html());
57
+ expect(results).toHaveNoViolations();
58
+ });
59
+
60
+ it('outputs an `img` element', () => {
61
+ const $ = cheerio.load(renderComponent('images', EXAMPLE_IMAGE_URL_MINIMAL));
62
+
63
+ expect($('.ons-figure__image')[0].tagName).toBe('img');
64
+ });
65
+
66
+ it('outputs an `img` element with the expected `src`', () => {
67
+ const $ = cheerio.load(renderComponent('images', EXAMPLE_IMAGE_URL_MINIMAL));
68
+
69
+ expect($('.ons-figure__image').attr('src')).toBe('example.png');
70
+ });
71
+
72
+ it('outputs an `img` element with the expected alt text', () => {
73
+ const $ = cheerio.load(
74
+ renderComponent('images', {
75
+ ...EXAMPLE_IMAGE_URL_MINIMAL,
76
+ alt: 'Example alt text',
77
+ }),
78
+ );
79
+
80
+ expect($('.ons-figure__image').attr('alt')).toBe('Example alt text');
81
+ });
82
+ });
83
+
84
+ describe('mode: image', () => {
85
+ it('passes jest-axe checks', async () => {
86
+ const $ = cheerio.load(renderComponent('images', EXAMPLE_IMAGE_IMAGE_MINIMAL));
87
+
88
+ const results = await axe($.html());
89
+ expect(results).toHaveNoViolations();
90
+ });
91
+
92
+ it('outputs an `img` element', () => {
93
+ const $ = cheerio.load(renderComponent('images', EXAMPLE_IMAGE_IMAGE_MINIMAL));
94
+
95
+ expect($('.ons-figure__image')[0].tagName).toBe('img');
96
+ });
97
+
98
+ it('outputs an `img` element with the expected `srcset`', () => {
99
+ const $ = cheerio.load(renderComponent('images', EXAMPLE_IMAGE_IMAGE_MINIMAL));
100
+
101
+ expect($('.ons-figure__image').attr('srcset')).toBe('example-small.png 1x, example-large.png 2x');
102
+ });
103
+
104
+ it('outputs an `img` element with the expected `src`', () => {
105
+ const $ = cheerio.load(renderComponent('images', EXAMPLE_IMAGE_IMAGE_MINIMAL));
106
+
107
+ expect($('.ons-figure__image').attr('src')).toBe('example-small.png');
108
+ });
109
+
110
+ it('outputs an `img` element with the expected alt text', () => {
111
+ const $ = cheerio.load(
112
+ renderComponent('images', {
113
+ ...EXAMPLE_IMAGE_IMAGE_MINIMAL,
114
+ alt: 'Example alt text',
115
+ }),
116
+ );
117
+
118
+ expect($('.ons-figure__image').attr('alt')).toBe('Example alt text');
119
+ });
120
+ });
121
+ });
@@ -18,9 +18,8 @@
18
18
  }
19
19
  }
20
20
 
21
- &__type[title] {
21
+ &__type {
22
22
  background-color: $color-button-secondary;
23
- border: 1px solid $color-input;
24
23
  display: block;
25
24
  flex: 0 0 auto;
26
25
  font-size: 1rem;
@@ -28,11 +27,19 @@
28
27
  line-height: normal;
29
28
  padding: $input-padding-vertical $input-padding-horizontal * 2;
30
29
  text-align: center;
31
- text-decoration: none;
32
30
  white-space: nowrap;
31
+
32
+ &[title] {
33
+ text-decoration: none;
34
+ }
33
35
  }
34
36
 
35
- &__input:focus + &__type[title]::after {
37
+ &__type,
38
+ &__type[title] {
39
+ border: 1px solid $color-input;
40
+ }
41
+
42
+ &__input:focus + &__type::after {
36
43
  border-radius: $input-radius;
37
44
  bottom: 0;
38
45
  box-shadow: 0 0 0 3px $color-focus;
@@ -45,7 +52,7 @@
45
52
  }
46
53
 
47
54
  &:not(&--prefix) & {
48
- &__type[title] {
55
+ &__type {
49
56
  border-left: 0;
50
57
  border-radius: 0 $input-radius $input-radius 0;
51
58
  }
@@ -27,7 +27,7 @@
27
27
  type="{{ type }}"
28
28
  id="{{ params.id }}"
29
29
  class="ons-input ons-input--text ons-input-type__input{% if params.error is defined and params.error %} ons-input--error{% endif %}{% if params.searchButton is defined and params.searchButton %} ons-search__input{% endif %}{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}{% if params.width is defined and params.width %} ons-input{% if params.type is defined and (params.type == 'number' or params.type == 'tel') %}-number{% endif %}--w-{{ params.width }}{% endif %}{{ exclusiveClass }}{{ inputPlaceholder }}"
30
- {% if params.prefix is defined and params.prefix or params.suffix is defined and params.suffix %}title="{{ params.prefix.title if params.prefix }}{{ params.suffix.title if params.suffix }}"{% endif %}
30
+ {% if params.prefix is defined and params.prefix or params.suffix is defined and params.suffix %}aria-labelledby="{{ params.prefix.id if params.prefix }}{{ params.suffix.id if params.suffix }}"{% endif %}
31
31
  {% if params.name is defined and params.name %}name="{{ params.name }}"{% endif %}
32
32
  {% if params.value is defined and params.value %}value="{{ params.value }}"{% endif %}
33
33
  {% if params.accept is defined and params.accept %}accept="{{ params.accept }}"{% endif %}
@@ -53,7 +53,7 @@
53
53
  </script>
54
54
  {% endif %}
55
55
  {% if params.postTextboxLinkText is defined and params.postTextboxLinkText %}
56
- <a class="ons-u-fs-s" href="{{ params.postTextboxLinkUrl }}">{{ params.postTextboxLinkText }}</a>
56
+ <a class="ons-u-fs-s ons-input__post-link" href="{{ params.postTextboxLinkUrl }}">{{ params.postTextboxLinkText }}</a>
57
57
  {% endif %}
58
58
  {% endset %}
59
59
  {% set field %}
@@ -80,10 +80,9 @@
80
80
  {{ input | safe }}
81
81
  {% set abbr = params.prefix or params.suffix %}
82
82
  <abbr
83
+ {% if abbr.id is defined and abbr.id %}id="{{ abbr.id }}" {% endif %}
83
84
  class="ons-input-type__type ons-js-input-abbr"
84
- aria-hidden="true"
85
- title="{{ abbr.title }}"
86
- {% if abbr.id is defined and abbr.id %} id="{{ abbr.id }}"{% endif %}
85
+ title="{{ abbr.title }}"
87
86
  >{{ abbr.text or abbr.title }}</abbr>
88
87
  </span>
89
88
  </span>