@ons/design-system 72.6.0 → 72.9.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 (42) hide show
  1. package/components/breadcrumbs/_breadcrumbs.scss +1 -0
  2. package/components/chart/_chart.scss +10 -0
  3. package/components/chart/_macro.njk +50 -32
  4. package/components/chart/_macro.spec.js +201 -0
  5. package/components/chart/annotations-options.js +1 -1
  6. package/components/chart/area-chart.js +26 -0
  7. package/components/chart/bar-chart.js +11 -2
  8. package/components/chart/chart-constants.js +84 -3
  9. package/components/chart/chart.js +43 -10
  10. package/components/chart/column-chart.js +33 -24
  11. package/components/chart/common-chart-options.js +14 -35
  12. package/components/chart/example-area-chart.njk +68 -0
  13. package/components/chart/example-clustered-column-chart.njk +2 -1
  14. package/components/chart/example-column-chart-with-annotations.njk +2 -1
  15. package/components/chart/example-column-chart.njk +2 -1
  16. package/components/chart/example-column-with-line-chart.njk +5 -2
  17. package/components/chart/example-line-chart-with-markers.njk +138 -0
  18. package/components/chart/example-line-chart.njk +3 -1
  19. package/components/chart/example-scatter-chart.njk +94 -0
  20. package/components/chart/line-chart.js +18 -23
  21. package/components/chart/scatter-chart.js +34 -0
  22. package/components/details/details.js +5 -0
  23. package/components/details-panel/_details-panel.scss +107 -0
  24. package/components/details-panel/_macro.njk +41 -0
  25. package/components/details-panel/_macro.spec.js +54 -0
  26. package/components/details-panel/example-details-panel-open.njk +29 -0
  27. package/components/details-panel/example-details-panel.njk +28 -0
  28. package/components/hero/_hero.scss +87 -60
  29. package/components/hero/_macro.njk +1 -1
  30. package/components/hero/example-hero-dark.njk +1 -1
  31. package/components/pagination/_macro.njk +1 -1
  32. package/components/pagination/_pagination.scss +7 -7
  33. package/components/summary/_macro.njk +2 -2
  34. package/components/summary/_macro.spec.js +37 -21
  35. package/components/summary/_summary.scss +5 -1
  36. package/components/summary/example-summary-grouped.njk +0 -12
  37. package/css/main.css +1 -1
  38. package/package.json +1 -1
  39. package/scripts/main.es5.js +1 -1
  40. package/scripts/main.js +1 -1
  41. package/scss/main.scss +1 -0
  42. package/scss/vars/_colors.scss +1 -0
@@ -13,7 +13,7 @@
13
13
  aria-label="Pagination ({{ position }})"
14
14
  >
15
15
  <div class="ons-pagination__position">{{ position }}</div>
16
- <ul class="ons-pagination__items">
16
+ <ul class="ons-pagination__items{{ ' ons-pagination__items--no-previous' if currentPageIndex == 1 }}">
17
17
  {% if currentPageIndex != 1 %}
18
18
  {% set prevPageIndex = currentPageIndex - 2 %}
19
19
  <li class="ons-pagination__item ons-pagination__item--previous">
@@ -7,7 +7,14 @@ $pagination-item-width: 2.5rem;
7
7
  }
8
8
 
9
9
  &__items {
10
+ margin: 0 $pagination-item-padding * -1;
10
11
  padding: 0;
12
+
13
+ &--no-previous {
14
+ @include mq(m) {
15
+ margin: 0;
16
+ }
17
+ }
11
18
  }
12
19
 
13
20
  &__item {
@@ -16,7 +23,6 @@ $pagination-item-width: 2.5rem;
16
23
 
17
24
  &--previous,
18
25
  &--next {
19
- margin: 0 $pagination-item-padding * -1;
20
26
  display: inline-block;
21
27
  }
22
28
 
@@ -25,12 +31,6 @@ $pagination-item-width: 2.5rem;
25
31
  display: inline-block;
26
32
  }
27
33
  }
28
-
29
- @include mq('2xs', m) {
30
- &--previous ~ &--next {
31
- margin: 0;
32
- }
33
- }
34
34
  }
35
35
 
36
36
  &__item,
@@ -77,7 +77,7 @@
77
77
  </dt>
78
78
  {% if item.valueList %}
79
79
  <dd
80
- class="ons-summary__values{{ ' ons-summary__values--2' if not item.actions }}"
80
+ class="ons-summary__values{{ ' ons-summary__column-size--2' if not item.actions }}"
81
81
  {% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
82
82
  >
83
83
  {% if item.valueList | length == 1 %}
@@ -104,7 +104,7 @@
104
104
  </dd>
105
105
  {% endif %}
106
106
  {% if item.actions %}
107
- <dd class="ons-summary__actions" {% if item.id %}id="{{ item.id }}"{% endif %}>
107
+ <dd class="ons-summary__actions{{ ' ons-summary__column-size--2' if not item.valueList }}" {% if item.id %}id="{{ item.id }}"{% endif %}>
108
108
  {% for action in item.actions %}
109
109
  {% if loop.index > 1 %}<span class="ons-summary__spacer"></span>{% endif %}
110
110
  <a
@@ -196,20 +196,10 @@ const EXAMPLE_SUMMARY_HOUSEHOLD_GROUP = {
196
196
  itemsList: [
197
197
  {
198
198
  title: 'row item 4',
199
- valueList: [
200
- {
201
- text: 'list item 4',
202
- },
203
- ],
204
199
  actions: [
205
200
  {
206
201
  text: 'Change',
207
- visuallyHiddenText: 'change answer',
208
- url: '#0',
209
- },
210
- {
211
- text: 'Remove',
212
- visuallyHiddenText: 'remove list item',
202
+ visuallyHiddenText: 'change list item',
213
203
  url: '#0',
214
204
  },
215
205
  ],
@@ -221,13 +211,6 @@ const EXAMPLE_SUMMARY_HOUSEHOLD_GROUP = {
221
211
  text: 'list item 5',
222
212
  },
223
213
  ],
224
- actions: [
225
- {
226
- text: 'Change',
227
- visuallyHiddenText: 'change list item',
228
- url: '#0',
229
- },
230
- ],
231
214
  },
232
215
  {
233
216
  title: 'row item 6',
@@ -304,6 +287,21 @@ const EXAMPLE_SUMMARY_MULTIPLE_GROUPS = {
304
287
  ],
305
288
  };
306
289
 
290
+ const EXAMPLE_SUMMARY_SINGLE_GROUP = {
291
+ summaries: [
292
+ {
293
+ title: 'summary title',
294
+ groups: [
295
+ {
296
+ id: 'group-id-1',
297
+ title: 'group title',
298
+ ...EXAMPLE_SUMMARY_HOUSEHOLD_GROUP,
299
+ },
300
+ ],
301
+ },
302
+ ],
303
+ };
304
+
307
305
  // To address a DAC issue, we've disabled specific axe definition list rules causing test failures.
308
306
  // While resolving it would require a significant refactor, the failures are deemed non-critical for accessibility,
309
307
  // leading to their removal in this context. [https://github.com/ONSdigital/design-system/issues/3027]
@@ -411,9 +409,9 @@ describe('macro: summary', () => {
411
409
  it('displays the row `title` text', () => {
412
410
  const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
413
411
 
414
- expect($('.ons-summary__items .ons-summary__item:nth-of-type(1) .ons-summary__item--text').text().trim()).toBe(
415
- 'row title 1',
416
- );
412
+ expect(
413
+ $('.ons-summary__items .ons-summary__item:nth-of-type(1) .ons-summary__item--text:nth-of-type(1)').text().trim(),
414
+ ).toBe('row title 1');
417
415
  });
418
416
 
419
417
  it('has a custom icon `iconType`', () => {
@@ -473,6 +471,16 @@ describe('macro: summary', () => {
473
471
 
474
472
  expect($('.ons-summary__items .ons-summary__item:nth-of-type(3) .ons-summary__values ul').length).toBe(1);
475
473
  });
474
+
475
+ it('adds the `ons-summary__column-size--2` class if no `valueList` is provided', () => {
476
+ const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_SINGLE_GROUP));
477
+
478
+ expect(
479
+ $('.ons-summary__items .ons-summary__item:nth-of-type(2) .ons-summary__actions').hasClass(
480
+ 'ons-summary__column-size--2',
481
+ ),
482
+ ).toBe(true);
483
+ });
476
484
  });
477
485
 
478
486
  describe('part: item action', () => {
@@ -549,6 +557,14 @@ describe('macro: summary', () => {
549
557
  ),
550
558
  ).toBe('def');
551
559
  });
560
+
561
+ it('adds the `ons-summary__column-size--2` class if no action is provided', () => {
562
+ const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_SINGLE_GROUP));
563
+
564
+ expect(
565
+ $('.ons-summary__items .ons-summary__item:nth-of-type(2) .ons-summary__values').hasClass('ons-summary__column-size--2'),
566
+ ).toBe(true);
567
+ });
552
568
  });
553
569
  });
554
570
 
@@ -192,10 +192,14 @@ $hub-row-spacing: 1.3rem;
192
192
  text-align: right;
193
193
  }
194
194
 
195
- &__values--2 {
195
+ &__column-size--2 {
196
196
  flex: 10.5 1 66%;
197
197
  }
198
198
 
199
+ &__actions ~ &__values.ons-summary__column-size--2 {
200
+ padding-right: 33%;
201
+ }
202
+
199
203
  &--hub & {
200
204
  &__item-title,
201
205
  &__values,
@@ -284,11 +284,6 @@
284
284
  "itemsList": [
285
285
  {
286
286
  "title": "Food",
287
- "valueList": [
288
- {
289
- "text": "£50.00"
290
- }
291
- ],
292
287
  "actions": [
293
288
  {
294
289
  "text": "Change",
@@ -333,13 +328,6 @@
333
328
  {
334
329
  "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
335
330
  }
336
- ],
337
- "actions": [
338
- {
339
- "text": "Change",
340
- "visuallyHiddenText": "Change answer",
341
- "url": "#0"
342
- }
343
331
  ]
344
332
  }
345
333
  ]