@ons/design-system 62.2.3 → 63.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 (74) hide show
  1. package/components/access-code/example-access-code-error.njk +1 -1
  2. package/components/accordion/_macro.njk +1 -1
  3. package/components/breadcrumbs/_macro.njk +2 -2
  4. package/components/breadcrumbs/_macro.spec.js +1 -1
  5. package/components/button/_macro.njk +1 -1
  6. package/components/button/_macro.spec.js +6 -6
  7. package/components/card/_macro.njk +1 -1
  8. package/components/card/_macro.spec.js +1 -1
  9. package/components/collapsible/_macro.spec.js +1 -1
  10. package/components/content-pagination/_macro.njk +2 -2
  11. package/components/content-pagination/_macro.spec.js +2 -2
  12. package/components/details/_macro.njk +1 -1
  13. package/components/details/_macro.spec.js +1 -1
  14. package/components/document-list/_macro.njk +1 -1
  15. package/components/footer/_macro.njk +2 -2
  16. package/components/footer/_macro.spec.js +7 -7
  17. package/components/header/_macro.njk +3 -3
  18. package/components/header/_macro.spec.js +5 -6
  19. package/components/{icons → icon}/_macro.spec.js +7 -7
  20. package/components/{images → image}/_macro.spec.js +13 -13
  21. package/components/{images/example-images-for-regular-screens.njk → image/example-image-for-regular-screens.njk} +1 -1
  22. package/components/{images/example-images-for-retina-screens.njk → image/example-image-for-retina-screens.njk} +1 -1
  23. package/components/{lists → list}/_macro.njk +3 -3
  24. package/components/{lists → list}/_macro.spec.js +42 -42
  25. package/components/message/_macro.njk +2 -2
  26. package/components/message/_macro.spec.js +0 -1
  27. package/components/metadata/_macro.njk +1 -1
  28. package/components/navigation/_macro.njk +3 -3
  29. package/components/pagination/_macro.njk +65 -69
  30. package/components/pagination/_macro.spec.js +18 -16
  31. package/components/pagination/example-pagination-first.njk +5 -5
  32. package/components/pagination/example-pagination-last.njk +5 -5
  33. package/components/pagination/example-pagination-with-no-range-indicator.njk +11 -11
  34. package/components/pagination/example-pagination.njk +2 -2
  35. package/components/panel/_macro.njk +2 -2
  36. package/components/panel/_macro.spec.js +2 -2
  37. package/components/panel/example-panel-with-error-summary.njk +1 -1
  38. package/components/phase-banner/_phase-banner.scss +2 -1
  39. package/components/question/_macro.njk +1 -1
  40. package/components/question/_macro.spec.js +1 -1
  41. package/components/quote/_macro.njk +1 -1
  42. package/components/quote/_macro.spec.js +1 -1
  43. package/components/related-content/_macro.njk +1 -1
  44. package/components/related-content/_macro.spec.js +1 -1
  45. package/components/related-content/example-related-content-general.njk +1 -1
  46. package/components/relationships/example-relationships-error.njk +1 -1
  47. package/components/section-navigation/_macro.njk +2 -2
  48. package/components/share-page/_macro.njk +1 -1
  49. package/components/share-page/_macro.spec.js +5 -5
  50. package/components/summary/_macro.njk +4 -4
  51. package/components/summary/_macro.spec.js +1 -1
  52. package/components/summary/example-summary-grouped-total.njk +3 -3
  53. package/components/table/_macro.njk +3 -3
  54. package/components/table/_macro.spec.js +1 -1
  55. package/components/table/example-table-basic.njk +1 -2
  56. package/components/table-of-contents/_macro.njk +1 -1
  57. package/components/table-of-contents/_macro.spec.js +2 -2
  58. package/components/tabs/_macro.njk +2 -2
  59. package/components/tabs/_macro.spec.js +5 -8
  60. package/components/tabs/example-tabs.njk +1 -0
  61. package/components/timeline/_macro.njk +1 -1
  62. package/components/timeline/_macro.spec.js +1 -1
  63. package/components/timeout-modal/example-timeout-modal.njk +2 -0
  64. package/css/main.css +3 -3
  65. package/css/print.css +1 -1
  66. package/package.json +1 -1
  67. package/scripts/main.es5.js +1 -1
  68. package/scripts/main.js +1 -1
  69. package/scss/main.scss +3 -3
  70. /package/components/{icons/_icons.scss → icon/_icon.scss} +0 -0
  71. /package/components/{icons → icon}/_macro.njk +0 -0
  72. /package/components/{images/_images.scss → image/_image.scss} +0 -0
  73. /package/components/{images → image}/_macro.njk +0 -0
  74. /package/components/{lists → list}/_list.scss +0 -0
@@ -22,11 +22,11 @@ const EXAMPLE_ITEM_NAVIGATION_TITLE = {
22
22
  navigationTitle: 'Nav friendly title',
23
23
  };
24
24
 
25
- describe('macro: lists', () => {
25
+ describe('macro: list', () => {
26
26
  describe('list element', () => {
27
27
  it('has `id` attribute when provided', () => {
28
28
  const $ = cheerio.load(
29
- renderComponent('lists', {
29
+ renderComponent('list', {
30
30
  ...EXAMPLE_LIST_TEXT_ITEMS,
31
31
  id: 'example-id',
32
32
  }),
@@ -37,7 +37,7 @@ describe('macro: lists', () => {
37
37
 
38
38
  it('has additionally provided style classes', () => {
39
39
  const $ = cheerio.load(
40
- renderComponent('lists', {
40
+ renderComponent('list', {
41
41
  ...EXAMPLE_LIST_TEXT_ITEMS,
42
42
  classes: 'extra-class another-extra-class',
43
43
  }),
@@ -49,7 +49,7 @@ describe('macro: lists', () => {
49
49
 
50
50
  it('has provided variant style class when one variant is provided', () => {
51
51
  const $ = cheerio.load(
52
- renderComponent('lists', {
52
+ renderComponent('list', {
53
53
  ...EXAMPLE_LIST_TEXT_ITEMS,
54
54
  variants: 'dashed',
55
55
  }),
@@ -60,7 +60,7 @@ describe('macro: lists', () => {
60
60
 
61
61
  it('has provided variant style classes when multiple variants are provided', () => {
62
62
  const $ = cheerio.load(
63
- renderComponent('lists', {
63
+ renderComponent('list', {
64
64
  ...EXAMPLE_LIST_TEXT_ITEMS,
65
65
  variants: ['dashed', 'inline'],
66
66
  }),
@@ -72,7 +72,7 @@ describe('macro: lists', () => {
72
72
 
73
73
  it('assumes the "bare" variant with a prefix modifier class when the first list item has a prefix', () => {
74
74
  const $ = cheerio.load(
75
- renderComponent('lists', {
75
+ renderComponent('list', {
76
76
  itemsList: [{ text: 'Item text', prefix: 'Abc' }],
77
77
  }),
78
78
  );
@@ -83,7 +83,7 @@ describe('macro: lists', () => {
83
83
 
84
84
  it('assumes the "bare" variant with a suffix modifier class when the first list item has a suffix', () => {
85
85
  const $ = cheerio.load(
86
- renderComponent('lists', {
86
+ renderComponent('list', {
87
87
  itemsList: [{ text: 'Item text', suffix: 'Abc' }],
88
88
  }),
89
89
  );
@@ -94,7 +94,7 @@ describe('macro: lists', () => {
94
94
 
95
95
  it('assumes the "bare" variant with a icons modifier class when the first list item has an icon', () => {
96
96
  const $ = cheerio.load(
97
- renderComponent('lists', {
97
+ renderComponent('list', {
98
98
  ...EXAMPLE_LIST_TEXT_ITEMS,
99
99
  iconPosition: 'before',
100
100
  iconType: 'check',
@@ -106,14 +106,14 @@ describe('macro: lists', () => {
106
106
  });
107
107
 
108
108
  it('renders a <ul> element by default', () => {
109
- const $ = cheerio.load(renderComponent('lists', EXAMPLE_LIST_TEXT_ITEMS));
109
+ const $ = cheerio.load(renderComponent('list', EXAMPLE_LIST_TEXT_ITEMS));
110
110
 
111
111
  expect($('.ons-list')[0].tagName).toBe('ul');
112
112
  });
113
113
 
114
114
  it('renders a custom element when a custom `element` is provided', () => {
115
115
  const $ = cheerio.load(
116
- renderComponent('lists', {
116
+ renderComponent('list', {
117
117
  ...EXAMPLE_LIST_TEXT_ITEMS,
118
118
  element: 'div',
119
119
  }),
@@ -124,7 +124,7 @@ describe('macro: lists', () => {
124
124
 
125
125
  it('renders a <ol> element when specified', () => {
126
126
  const $ = cheerio.load(
127
- renderComponent('lists', {
127
+ renderComponent('list', {
128
128
  ...EXAMPLE_LIST_TEXT_ITEMS,
129
129
  element: 'ol',
130
130
  }),
@@ -135,7 +135,7 @@ describe('macro: lists', () => {
135
135
 
136
136
  it('has the expected quantity of <li> elements when a <ol> element is specified', () => {
137
137
  const $ = cheerio.load(
138
- renderComponent('lists', {
138
+ renderComponent('list', {
139
139
  ...EXAMPLE_LIST_TEXT_ITEMS,
140
140
  element: 'ol',
141
141
  }),
@@ -146,7 +146,7 @@ describe('macro: lists', () => {
146
146
 
147
147
  describe('when <ol> is specified but there is only one list item', () => {
148
148
  const $ = cheerio.load(
149
- renderComponent('lists', {
149
+ renderComponent('list', {
150
150
  element: 'ol',
151
151
  itemsList: [{ text: 'Only item' }],
152
152
  }),
@@ -167,7 +167,7 @@ describe('macro: lists', () => {
167
167
 
168
168
  it('has additionally provided `attributes`', () => {
169
169
  const $ = cheerio.load(
170
- renderComponent('lists', {
170
+ renderComponent('list', {
171
171
  ...EXAMPLE_LIST_TEXT_ITEMS,
172
172
  attributes: {
173
173
  a: 123,
@@ -189,7 +189,7 @@ describe('macro: lists', () => {
189
189
  describe('content without link', () => {
190
190
  it('passes jest-axe checks', async () => {
191
191
  const $ = cheerio.load(
192
- renderComponent('lists', {
192
+ renderComponent('list', {
193
193
  itemsList: [item],
194
194
  }),
195
195
  );
@@ -200,7 +200,7 @@ describe('macro: lists', () => {
200
200
 
201
201
  it('renders the expected list item text', () => {
202
202
  const $ = cheerio.load(
203
- renderComponent('lists', {
203
+ renderComponent('list', {
204
204
  itemsList: [item],
205
205
  }),
206
206
  );
@@ -210,7 +210,7 @@ describe('macro: lists', () => {
210
210
 
211
211
  it('does not render a hyperlink element', () => {
212
212
  const $ = cheerio.load(
213
- renderComponent('lists', {
213
+ renderComponent('list', {
214
214
  itemsList: [item],
215
215
  }),
216
216
  );
@@ -222,7 +222,7 @@ describe('macro: lists', () => {
222
222
  describe('content with an internal link', () => {
223
223
  it('passes jest-axe checks', async () => {
224
224
  const $ = cheerio.load(
225
- renderComponent('lists', {
225
+ renderComponent('list', {
226
226
  itemsList: [
227
227
  {
228
228
  ...item,
@@ -238,7 +238,7 @@ describe('macro: lists', () => {
238
238
 
239
239
  it('renders a hyperlink element', () => {
240
240
  const $ = cheerio.load(
241
- renderComponent('lists', {
241
+ renderComponent('list', {
242
242
  itemsList: [
243
243
  {
244
244
  ...item,
@@ -254,7 +254,7 @@ describe('macro: lists', () => {
254
254
 
255
255
  it('does not render a hyperlink element for current item', () => {
256
256
  const $ = cheerio.load(
257
- renderComponent('lists', {
257
+ renderComponent('list', {
258
258
  itemsList: [
259
259
  {
260
260
  ...item,
@@ -270,7 +270,7 @@ describe('macro: lists', () => {
270
270
 
271
271
  it('supports the `inPageLink` variant', () => {
272
272
  const $ = cheerio.load(
273
- renderComponent('lists', {
273
+ renderComponent('list', {
274
274
  itemsList: [
275
275
  {
276
276
  ...item,
@@ -286,7 +286,7 @@ describe('macro: lists', () => {
286
286
 
287
287
  it('has additionally provided style classes', () => {
288
288
  const $ = cheerio.load(
289
- renderComponent('lists', {
289
+ renderComponent('list', {
290
290
  itemsList: [
291
291
  {
292
292
  ...item,
@@ -303,7 +303,7 @@ describe('macro: lists', () => {
303
303
 
304
304
  it('has the provided `target` attribute', () => {
305
305
  const $ = cheerio.load(
306
- renderComponent('lists', {
306
+ renderComponent('list', {
307
307
  itemsList: [
308
308
  {
309
309
  ...item,
@@ -319,7 +319,7 @@ describe('macro: lists', () => {
319
319
 
320
320
  it('renders visually hidden screen reader message when target is "_blank"', () => {
321
321
  const $ = cheerio.load(
322
- renderComponent('lists', {
322
+ renderComponent('list', {
323
323
  itemsList: [
324
324
  {
325
325
  ...item,
@@ -336,7 +336,7 @@ describe('macro: lists', () => {
336
336
 
337
337
  it('renders a default visually hidden screen reader message when target is "_blank"', () => {
338
338
  const $ = cheerio.load(
339
- renderComponent('lists', {
339
+ renderComponent('list', {
340
340
  itemsList: [
341
341
  {
342
342
  ...item,
@@ -352,7 +352,7 @@ describe('macro: lists', () => {
352
352
 
353
353
  it('has additionally provided `attributes`', () => {
354
354
  const $ = cheerio.load(
355
- renderComponent('lists', {
355
+ renderComponent('list', {
356
356
  itemsList: [
357
357
  {
358
358
  ...item,
@@ -372,7 +372,7 @@ describe('macro: lists', () => {
372
372
 
373
373
  it('renders visually hidden prefix', () => {
374
374
  const $ = cheerio.load(
375
- renderComponent('lists', {
375
+ renderComponent('list', {
376
376
  itemsList: [
377
377
  {
378
378
  ...item,
@@ -390,7 +390,7 @@ describe('macro: lists', () => {
390
390
  describe('content with an external link', () => {
391
391
  it('passes jest-axe checks', async () => {
392
392
  const $ = cheerio.load(
393
- renderComponent('lists', {
393
+ renderComponent('list', {
394
394
  itemsList: [
395
395
  {
396
396
  ...item,
@@ -409,7 +409,7 @@ describe('macro: lists', () => {
409
409
  const faker = templateFaker();
410
410
  const externalLinkSpy = faker.spy('external-link');
411
411
 
412
- faker.renderComponent('lists', {
412
+ faker.renderComponent('list', {
413
413
  itemsList: [
414
414
  {
415
415
  ...item,
@@ -429,7 +429,7 @@ describe('macro: lists', () => {
429
429
  const faker = templateFaker();
430
430
  const externalLinkSpy = faker.spy('external-link');
431
431
 
432
- faker.renderComponent('lists', {
432
+ faker.renderComponent('list', {
433
433
  itemsList: [
434
434
  {
435
435
  ...item,
@@ -448,7 +448,7 @@ describe('macro: lists', () => {
448
448
  describe('prefix', () => {
449
449
  it('renders item `prefix` content', () => {
450
450
  const $ = cheerio.load(
451
- renderComponent('lists', {
451
+ renderComponent('list', {
452
452
  itemsList: [
453
453
  {
454
454
  prefix: '[PREFIX]',
@@ -467,7 +467,7 @@ describe('macro: lists', () => {
467
467
 
468
468
  it('marks `prefix` content as visually hidden when list element is not <ol>', () => {
469
469
  const $ = cheerio.load(
470
- renderComponent('lists', {
470
+ renderComponent('list', {
471
471
  itemsList: [
472
472
  {
473
473
  prefix: '[PREFIX]',
@@ -482,7 +482,7 @@ describe('macro: lists', () => {
482
482
 
483
483
  it('does not mark `prefix` content as visually hidden when list element is <ol>', () => {
484
484
  const $ = cheerio.load(
485
- renderComponent('lists', {
485
+ renderComponent('list', {
486
486
  element: 'ol',
487
487
  itemsList: [
488
488
  {
@@ -504,7 +504,7 @@ describe('macro: lists', () => {
504
504
  describe('suffix', () => {
505
505
  it('renders item `suffix` content', () => {
506
506
  const $ = cheerio.load(
507
- renderComponent('lists', {
507
+ renderComponent('list', {
508
508
  itemsList: [
509
509
  {
510
510
  suffix: '[SUFFIX]',
@@ -523,7 +523,7 @@ describe('macro: lists', () => {
523
523
 
524
524
  it('marks `suffix` content as visually hidden when list element is not <ol>', () => {
525
525
  const $ = cheerio.load(
526
- renderComponent('lists', {
526
+ renderComponent('list', {
527
527
  itemsList: [
528
528
  {
529
529
  suffix: '[SUFFIX]',
@@ -538,7 +538,7 @@ describe('macro: lists', () => {
538
538
 
539
539
  it('does not mark `suffix` content as visually hidden when list element is <ol>', () => {
540
540
  const $ = cheerio.load(
541
- renderComponent('lists', {
541
+ renderComponent('list', {
542
542
  element: 'ol',
543
543
  itemsList: [
544
544
  {
@@ -560,9 +560,9 @@ describe('macro: lists', () => {
560
560
  describe('icons', () => {
561
561
  it.each([['before'], ['after']])('renders default icon on list items when icon is positioned %s', iconPosition => {
562
562
  const faker = templateFaker();
563
- const iconsSpy = faker.spy('icons');
563
+ const iconsSpy = faker.spy('icon');
564
564
 
565
- faker.renderComponent('lists', {
565
+ faker.renderComponent('list', {
566
566
  ...EXAMPLE_LIST_TEXT_ITEMS,
567
567
  iconPosition,
568
568
  iconType: 'check',
@@ -575,9 +575,9 @@ describe('macro: lists', () => {
575
575
 
576
576
  it.each([['before'], ['after']])('renders a custom icon on specific list items when icon is positioned %s', iconPosition => {
577
577
  const faker = templateFaker();
578
- const iconsSpy = faker.spy('icons');
578
+ const iconsSpy = faker.spy('icon');
579
579
 
580
- faker.renderComponent('lists', {
580
+ faker.renderComponent('list', {
581
581
  itemsList: [{ text: 'First item' }, { text: 'Second item', iconType: 'print' }, { text: 'Third item' }],
582
582
  iconPosition,
583
583
  iconType: 'check',
@@ -591,7 +591,7 @@ describe('macro: lists', () => {
591
591
 
592
592
  it('renders the icon before the item text', () => {
593
593
  const $ = cheerio.load(
594
- renderComponent('lists', {
594
+ renderComponent('list', {
595
595
  itemsList: [{ text: '<span id="first">First item</span>' }, { text: '<span id="second">Second item</span>' }],
596
596
  iconPosition: 'before',
597
597
  iconType: 'check',
@@ -604,7 +604,7 @@ describe('macro: lists', () => {
604
604
 
605
605
  it('renders the icon after the item text', () => {
606
606
  const $ = cheerio.load(
607
- renderComponent('lists', {
607
+ renderComponent('list', {
608
608
  itemsList: [{ text: '<span id="first">First item</span>' }, { text: '<span id="second">Second item</span>' }],
609
609
  iconPosition: 'after',
610
610
  iconType: 'check',
@@ -1,7 +1,7 @@
1
1
  {%- macro onsMessage(params) -%}
2
2
  <div class="ons-message ons-message--{{ params.type }}">
3
3
  <div class="ons-message__head">
4
- <dl class="ons-message__metadata" {% if params.id %} id="{{ params.id }}"{% endif %} {% if params.name %} name="{{ params.name }}"{% endif %}>
4
+ <dl class="ons-message__metadata" {% if params.id %} id="{{ params.id }}"{% endif %}>
5
5
  <div class="ons-message__sender">
6
6
  <dt class="ons-message__term ons-u-fw-b">{{ params.fromLabel }}:</dt>
7
7
  <dd class="ons-message__value ons-u-fw-b" {% if params.fromId %} id="{{ params.fromId }}"{% endif %} {% if params.fromName %} name="{{ params.fromName }}"{% endif %}>{{ params.fromValue }}</dd>
@@ -15,7 +15,7 @@
15
15
  <a class="ons-message__unread-link" {% if params.unreadLinkId %}id="{{ params.unreadLinkId }}"{% endif %} href="{{ params.unreadLink }}">{{ params.unreadLinkText }}</a>
16
16
  {% endif %}
17
17
  </div>
18
- <div class="ons-message__body" {% if params.messageID %} id="{{ params.messageID }}"{% endif %} {% if params.messageName %} name="{{ params.messageName }}"{% endif %}>
18
+ <div class="ons-message__body" {% if params.messageID %} id="{{ params.messageID }}"{% endif %}>
19
19
  {{ caller() }}
20
20
  </div>
21
21
  </div>
@@ -18,7 +18,6 @@ const EXAMPLE_MESSAGE = {
18
18
  unreadLink: 'https://example.com/message/1',
19
19
  unreadLinkText: 'Unread message',
20
20
  id: 'message1',
21
- name: 'example-message-1',
22
21
  fromId: 'from1',
23
22
  sentId: 'sent1',
24
23
  unreadLinkId: 'unreadLink1',
@@ -1,6 +1,6 @@
1
1
  {% macro onsMetadata(params) %}
2
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
- {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
3
+ {% for item in params.itemsList %}
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 %}
@@ -40,7 +40,7 @@
40
40
  {% endif %}
41
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">
42
42
  <ul class="ons-navigation__list">
43
- {% for item in (params.navigation.itemsList if params.navigation.itemsList is iterable else params.navigation.itemsList.items()) %}
43
+ {% for item in params.navigation.itemsList %}
44
44
  <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
45
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>
@@ -53,7 +53,7 @@
53
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.fullWidth or params.navigation.fullWidth }}{{ ' ons-container--wide' if params.wide or params.navigation.wide }}">
55
55
  <ul class="ons-navigation__list ons-navigation__list">
56
- {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
56
+ {% for item in params.navigation.subNavigation.itemsList %}
57
57
  <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
58
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>
@@ -79,7 +79,7 @@
79
79
  <li class="ons-navigation__item">
80
80
  <a class="ons-navigation__link" href="{{ params.navigation.subNavigation.overviewURL }}">{{ params.navigation.subNavigation.overviewText | default('Overview') }}</a>
81
81
  </li>
82
- {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
82
+ {% for item in params.navigation.subNavigation.itemsList %}
83
83
  <li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
84
84
  <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
85
  {% if item.sections %}
@@ -1,72 +1,68 @@
1
1
  {% macro onsPagination(params) %}
2
- {% set currentPageIndex = "" %}
3
- {% for page in params.pages %}
4
- {% if page.current %}
5
- {% set currentPageIndex = loop.index %}
6
- {% endif %}
7
- {% endfor %}
2
+ {% set currentPageIndex = params.currentPageNumber|int %}
3
+ {% set totalPages = params.pages | length|int %}
4
+ {% set position = "Page " ~ currentPageIndex ~ " of " ~ totalPages %}
5
+ {% set lastPage = params.pages | last %}
6
+ {% set firstPage = params.pages | first %}
7
+ {% set prevPageIndex = currentPageIndex - 1 %}
8
+ {% set nextPageIndex = currentPageIndex + 1 %}
8
9
 
9
- {% set totalPages = params.pages | length %}
10
- {% set position = "Page " + currentPageIndex + " of " + totalPages %}
11
- {% set lastPage = params.pages | last %}
12
- {% set firstPage = params.pages | first %}
13
-
14
- <nav class="ons-pagination {{ params.classes }}{% if params.hideRangeIndicator %} ons-pagination--no-indicator{% endif %}" aria-label="Pagination ({{ position }})">
15
- <div class="ons-pagination__position">{{ position }}</div>
16
- <ul class="ons-pagination__items">
17
- {% if currentPageIndex != 1 %}
18
- {% set prevPageIndex = currentPageIndex - 2 %}
19
- <li class="ons-pagination__item ons-pagination__item--previous">
20
- <a href="{{ params.pages[prevPageIndex].url }}" class="ons-pagination__link" rel="prev" aria-label="Go to the previous page (Page {{ currentPageIndex - 1 }})">{{ params.previous }}</a>
21
- </li>
22
- {% endif %}
23
- {% if currentPageIndex > 2 %}
24
- <li class="ons-pagination__item{% if firstPage.current == true %} ons-pagination__item--current{% endif %}">
25
- <a href="{{ firstPage.url }}" class="ons-pagination__link" aria-label="Go to the first page (Page 1)">1</a>
26
- </li>
27
- {% endif %}
28
- {% if currentPageIndex > 4 %}
29
- <li class="ons-pagination__item ons-pagination__item--gap">&hellip;</li>
30
- {% endif %}
31
- {% for page in params.pages %}
32
- {% set showPage = false %}
33
- {# Show the current, next and previous page
34
- Show page 2 if the current page index is within the first 4 pages
35
- Show the penultimate page if the current page index is within the last 4 pages #}
36
- {% if (loop.index == currentPageIndex) or (loop.index == currentPageIndex + 1) or (loop.index == currentPageIndex - 1) or (loop.index == 2 and currentPageIndex <= 4) or ((loop.index == totalPages - 1) and (currentPageIndex > totalPages - 4)) %}
37
- {% set showPage = true %}
38
- {% endif %}
39
- {% if showPage == true %}
40
- <li class="ons-pagination__item{% if page.current == true %} ons-pagination__item--current{% endif %}">
41
- <a href="{{ page.url }}" class="ons-pagination__link"
42
- {%- if page.current -%}
43
- aria-current="true" aria-label="Current page ({{ position }})"
44
- {%- else -%}
45
- aria-label="Go to page {{ loop.index }}"
46
- {%- endif -%}
47
- {%- if loop.index == currentPageIndex - 1 -%}
48
- rel="prev"
49
- {%- endif -%}
50
- {%- if loop.index == currentPageIndex + 1 -%}
51
- rel="next"
52
- {%- endif -%}
53
- >{{ loop.index }}</a>
54
- </li>
55
- {% endif %}
56
- {% endfor %}
57
- {% if currentPageIndex < totalPages - 3 %}
58
- <li class="ons-pagination__item ons-pagination__item--gap">&hellip;</li>
59
- {% endif %}
60
- {% if currentPageIndex < totalPages - 1 %}
61
- <li class="ons-pagination__item{% if lastPage.current == true %} ons-pagination__item--current{% endif %}">
62
- <a href="{{ lastPage.url }}" class="ons-pagination__link" aria-label="Go to the last page (Page {{ totalPages }})">{{ totalPages }}</a>
63
- </li>
64
- {% endif %}
65
- {% if totalPages > 1 and totalPages != currentPageIndex %}
66
- <li class="ons-pagination__item ons-pagination__item--next">
67
- <a href="{{ params.pages[currentPageIndex].url }}" class="ons-pagination__link" rel="next" aria-label="Go to the next page (Page {{ currentPageIndex + 1 }})">{{ params.next }}</a>
68
- </li>
69
- {% endif %}
70
- </ul>
71
- </nav>
10
+ <nav class="ons-pagination {{ params.classes }}{% if params.hideRangeIndicator %} ons-pagination--no-indicator{% endif %}" aria-label="Pagination ({{ position }})">
11
+ <div class="ons-pagination__position">{{ position }}</div>
12
+ <ul class="ons-pagination__items">
13
+ {% if currentPageIndex != 1 %}
14
+ {% set prevPageIndex = currentPageIndex - 2 %}
15
+ <li class="ons-pagination__item ons-pagination__item--previous">
16
+ <a href="{{ params.pages[prevPageIndex].url }}" class="ons-pagination__link" rel="prev" aria-label="Go to the previous page (Page {{ currentPageIndex - 1 }})">{{ params.previous }}</a>
17
+ </li>
18
+ {% endif %}
19
+ {% if currentPageIndex > 2 %}
20
+ <li class="ons-pagination__item{% if (currentPageIndex == 1) %} ons-pagination__item--current{% endif %}">
21
+ <a href="{{ firstPage.url }}" class="ons-pagination__link" aria-label="Go to the first page (Page 1)">1</a>
22
+ </li>
23
+ {% endif %}
24
+ {% if currentPageIndex > 4 %}
25
+ <li class="ons-pagination__item ons-pagination__item--gap">&hellip;</li>
26
+ {% endif %}
27
+ {% for page in params.pages %}
28
+ {% set showPage = false %}
29
+ {# Show the current, next and previous page
30
+ Show page 2 if the current page index is within the first 4 pages
31
+ Show the penultimate page if the current page index is within the last 4 pages #}
32
+ {% if (loop.index == currentPageIndex) or (loop.index == currentPageIndex + 1) or (loop.index == currentPageIndex - 1) or (loop.index == 2 and currentPageIndex <= 4) or ((loop.index == totalPages - 1) and (currentPageIndex > totalPages - 4)) %}
33
+ {% set showPage = true %}
34
+ {% endif %}
35
+ {% if showPage == true %}
36
+ <li class="ons-pagination__item{% if loop.index == currentPageIndex %} ons-pagination__item--current{% endif %}">
37
+ <a href="{{ page.url }}" class="ons-pagination__link"
38
+ {%- if loop.index == currentPageIndex -%}
39
+ aria-current="true" aria-label="Current page ({{ position }})"
40
+ {%- else -%}
41
+ aria-label="Go to page {{ loop.index }}"
42
+ {%- endif -%}
43
+ {%- if loop.index == currentPageIndex - 1 -%}
44
+ rel="prev"
45
+ {%- endif -%}
46
+ {%- if loop.index == currentPageIndex + 1 -%}
47
+ rel="next"
48
+ {%- endif -%}
49
+ >{{ loop.index }}</a>
50
+ </li>
51
+ {% endif %}
52
+ {% endfor %}
53
+ {% if currentPageIndex < totalPages - 3 %}
54
+ <li class="ons-pagination__item ons-pagination__item--gap">&hellip;</li>
55
+ {% endif %}
56
+ {% if currentPageIndex < totalPages - 1 %}
57
+ <li class="ons-pagination__item{% if currentPageIndex == totalPages %} ons-pagination__item--current{% endif %}">
58
+ <a href="{{ lastPage.url }}" class="ons-pagination__link" aria-label="Go to the last page (Page {{ totalPages }})">{{ totalPages }}</a>
59
+ </li>
60
+ {% endif %}
61
+ {% if totalPages > 1 and totalPages != currentPageIndex %}
62
+ <li class="ons-pagination__item ons-pagination__item--next">
63
+ <a href="{{ params.pages[currentPageIndex].url }}" class="ons-pagination__link" rel="next" aria-label="Go to the next page (Page {{ currentPageIndex + 1 }})">{{ params.next }}</a>
64
+ </li>
65
+ {% endif %}
66
+ </ul>
67
+ </nav>
72
68
  {% endmacro %}