@ons/design-system 52.0.0 → 53.0.2

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 (39) hide show
  1. package/components/button/_button.scss +75 -33
  2. package/components/button/_macro.njk +1 -1
  3. package/components/button/_macro.spec.js +2 -2
  4. package/components/external-link/_macro.njk +5 -2
  5. package/components/external-link/_macro.spec.js +18 -1
  6. package/components/footer/_footer.scss +19 -4
  7. package/components/footer/_macro.njk +108 -98
  8. package/components/footer/_macro.spec.js +131 -2
  9. package/components/header/_header.scss +65 -46
  10. package/components/header/_macro.njk +172 -120
  11. package/components/header/_macro.spec.js +85 -29
  12. package/components/hero/_hero.scss +30 -140
  13. package/components/hero/_macro.njk +13 -20
  14. package/components/hero/_macro.spec.js +32 -29
  15. package/components/icons/_macro.njk +257 -29
  16. package/components/icons/_macro.spec.js +6 -6
  17. package/components/input/_input.scss +8 -0
  18. package/components/language-selector/_macro.njk +1 -1
  19. package/components/language-selector/_macro.spec.js +9 -1
  20. package/components/navigation/_macro.njk +42 -35
  21. package/components/navigation/_macro.spec.js +34 -32
  22. package/components/navigation/_navigation.scss +20 -4
  23. package/components/related-content/_macro.njk +13 -21
  24. package/components/related-content/_macro.spec.js +18 -27
  25. package/components/related-content/_section-macro.njk +10 -0
  26. package/components/related-content/_section-macro.spec.js +43 -0
  27. package/components/share-page/_macro.njk +4 -2
  28. package/css/census.css +3 -1
  29. package/css/ids.css +2 -0
  30. package/css/main.css +1 -1
  31. package/img/dummy-brand-logo.svg +1 -0
  32. package/layout/_template.njk +9 -4
  33. package/package.json +1 -1
  34. package/scripts/main.es5.js +2 -2
  35. package/scss/ids.scss +2 -0
  36. package/scss/settings/_census.scss +141 -0
  37. package/scss/settings/_ids.scss +48 -0
  38. package/scss/utilities/_margin.scss +1 -0
  39. package/scss/vars/_colors.scss +5 -2
@@ -6,9 +6,9 @@ import axe from '../../tests/helpers/axe';
6
6
  import { mapAll } from '../../tests/helpers/cheerio';
7
7
  import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
8
8
 
9
- const EXAMPLE_RELATED_CONTENT_BODY = {
9
+ const EXAMPLE_RELATED_CONTENT_GENERAL = {
10
10
  title: 'Related information',
11
- body: 'Example body text...',
11
+ id: 'related-general-content',
12
12
  };
13
13
 
14
14
  const EXAMPLE_RELATED_CONTENT_LINKS = {
@@ -38,7 +38,7 @@ const EXAMPLE_RELATED_CONTENT_LINKS = {
38
38
 
39
39
  describe('macro: related-content', () => {
40
40
  describe.each([
41
- ['content', EXAMPLE_RELATED_CONTENT_BODY],
41
+ ['general content', EXAMPLE_RELATED_CONTENT_GENERAL],
42
42
  ['list of links', EXAMPLE_RELATED_CONTENT_LINKS],
43
43
  ])('mode: %s', (_, params) => {
44
44
  it('passes jest-axe checks', async () => {
@@ -78,37 +78,28 @@ describe('macro: related-content', () => {
78
78
  });
79
79
  });
80
80
 
81
- describe('mode: content', () => {
82
- it('has provided body text', () => {
83
- const $ = cheerio.load(renderComponent('related-content', EXAMPLE_RELATED_CONTENT_BODY));
81
+ describe('mode: general content', () => {
82
+ it('calls with content', () => {
83
+ const $ = cheerio.load(renderComponent('related-content', { EXAMPLE_RELATED_CONTENT_GENERAL }, 'Example content...'));
84
84
 
85
- expect(
86
- $('.ons-related-content__body .ons-related-content__body')
87
- .text()
88
- .trim(),
89
- ).toBe('Example body text...');
90
- });
91
-
92
- it('has inner content when the macro is called', () => {
93
- const $ = cheerio.load(renderComponent('related-content', EXAMPLE_RELATED_CONTENT_BODY, ['<strong>Content</strong>']));
94
-
95
- expect($('.ons-related-content__body .ons-related-content__body').html()).toContain('<strong>Content</strong>');
85
+ const content = $('.ons-related-content__body')
86
+ .text()
87
+ .trim();
88
+ expect(content).toEqual(expect.stringContaining('Example content...'));
96
89
  });
97
90
  });
98
91
 
99
92
  describe('mode: list of links', () => {
100
- it('has a title heading for each section of links', () => {
101
- const $ = cheerio.load(renderComponent('related-content', EXAMPLE_RELATED_CONTENT_LINKS));
102
-
103
- const values = mapAll($('.ons-related-content__title'), node => node.text().trim());
104
- expect(values).toEqual(['Related articles', 'Related links']);
105
- });
93
+ it('renders the expected output using the related-content/section macro', () => {
94
+ const faker = templateFaker();
95
+ const sectionSpy = faker.spy('related-content/section');
106
96
 
107
- it('has the `id` attribute for each section heading', () => {
108
- const $ = cheerio.load(renderComponent('related-content', EXAMPLE_RELATED_CONTENT_LINKS));
97
+ faker.renderComponent('related-content', EXAMPLE_RELATED_CONTENT_LINKS);
109
98
 
110
- const values = mapAll($('.ons-related-content__title'), node => node.attr('id'));
111
- expect(values).toEqual(['related-articles', 'related-links']);
99
+ expect(sectionSpy.occurrences[0]).toHaveProperty('title', 'Related articles');
100
+ expect(sectionSpy.occurrences[0]).toHaveProperty('id', 'related-articles');
101
+ expect(sectionSpy.occurrences[1]).toHaveProperty('title', 'Related links');
102
+ expect(sectionSpy.occurrences[1]).toHaveProperty('id', 'related-links');
112
103
  });
113
104
 
114
105
  it('has the `aria-labelledby` attribute for each section of links', () => {
@@ -0,0 +1,10 @@
1
+ {% macro onsRelatedContentSection(params) %}
2
+ <div class="ons-related-content__section">
3
+ {% if params.title %}
4
+ <h2 class="ons-related-content__title ons-u-fs-r--b ons-u-mb-xs" {% if params.id %}id="{{ params.id }}"{% endif %}>{{ params.title }}</h2>
5
+ {% endif %}
6
+ <div class="ons-related-content__content">
7
+ {{ caller() if caller }}
8
+ </div>
9
+ </div>
10
+ {% endmacro %}
@@ -0,0 +1,43 @@
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_RELATED_SECTION_CONTENT = {
9
+ title: 'Related information',
10
+ id: 'related-general-content',
11
+ };
12
+
13
+ describe('macro: related-content/section', () => {
14
+ it('passes jest-axe checks', async () => {
15
+ const $ = cheerio.load(renderComponent('related-content/section', EXAMPLE_RELATED_SECTION_CONTENT));
16
+
17
+ const results = await axe($.html());
18
+ expect(results).toHaveNoViolations();
19
+ });
20
+
21
+ it('has the provided `title` text', () => {
22
+ const $ = cheerio.load(renderComponent('related-content/section', EXAMPLE_RELATED_SECTION_CONTENT));
23
+ expect(
24
+ $('.ons-related-content__title')
25
+ .text()
26
+ .trim(),
27
+ ).toEqual('Related information');
28
+ });
29
+
30
+ it('has the `id` attribute for the title', () => {
31
+ const $ = cheerio.load(renderComponent('related-content/section', EXAMPLE_RELATED_SECTION_CONTENT));
32
+ expect($('#related-general-content').length).toBe(1);
33
+ });
34
+
35
+ it('has the provided content', () => {
36
+ const $ = cheerio.load(renderComponent('related-content/section', { EXAMPLE_RELATED_SECTION_CONTENT }, 'Example content...'));
37
+
38
+ const content = $('.ons-related-content__content')
39
+ .text()
40
+ .trim();
41
+ expect(content).toEqual(expect.stringContaining('Example content...'));
42
+ });
43
+ });
@@ -1,8 +1,10 @@
1
1
  {% macro onsSharePage(params) %}
2
2
  {% from "components/lists/_macro.njk" import onsList %}
3
3
 
4
- {% set titleTag = params.titleTag | default("h2") %}
5
- <{{ titleTag }} class="ons-u-fs-r--b ons-u-mb-xs">{{ params.title }}</{{ titleTag }}>
4
+ {% if params.title %}
5
+ {% set titleTag = params.titleTag | default("h2") %}
6
+ <{{ titleTag }} class="ons-u-fs-r--b ons-u-mb-xs">{{ params.title }}</{{ titleTag }}>
7
+ {% endif %}
6
8
 
7
9
  {% set list = [] %}
8
10
  {% if params.facebook is defined and params.facebook and params.facebook == true %}