@ons/design-system 72.4.0 → 72.6.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 (62) hide show
  1. package/components/button/_button.scss +171 -3
  2. package/components/button/_macro.njk +4 -0
  3. package/components/card/_card.scss +5 -0
  4. package/components/card/_macro.njk +10 -2
  5. package/components/card/_macro.spec.js +58 -0
  6. package/components/card/example-card-set-with-headline-figures.njk +62 -0
  7. package/components/chart/_chart.scss +80 -0
  8. package/components/chart/_macro.njk +125 -0
  9. package/components/chart/_macro.spec.js +825 -0
  10. package/components/chart/annotations-options.js +78 -0
  11. package/components/chart/bar-chart.js +164 -0
  12. package/components/chart/chart-constants.js +21 -0
  13. package/components/chart/chart.dom.js +8 -0
  14. package/components/chart/chart.js +242 -0
  15. package/components/chart/column-chart.js +48 -0
  16. package/components/chart/common-chart-options.js +247 -0
  17. package/components/chart/example-bar-chart-with-annotations.njk +62 -0
  18. package/components/chart/example-bar-chart.njk +55 -0
  19. package/components/chart/example-bar-with-line-chart.njk +64 -0
  20. package/components/chart/example-clustered-bar-chart.njk +60 -0
  21. package/components/chart/example-clustered-column-chart.njk +74 -0
  22. package/components/chart/example-column-chart-with-annotations.njk +62 -0
  23. package/components/chart/example-column-chart.njk +54 -0
  24. package/components/chart/example-column-with-line-chart.njk +62 -0
  25. package/components/chart/example-line-chart-with-annotations.njk +235 -0
  26. package/components/chart/example-line-chart.njk +221 -0
  27. package/components/chart/example-stacked-bar-chart.njk +60 -0
  28. package/components/chart/example-stacked-column-chart.njk +67 -0
  29. package/components/chart/line-chart.js +42 -0
  30. package/components/chart/specific-chart-options.js +22 -0
  31. package/components/footer/_footer.scss +12 -0
  32. package/components/footer/_macro.njk +38 -17
  33. package/components/header/_header.scss +18 -2
  34. package/components/header/_macro.njk +81 -8
  35. package/components/header/_macro.spec.js +97 -0
  36. package/components/header/example-header-with-search-button.njk +190 -0
  37. package/components/header/header.spec.js +128 -0
  38. package/components/hero/_hero.scss +39 -7
  39. package/components/hero/_macro.njk +47 -17
  40. package/components/hero/_macro.spec.js +94 -0
  41. package/components/hero/example-hero-grey.njk +9 -0
  42. package/components/icon/_macro.njk +8 -8
  43. package/components/input/_input.scss +15 -0
  44. package/components/input/_macro.njk +3 -3
  45. package/components/navigation/navigation.dom.js +17 -0
  46. package/components/navigation/navigation.js +72 -2
  47. package/components/pagination/_pagination.scss +7 -1
  48. package/components/summary/_macro.njk +1 -1
  49. package/components/summary/_macro.spec.js +6 -0
  50. package/components/table-of-contents/_macro.njk +40 -0
  51. package/components/table-of-contents/_macro.spec.js +72 -0
  52. package/components/table-of-contents/_table-of-contents.scss +11 -0
  53. package/components/table-of-contents/example-table-of-contents-related-links-with-button.njk +60 -0
  54. package/css/main.css +1 -1
  55. package/js/cookies-functions.js +11 -6
  56. package/js/cookies-functions.spec.js +44 -0
  57. package/js/main.js +2 -0
  58. package/package.json +4 -1
  59. package/scripts/main.es5.js +1 -1
  60. package/scripts/main.js +1 -1
  61. package/scss/main.scss +1 -0
  62. package/scss/utilities/_grid.scss +13 -4
@@ -104,7 +104,7 @@
104
104
  </dd>
105
105
  {% endif %}
106
106
  {% if item.actions %}
107
- <dd class="ons-summary__actions">
107
+ <dd class="ons-summary__actions" {% 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
@@ -514,6 +514,12 @@ describe('macro: summary', () => {
514
514
  ).toBe('Action 2');
515
515
  });
516
516
 
517
+ it('has the correct `id` added to the actions', () => {
518
+ const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
519
+
520
+ expect($('.ons-summary__items .ons-summary__item:nth-of-type(2) .ons-summary__actions').attr('id')).toBe('item-id-2');
521
+ });
522
+
517
523
  it('has the correct visually hidden <span> text', () => {
518
524
  const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
519
525
 
@@ -1,6 +1,7 @@
1
1
  {% macro onsTableOfContents(params) %}
2
2
  {% from "components/list/_macro.njk" import onsList %}
3
3
  {% from "components/skip-to-content/_macro.njk" import onsSkipToContent %}
4
+ {% from "components/button/_macro.njk" import onsButton %}
4
5
 
5
6
  <aside class="ons-table-of-contents-container" role="complementary">
6
7
  {% if params.skipLink %}
@@ -41,5 +42,44 @@
41
42
  }}
42
43
  {% endif %}
43
44
  </nav>
45
+
46
+ {% if params.relatedLinks %}
47
+ <nav
48
+ class="ons-table-of-contents__related-links ons-u-pb-s ons-u-pt-l ons-u-mt-s"
49
+ aria-label="{{ params.relatedLinks.ariaLabel | default('Related links') }}"
50
+ >
51
+ <h2 class="ons-table-of-contents__title ons-u-fs-r--b ons-u-mb-s">{{ params.relatedLinks.title }}</h2>
52
+
53
+ {{
54
+ onsList({
55
+ "variants": 'bare',
56
+ "itemsList": params.relatedLinks.itemsList
57
+ })
58
+ }}
59
+ </nav>
60
+ {% endif %}
61
+
62
+ {% if params.button %}
63
+ <div class="ons-table-of-contents__button ons-u-pt-l">
64
+ {% set allVariants = ['small', 'secondary'] %}
65
+
66
+ {% if params.button.variants %}
67
+ {% if params.button.variants is string %}
68
+ {% set allVariants = (allVariants.push(params.button.variants), allVariants) %}
69
+ {% else %}
70
+ {% for variant in params.button.variants %}
71
+ {% set allVariants = (allVariants.push(variant), allVariants) %}
72
+ {% endfor %}
73
+ {% endif %}
74
+ {% endif %}
75
+
76
+ {{
77
+ onsButton({
78
+ "text": params.button.text | default('Save or print this page'),
79
+ "variants": allVariants
80
+ })
81
+ }}
82
+ </div>
83
+ {% endif %}
44
84
  </aside>
45
85
  {% endmacro %}
@@ -55,6 +55,33 @@ const EXAMPLE_TABLE_OF_CONTENTS_MULTIPLE = {
55
55
  ],
56
56
  };
57
57
 
58
+ const EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON = {
59
+ title: 'Contents',
60
+ itemsList: [
61
+ {
62
+ url: '#overview',
63
+ text: 'Overview',
64
+ },
65
+ {
66
+ url: '#who-should-take-part-and-why',
67
+ text: 'Who should take part and why',
68
+ },
69
+ ],
70
+ relatedLinks: {
71
+ title: 'Related publications',
72
+ itemsList: [
73
+ {
74
+ url: '#0',
75
+ text: 'Example publication title',
76
+ },
77
+ ],
78
+ },
79
+ button: {
80
+ text: 'Save or print this page',
81
+ variants: ['print'],
82
+ },
83
+ };
84
+
58
85
  describe('macro: table-of-contents', () => {
59
86
  it('renders a default aria label', () => {
60
87
  const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_SINGLE));
@@ -167,4 +194,49 @@ describe('macro: table-of-contents', () => {
167
194
  });
168
195
  });
169
196
  });
197
+
198
+ describe('related links and button', () => {
199
+ it('passes jest-axe checks with related links and button', async () => {
200
+ const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON));
201
+
202
+ const results = await axe($.html());
203
+ expect(results).toHaveNoViolations();
204
+ });
205
+
206
+ it('renders related links section with correct title', () => {
207
+ const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON));
208
+
209
+ expect($('.ons-table-of-contents__related-links h2').text().trim()).toBe('Related publications');
210
+ });
211
+
212
+ it('outputs `lists` component for related links with expected parameters', () => {
213
+ const faker = templateFaker();
214
+ const listsSpy = faker.spy('list');
215
+
216
+ faker.renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON);
217
+
218
+ expect(listsSpy.occurrences[1]).toEqual({
219
+ variants: 'bare',
220
+ itemsList: EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON.relatedLinks.itemsList,
221
+ });
222
+ });
223
+
224
+ it('renders button with correct text', () => {
225
+ const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON));
226
+
227
+ expect($('.ons-table-of-contents__button .ons-btn').text().trim()).toBe('Save or print this page');
228
+ });
229
+
230
+ it('outputs `button` component with expected parameters', () => {
231
+ const faker = templateFaker();
232
+ const buttonSpy = faker.spy('button');
233
+
234
+ faker.renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_RELATED_LINKS_BUTTON);
235
+
236
+ expect(buttonSpy.occurrences[0]).toEqual({
237
+ text: 'Save or print this page',
238
+ variants: ['small', 'secondary', 'print'],
239
+ });
240
+ });
241
+ });
170
242
  });
@@ -1,12 +1,23 @@
1
1
  .ons-table-of-contents {
2
+ $root: &;
3
+
2
4
  &-container {
3
5
  border-bottom: 1px solid var(--ons-color-grey-15);
4
6
  margin-bottom: 2rem;
5
7
  padding-bottom: 1rem;
8
+
9
+ &:has(:where(#{$root}__related-links, #{$root}__button)) {
10
+ border-bottom: 0;
11
+ }
6
12
  }
7
13
 
8
14
  &__link-active {
9
15
  color: var(--ons-color-text-link-hover);
10
16
  text-decoration: underline solid var(--ons-color-text-link-hover) 2px;
11
17
  }
18
+
19
+ &__related-links,
20
+ &__button {
21
+ border-top: 4px solid var(--ons-color-ocean-blue);
22
+ }
12
23
  }
@@ -0,0 +1,60 @@
1
+ {% from "components/table-of-contents/_macro.njk" import onsTableOfContents %}
2
+
3
+ {{-
4
+ onsTableOfContents({
5
+ "title": 'Contents',
6
+ "ariaLabel": 'Pages in this guide',
7
+ "skipLink": {
8
+ "url": "#0",
9
+ "text": 'Skip to guide content'
10
+ },
11
+ "lists": [
12
+ {
13
+ "itemsList": [
14
+ {
15
+ "url": '#0',
16
+ "text": 'Overview',
17
+ "current": true
18
+ },
19
+ {
20
+ "url": '#0',
21
+ "text": 'Who should take part and why'
22
+ },
23
+ {
24
+ "url": '#0',
25
+ "text": 'How your information is used'
26
+ },
27
+ {
28
+ "url": '#0',
29
+ "text": 'The 2019 Census Rehearsal'
30
+ },
31
+ {
32
+ "url": '#0',
33
+ "text": 'Online census'
34
+ }
35
+ ]
36
+ }
37
+ ],
38
+ "relatedLinks": {
39
+ "title": 'Related publications',
40
+ "itemsList": [
41
+ {
42
+ "url": '#0',
43
+ "text": 'Example publication title'
44
+ },
45
+ {
46
+ "url": '#0',
47
+ "text": 'Example publication title 2'
48
+ },
49
+ {
50
+ "url": '#0',
51
+ "text": 'Example publication title 3'
52
+ }
53
+ ]
54
+ },
55
+ "button": {
56
+ "text": 'Save or print this page',
57
+ "variants": 'print'
58
+ }
59
+ })
60
+ -}}