@ons/design-system 73.0.1 → 73.0.3

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.
package/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # ONS Design System
2
2
 
3
3
  [![GitHub release](https://img.shields.io/github/release/ONSdigital/design-system.svg)](https://github.com/ONSdigital/design-system/releases)
4
- [![Tests](https://github.com/ONSdigital/design-system/actions/workflows/tests.yml/badge.svg)](https://github.com/ONSdigital/design-system/actions/workflows/tests.yml)
4
+ [![Macro and script tests](https://github.com/ONSdigital/design-system/actions/workflows/macro-and-script-tests.yml/badge.svg)](https://github.com/ONSdigital/design-system/actions/workflows/macro-and-script-tests.yml)
5
+ [![Visual regression tests](https://github.com/ONSdigital/design-system/actions/workflows/visual-regression-tests.yml/badge.svg)](https://github.com/ONSdigital/design-system/actions/workflows/visual-regression-tests.yml)
6
+ [![Lighthouse tests](https://github.com/ONSdigital/design-system/actions/workflows/lighthouse-ci.yml/badge.svg)](https://github.com/ONSdigital/design-system/actions/workflows/lighthouse-ci.yml)
5
7
  [![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/ONSdigital/design-system.svg)](https://github.com/ONSdigital/design-system/pulls)
6
8
  [![Github last commit](https://img.shields.io/github/last-commit/ONSdigital/design-system.svg)](https://github.com/ONSdigital/design-system/commits)
7
9
  [![Github contributors](https://img.shields.io/github/contributors/ONSdigital/design-system.svg)](https://github.com/ONSdigital/design-system/graphs/contributors)
@@ -2,7 +2,7 @@
2
2
  {{
3
3
  onsButton({
4
4
  "text": 'Web chat',
5
- "url": '/patterns/send-a-web-form/examples/form/',
5
+ "url": '/patterns/send-a-web-form/example-form',
6
6
  "newWindow": true,
7
7
  "newWindowDescription": 'opens in a new window',
8
8
  "attributes": {
@@ -649,6 +649,7 @@
649
649
  viewBox="0 0 115 96"
650
650
  focusable="false"
651
651
  role="img"
652
+ aria-hidden="true"
652
653
  >
653
654
  <title id="{{ params.altTextId | default ('crest-alt') }}">
654
655
  {{ params.altText | default ('Royal coat of arms of the United Kingdom') }}
@@ -835,7 +836,15 @@
835
836
  />
836
837
  </svg>
837
838
  {%- elif params.iconType == "census-logo" -%}
838
- <svg xmlns="http://www.w3.org/2000/svg" class="ons-icon--logo{{ iconClasses }}" width="152" height="16" viewBox="0 0 171 18">
839
+ <svg
840
+ xmlns="http://www.w3.org/2000/svg"
841
+ class="ons-icon--logo{{ iconClasses }}"
842
+ width="152"
843
+ height="16"
844
+ viewBox="0 0 171 18"
845
+ aria-hidden="true"
846
+ focusable="false"
847
+ >
839
848
  <title id="{{ params.altTextId | default ('census-logo-alt') }}">{{ params.altText | default ('Census 2021 Logo') }}</title>
840
849
  <path
841
850
  d="M22.9246 6.96226H31.8567C31.0755 5.26415 29.3774 4.09245 27.3906 4.09245C25.4038 4.09245 23.7057 5.26415 22.9246 6.96226ZM27.3906 18C22.4321 18 18.3906 13.9585 18.3906 9C18.3906 4.04151 22.4321 0 27.3906 0C32.3491 0 36.3906 4.04151 36.3906 9C36.3906 10.1208 35.4736 11.0377 34.3529 11.0377H22.9246C23.7057 12.7358 25.4038 13.9076 27.3906 13.9076C28.5114 13.9076 29.4284 14.8245 29.4284 15.9453C29.4284 17.083 28.5114 18 27.3906 18Z"
@@ -9,8 +9,9 @@
9
9
  }
10
10
 
11
11
  &__caption {
12
+ @extend .ons-u-fs-s;
13
+
12
14
  display: block;
13
- font-size: 0.8rem;
14
15
  padding: 0.5rem 0 0;
15
16
  }
16
17
  }
@@ -7,8 +7,8 @@
7
7
  {% set firstPage = params.pages | first %}
8
8
  {% set prevPageIndex = currentPageIndex - 1 %}
9
9
  {% set nextPageIndex = currentPageIndex + 1 %}
10
- {% set prevPageAriaLabel = (params.previousAriaLabel or 'Go to the previous page') %}
11
- {% set nextPageAriaLabel = (params.nextAriaLabel or 'Go to the next page') %}
10
+ {% set prevPageAriaLabel = (params.previousAriaLabel or 'Previous page') %}
11
+ {% set nextPageAriaLabel = (params.nextAriaLabel or 'Next page') %}
12
12
 
13
13
  <nav
14
14
  class="ons-pagination{{ ' ' + params.classes if params.classes else '' }}{{ ' ons-pagination--no-indicator' if params.hideRangeIndicator }}"
@@ -41,7 +41,7 @@
41
41
  <a
42
42
  href="{{ firstPage.url }}"
43
43
  class="ons-pagination__link"
44
- aria-label="{{ params.firstAriaLabel | default('Go to the first page') }}"
44
+ aria-label="{{ params.firstAriaLabel | default('First page') }}"
45
45
  >1</a
46
46
  >
47
47
  </li>
@@ -63,9 +63,10 @@
63
63
  href="{{ page.url }}"
64
64
  class="ons-pagination__link"
65
65
  {%- if loop.index == currentPageIndex -%}
66
- aria-current="true" aria-label="{{ params.currentAriaLabel | default('Current page') }} ({{ position }})"
66
+ aria-current="true"
67
+ aria-label="{% if params.currentAriaLabel %}{{ params.currentAriaLabel }} ({{ position }}){% else %}{{ position }}{% endif %}"
67
68
  {%- else -%}
68
- aria-label="{{ params.goToAriaLabel | default('Go to page') }} {{ loop.index }}"
69
+ aria-label="{{ params.goToAriaLabel | default('Page') }} {{ loop.index }}"
69
70
  {%- endif -%}
70
71
  {%- if loop.index == currentPageIndex - 1 -%}
71
72
  rel="prev"
@@ -86,7 +87,7 @@
86
87
  <a
87
88
  href="{{ lastPage.url }}"
88
89
  class="ons-pagination__link"
89
- aria-label="{{ params.lastAriaLabel | default('Go to the last page') }} ({{ totalPages }})"
90
+ aria-label="{{ params.lastAriaLabel | default('Last page') }} ({{ totalPages }})"
90
91
  >{{ totalPages }}</a
91
92
  >
92
93
  </li>
@@ -75,7 +75,7 @@ describe('macro: pagination', () => {
75
75
 
76
76
  it('has a single list item', () => {
77
77
  expect($('li').length).toBe(1);
78
- assertIsCurrentPage($('.ons-pagination__item'), '/page/1', 'Current page (Page 1 of 1)', '1');
78
+ assertIsCurrentPage($('.ons-pagination__item'), '/page/1', 'Page 1 of 1', '1');
79
79
  });
80
80
  });
81
81
 
@@ -103,9 +103,9 @@ describe('macro: pagination', () => {
103
103
 
104
104
  it('has a 3 list items ("1", "2", "Next page")', () => {
105
105
  expect($('li').length).toBe(3);
106
- assertIsCurrentPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Current page (Page 1 of 2)', '1');
107
- assertIsNextPage($('.ons-pagination__item:nth-child(2)'), '/page/2', 'Go to page 2', '2');
108
- assertIsNextPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Go to the next page (2)', 'Next page');
106
+ assertIsCurrentPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Page 1 of 2', '1');
107
+ assertIsNextPage($('.ons-pagination__item:nth-child(2)'), '/page/2', 'Page 2', '2');
108
+ assertIsNextPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Next page (2)', 'Next page');
109
109
  });
110
110
  });
111
111
 
@@ -133,9 +133,9 @@ describe('macro: pagination', () => {
133
133
 
134
134
  it('has a 3 list items ("Previous page", "1", "2")', () => {
135
135
  expect($('li').length).toBe(3);
136
- assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Go to the previous page (1)', 'Previous page');
137
- assertIsPreviousPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Go to page 1', '1');
138
- assertIsCurrentPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Current page (Page 2 of 2)', '2');
136
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Previous page (1)', 'Previous page');
137
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Page 1', '1');
138
+ assertIsCurrentPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Page 2 of 2', '2');
139
139
  });
140
140
  });
141
141
 
@@ -163,11 +163,11 @@ describe('macro: pagination', () => {
163
163
 
164
164
  it('has a 5 list items ("Previous page", "1", "2", "3", "Next page")', () => {
165
165
  expect($('li').length).toBe(5);
166
- assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Go to the previous page (1)', 'Previous page');
167
- assertIsPreviousPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Go to page 1', '1');
168
- assertIsCurrentPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Current page (Page 2 of 3)', '2');
169
- assertIsNextPage($('.ons-pagination__item:nth-child(4)'), '/page/3', 'Go to page 3', '3');
170
- assertIsNextPage($('.ons-pagination__item:nth-child(5)'), '/page/3', 'Go to the next page (3)', 'Next page');
166
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Previous page (1)', 'Previous page');
167
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Page 1', '1');
168
+ assertIsCurrentPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Page 2 of 3', '2');
169
+ assertIsNextPage($('.ons-pagination__item:nth-child(4)'), '/page/3', 'Page 3', '3');
170
+ assertIsNextPage($('.ons-pagination__item:nth-child(5)'), '/page/3', 'Next page (3)', 'Next page');
171
171
  });
172
172
  });
173
173
 
@@ -195,13 +195,13 @@ describe('macro: pagination', () => {
195
195
 
196
196
  it('has a 7 list items ("Previous page", "1", "2", "3", "4", "5", "Next page")', () => {
197
197
  expect($('li').length).toBe(7);
198
- assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Go to the previous page (1)', 'Previous page');
199
- assertIsPreviousPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Go to page 1', '1');
200
- assertIsCurrentPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Current page (Page 2 of 5)', '2');
201
- assertIsNextPage($('.ons-pagination__item:nth-child(4)'), '/page/3', 'Go to page 3', '3');
202
- assertIsOtherPage($('.ons-pagination__item:nth-child(5)'), '/page/4', 'Go to page 4', '4');
203
- assertIsOtherPage($('.ons-pagination__item:nth-child(6)'), '/page/5', 'Go to the last page (5)', '5');
204
- assertIsNextPage($('.ons-pagination__item:nth-child(7)'), '/page/3', 'Go to the next page (3)', 'Next page');
198
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Previous page (1)', 'Previous page');
199
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Page 1', '1');
200
+ assertIsCurrentPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Page 2 of 5', '2');
201
+ assertIsNextPage($('.ons-pagination__item:nth-child(4)'), '/page/3', 'Page 3', '3');
202
+ assertIsOtherPage($('.ons-pagination__item:nth-child(5)'), '/page/4', 'Page 4', '4');
203
+ assertIsOtherPage($('.ons-pagination__item:nth-child(6)'), '/page/5', 'Last page (5)', '5');
204
+ assertIsNextPage($('.ons-pagination__item:nth-child(7)'), '/page/3', 'Next page (3)', 'Next page');
205
205
  });
206
206
  });
207
207
 
@@ -236,13 +236,13 @@ describe('macro: pagination', () => {
236
236
 
237
237
  it('has 7 list items ("Previous page", "1", "2", "3", "...", "6", "Next page")', () => {
238
238
  expect($('li').length).toBe(7);
239
- assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Go to the previous page (1)', 'Previous page');
240
- assertIsPreviousPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Go to page 1', '1');
241
- assertIsCurrentPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Current page (Page 2 of 6)', '2');
242
- assertIsNextPage($('.ons-pagination__item:nth-child(4)'), '/page/3', 'Go to page 3', '3');
239
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/1', 'Previous page (1)', 'Previous page');
240
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Page 1', '1');
241
+ assertIsCurrentPage($('.ons-pagination__item:nth-child(3)'), '/page/2', 'Page 2 of 6', '2');
242
+ assertIsNextPage($('.ons-pagination__item:nth-child(4)'), '/page/3', 'Page 3', '3');
243
243
  assertIsGap($('.ons-pagination__item:nth-child(5)'));
244
- assertIsOtherPage($('.ons-pagination__item:nth-child(6)'), '/page/6', 'Go to the last page (6)', '6');
245
- assertIsNextPage($('.ons-pagination__item:nth-child(7)'), '/page/3', 'Go to the next page (3)', 'Next page');
244
+ assertIsOtherPage($('.ons-pagination__item:nth-child(6)'), '/page/6', 'Last page (6)', '6');
245
+ assertIsNextPage($('.ons-pagination__item:nth-child(7)'), '/page/3', 'Next page (3)', 'Next page');
246
246
  });
247
247
  });
248
248
 
@@ -282,15 +282,15 @@ describe('macro: pagination', () => {
282
282
 
283
283
  it('has a 9 list items ("Previous page", "1", "...", "4", "5", "6", "...", "11", "Next page")', () => {
284
284
  expect($('li').length).toBe(9);
285
- assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/4', 'Go to the previous page (4)', 'Previous page');
286
- assertIsOtherPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Go to the first page', '1');
285
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/4', 'Previous page (4)', 'Previous page');
286
+ assertIsOtherPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'First page', '1');
287
287
  assertIsGap($('.ons-pagination__item:nth-child(3)'));
288
- assertIsPreviousPage($('.ons-pagination__item:nth-child(4)'), '/page/4', 'Go to page 4', '4');
289
- assertIsCurrentPage($('.ons-pagination__item:nth-child(5)'), '/page/5', 'Current page (Page 5 of 11)', '5');
290
- assertIsNextPage($('.ons-pagination__item:nth-child(6)'), '/page/6', 'Go to page 6', '6');
288
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(4)'), '/page/4', 'Page 4', '4');
289
+ assertIsCurrentPage($('.ons-pagination__item:nth-child(5)'), '/page/5', 'Page 5 of 11', '5');
290
+ assertIsNextPage($('.ons-pagination__item:nth-child(6)'), '/page/6', 'Page 6', '6');
291
291
  assertIsGap($('.ons-pagination__item:nth-child(7)'));
292
- assertIsOtherPage($('.ons-pagination__item:nth-child(8)'), '/page/11', 'Go to the last page (11)', '11');
293
- assertIsNextPage($('.ons-pagination__item:nth-child(9)'), '/page/6', 'Go to the next page (6)', 'Next page');
292
+ assertIsOtherPage($('.ons-pagination__item:nth-child(8)'), '/page/11', 'Last page (11)', '11');
293
+ assertIsNextPage($('.ons-pagination__item:nth-child(9)'), '/page/6', 'Next page (6)', 'Next page');
294
294
  });
295
295
  });
296
296
 
@@ -330,13 +330,13 @@ describe('macro: pagination', () => {
330
330
 
331
331
  it('has a 7 list items ("Previous page", "1", "...", "9", "10", "11", "Next page")', () => {
332
332
  expect($('li').length).toBe(7);
333
- assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/9', 'Go to the previous page (9)', 'Previous page');
334
- assertIsOtherPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'Go to the first page', '1');
333
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(1)'), '/page/9', 'Previous page (9)', 'Previous page');
334
+ assertIsOtherPage($('.ons-pagination__item:nth-child(2)'), '/page/1', 'First page', '1');
335
335
  assertIsGap($('.ons-pagination__item:nth-child(3)'));
336
- assertIsPreviousPage($('.ons-pagination__item:nth-child(4)'), '/page/9', 'Go to page 9', '9');
337
- assertIsCurrentPage($('.ons-pagination__item:nth-child(5)'), '/page/10', 'Current page (Page 10 of 11)', '10');
338
- assertIsNextPage($('.ons-pagination__item:nth-child(6)'), '/page/11', 'Go to page 11', '11');
339
- assertIsNextPage($('.ons-pagination__item:nth-child(7)'), '/page/11', 'Go to the next page (11)', 'Next page');
336
+ assertIsPreviousPage($('.ons-pagination__item:nth-child(4)'), '/page/9', 'Page 9', '9');
337
+ assertIsCurrentPage($('.ons-pagination__item:nth-child(5)'), '/page/10', 'Page 10 of 11', '10');
338
+ assertIsNextPage($('.ons-pagination__item:nth-child(6)'), '/page/11', 'Page 11', '11');
339
+ assertIsNextPage($('.ons-pagination__item:nth-child(7)'), '/page/11', 'Next page (11)', 'Next page');
340
340
  });
341
341
  });
342
342
 
@@ -370,7 +370,7 @@ describe('macro: pagination', () => {
370
370
  it('renders the default previousAriaLabel and page number on the Previous link if not provided', () => {
371
371
  const prevItem = $default('.ons-pagination__item--previous');
372
372
  expect(prevItem.length).toBe(1);
373
- expect(prevItem.find('a').attr('aria-label')).toBe('Go to the previous page (1)');
373
+ expect(prevItem.find('a').attr('aria-label')).toBe('Previous page (1)');
374
374
  });
375
375
  it('renders the custom nextAriaLabel and page number on the Next link', () => {
376
376
  const nextItem = $custom('.ons-pagination__item--next');
@@ -380,7 +380,7 @@ describe('macro: pagination', () => {
380
380
  it('renders the default nextAriaLabel and page number on the Next link if not provided', () => {
381
381
  const nextItem = $default('.ons-pagination__item--next');
382
382
  expect(nextItem.length).toBe(1);
383
- expect(nextItem.find('a').attr('aria-label')).toBe('Go to the next page (3)');
383
+ expect(nextItem.find('a').attr('aria-label')).toBe('Next page (3)');
384
384
  });
385
385
  });
386
386
 
@@ -430,7 +430,7 @@ describe('macro: pagination', () => {
430
430
  const firstPageLink = $('.ons-pagination__item a').filter(function () {
431
431
  return $(this).text().trim() === '1';
432
432
  });
433
- expect(firstPageLink.attr('aria-label')).toBe('Go to the first page');
433
+ expect(firstPageLink.attr('aria-label')).toBe('First page');
434
434
  });
435
435
  });
436
436
 
@@ -454,7 +454,7 @@ describe('macro: pagination', () => {
454
454
  }),
455
455
  );
456
456
  const currentPageLink = $('.ons-pagination__item--current a');
457
- expect(currentPageLink.attr('aria-label')).toBe('Current page (Page 2 of 3)');
457
+ expect(currentPageLink.attr('aria-label')).toBe('Page 2 of 3');
458
458
  });
459
459
  });
460
460
 
@@ -482,7 +482,7 @@ describe('macro: pagination', () => {
482
482
  const lastPageLink = $('.ons-pagination__item a').filter(function () {
483
483
  return $(this).text().trim() === '4';
484
484
  });
485
- expect(lastPageLink.attr('aria-label')).toBe('Go to the last page (4)');
485
+ expect(lastPageLink.attr('aria-label')).toBe('Last page (4)');
486
486
  });
487
487
  });
488
488
 
@@ -510,7 +510,7 @@ describe('macro: pagination', () => {
510
510
  const page2Link = $('.ons-pagination__item a').filter(function () {
511
511
  return $(this).text().trim() === '2';
512
512
  });
513
- expect(page2Link.attr('aria-label')).toBe('Go to page 2');
513
+ expect(page2Link.attr('aria-label')).toBe('Page 2');
514
514
  });
515
515
  });
516
516
  });
@@ -69,8 +69,14 @@
69
69
  <span class="ons-panel__assistive-text ons-u-vh"
70
70
  >{{ params.assistiveTextPrefix | default("Important information: ") }}</span
71
71
  >
72
- {% elif params.variant == 'error' or params.variant == 'success' %}
73
- {% set defaultText = "Completed" if params.variant == "success" else "Error" %}
72
+ {% elif params.variant == 'error' or params.variant == 'success' or params.variant == 'pending' %}
73
+ {% if params.variant == "success" %}
74
+ {% set defaultText = "Completed" %}
75
+ {% elif params.variant == "pending" %}
76
+ {% set defaultText = "Pending" %}
77
+ {% else %}
78
+ {% set defaultText = "Error" %}
79
+ {% endif %}
74
80
  <span {% if params.variant == "success" %}id="alert"{% endif %}class="ons-panel__assistive-text ons-u-vh"
75
81
  >{{ params.assistiveTextPrefix | default(defaultText ~ ": ") }}</span
76
82
  >
@@ -15,6 +15,7 @@ describe('macro: panel', () => {
15
15
  ['info', 'Important information:'],
16
16
  ['bare', 'Important information:'],
17
17
  ['error', 'Error:'],
18
+ ['pending', 'Pending:'],
18
19
  ['warn', 'Warning:'],
19
20
  ['warn-branded', 'Warning:'],
20
21
  ['branded', 'Important information:'],
@@ -134,17 +135,22 @@ describe('macro: panel', () => {
134
135
  });
135
136
  });
136
137
 
137
- describe('mode: info', () => {
138
+ describe.each([
139
+ ['info', 'div'],
140
+ ['', 'div'],
141
+ ['pending', 'div'],
142
+ ])('mode: %s', (panelVariant, tagEl) => {
138
143
  it('has the default title tag', () => {
139
144
  const $ = cheerio.load(
140
145
  renderComponent('panel', {
141
146
  ...EXAMPLE_PANEL_BASIC,
142
147
  title: 'Panel title',
148
+ variant: panelVariant,
143
149
  }),
144
150
  );
145
151
 
146
152
  const titleTag = $('.ons-panel__title')[0].tagName;
147
- expect(titleTag).toBe('div');
153
+ expect(titleTag).toBe(tagEl);
148
154
  });
149
155
 
150
156
  it('has the provided `headingLevel`', () => {
@@ -152,6 +158,7 @@ describe('macro: panel', () => {
152
158
  renderComponent('panel', {
153
159
  ...EXAMPLE_PANEL_BASIC,
154
160
  title: 'Panel title',
161
+ variant: panelVariant,
155
162
  headingLevel: 3,
156
163
  }),
157
164
  );
@@ -165,6 +172,7 @@ describe('macro: panel', () => {
165
172
  renderComponent('panel', {
166
173
  ...EXAMPLE_PANEL_BASIC,
167
174
  title: 'Panel title',
175
+ variant: panelVariant,
168
176
  }),
169
177
  );
170
178
 
@@ -216,6 +224,20 @@ describe('macro: panel', () => {
216
224
  expect(titleTag).toBe(tagEl);
217
225
  });
218
226
 
227
+ it('has the provided `headingLevel`', () => {
228
+ const $ = cheerio.load(
229
+ renderComponent('panel', {
230
+ ...EXAMPLE_PANEL_BASIC,
231
+ title: 'Panel title',
232
+ variant: panelVariant,
233
+ headingLevel: 3,
234
+ }),
235
+ );
236
+
237
+ const titleTag = $('.ons-panel__title')[0].tagName;
238
+ expect(titleTag).toBe('h3');
239
+ });
240
+
219
241
  it('has aria-labelledby attribute set with default value', () => {
220
242
  const $ = cheerio.load(
221
243
  renderComponent('panel', {
@@ -247,6 +247,7 @@
247
247
  &--bare,
248
248
  &--success,
249
249
  &--warn,
250
+ &--pending,
250
251
  &--warn-branded,
251
252
  &--announcement {
252
253
  .ons-panel__icon {
@@ -257,6 +258,7 @@
257
258
 
258
259
  @include panel-variant(error, var(--ons-color-errors), var(--ons-color-errors-tint));
259
260
  @include panel-variant(success, var(--ons-color-success), var(--ons-color-success-tint));
261
+ @include panel-variant(pending, var(--ons-color-pending), var(--ons-color-pending-tint));
260
262
  @include panel-variant(info, var(--ons-color-info), var(--ons-color-info-tint));
261
263
  @include panel-variant(branded, var(--ons-color-branded), var(--ons-color-branded-tint));
262
264
  @include panel-variant(warn, transparent, transparent);
@@ -0,0 +1,9 @@
1
+ {% from "components/panel/_macro.njk" import onsPanel %}
2
+
3
+ {{
4
+ onsPanel({
5
+ "variant": 'pending',
6
+ "id": 'pending-id',
7
+ "body": 'Information is being processed'
8
+ })
9
+ }}
@@ -140,7 +140,8 @@
140
140
  "limit": radio.other.charCheckLimit.limit,
141
141
  "charCountSingular": radio.other.charCheckLimit.charCountSingular,
142
142
  "charCountPlural": radio.other.charCheckLimit.charCountPlural
143
- }
143
+ },
144
+ "attributes": radio.other.attributes
144
145
  })
145
146
  }}
146
147
  {% endif %}
@@ -129,6 +129,15 @@ const EXAMPLE_RADIO_ITEM_TEXTAREA_WITH_PRESET_VALUE = {
129
129
  id: 'other-textarea-input',
130
130
  name: 'other-answer',
131
131
  value: 'other answer',
132
+ attributes: { a: 42 },
133
+ label: {
134
+ text: 'Example radio with Text area',
135
+ },
136
+ charCheckLimit: {
137
+ limit: 200,
138
+ charCountSingular: 'You have {x} character remaining',
139
+ charCountPlural: 'You have {x} characters remaining',
140
+ },
132
141
  },
133
142
  };
134
143
 
@@ -558,6 +567,33 @@ describe('macro: radios', () => {
558
567
 
559
568
  expect($('.ons-input--textarea').text()).toBe('other answer');
560
569
  });
570
+
571
+ it('renders other "textarea" component for item', () => {
572
+ const faker = templateFaker();
573
+ const textareaSpy = faker.spy('textarea');
574
+
575
+ faker.renderComponent('radios', {
576
+ ...EXAMPLE_RADIOS_MINIMAL,
577
+ radios: [EXAMPLE_RADIO_ITEM_TEXTAREA_WITH_PRESET_VALUE],
578
+ });
579
+
580
+ expect(textareaSpy.occurrences).toContainEqual({
581
+ id: 'other-textarea-input',
582
+ name: 'other-answer',
583
+ value: 'other answer',
584
+ attributes: { a: 42 },
585
+ label: {
586
+ id: 'other-textarea-input-label',
587
+ text: 'Example radio with Text area',
588
+ classes: 'ons-u-fw-n',
589
+ },
590
+ charCheckLimit: {
591
+ limit: 200,
592
+ charCountSingular: 'You have {x} character remaining',
593
+ charCountPlural: 'You have {x} characters remaining',
594
+ },
595
+ });
596
+ });
561
597
  });
562
598
 
563
599
  describe('clear radios button', () => {
@@ -2,22 +2,6 @@
2
2
  {% from "components/button/_macro.njk" import onsButton %}
3
3
  {% from "components/icon/_macro.njk" import onsIcon %}
4
4
  {% set variants = params.variants if params.variants %}
5
- {% set hasRowSpan = false %}
6
- {% for row in params.thList %}
7
- {% for th in row.ths %}
8
- {% if th.rowspan %}
9
- {% set hasRowSpan = true %}
10
- {% endif %}
11
- {% endfor %}
12
- {% endfor %}
13
-
14
- {% for row in params.trs %}
15
- {% for td in row.tds %}
16
- {% if td.rowspan %}
17
- {% set hasRowSpan = true %}
18
- {% endif %}
19
- {% endfor %}
20
- {% endfor %}
21
5
 
22
6
  <div class="ons-table-scrollable ons-table-scrollable--on">
23
7
  <div
@@ -26,15 +10,16 @@
26
10
  role="region"
27
11
  aria-label="{{ params.caption }}. {{ params.ariaLabel | default('Scrollable table') }}"
28
12
  >
13
+ {# Uses multiple loops to set the rowspan class so that it can work in both nunjucks and jinja2 environments due to the scoping rules of each language #}
29
14
  <table
30
15
  {% if params.id %}id="{{ params.id }}"{% endif %}
31
- class="ons-table{{ ' ' + params.tableClasses if params.tableClasses else '' }}{% if hasRowSpan %}{{ ' ' }}ons-table--has-rowspan{% endif %}{% if variants %}{% if variants is not string %}{% for variant in variants %}{{ ' ' }}ons-table--{{ variant }}{% endfor %}{% else %}{{ ' ' }}ons-table--{{ variants }}{% endif %}{% endif %}"
16
+ class="ons-table{{ ' ' + params.tableClasses if params.tableClasses else '' }}{% for row in params.thList %}{% for th in row.ths %}{% if th.rowspan %}{{ ' ' }}ons-table--has-rowspan{% endif %}{% endfor %}{% endfor %}{% for row in params.trs %}{% for td in row.tds %}{% if td.rowspan %}{{ ' ' }}ons-table--has-rowspan{% endif %}{% endfor %}{% endfor %}{% if variants %}{% if variants is not string %}{% for variant in variants %}{{ ' ' }}ons-table--{{ variant }}{% endfor %}{% else %}{{ ' ' }}ons-table--{{ variants }}{% endif %}{% endif %}"
32
17
  {% if params.sortBy and 'sortable' in variants %}
33
18
  data-aria-sort="{{ params.sortBy }}" data-aria-asc="{{ params.ariaAsc }}" data-aria-desc="{{ params.ariaDesc }}"
34
19
  {% endif %}
35
20
  >
36
21
  {% if params.caption %}
37
- <caption class="ons-table__caption{{ " ons-u-vh" if params.hideCaption }}">
22
+ <caption class="ons-table__caption{{ ' ons-u-vh' if params.hideCaption }}">
38
23
  {{ params.caption }}
39
24
  </caption>
40
25
  {% endif %}
@@ -43,7 +28,7 @@
43
28
  {% if params.thList %}
44
29
  {% set thGroups = params.thList %}
45
30
  {% else %}
46
- {% set thGroups = [ { ths: params.ths } ] %}
31
+ {% set thGroups = [ { "ths": params.ths } ] %}
47
32
  {% endif %}
48
33
  {% for headerCols in thGroups %}
49
34
  <tr class="ons-table__row">