@ons/design-system 72.1.0 → 72.1.1

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 (40) hide show
  1. package/README.md +1 -1
  2. package/components/accordion/_macro.spec.js +2 -2
  3. package/components/address-input/_macro.spec.js +245 -322
  4. package/components/address-input/autosuggest.address.spec.js +16 -14
  5. package/components/address-output/_macro.spec.js +121 -74
  6. package/components/address-output/_test_examples.js +8 -0
  7. package/components/autosuggest/_macro.spec.js +373 -184
  8. package/components/back-to-top/back-to-top.dom.js +4 -4
  9. package/components/back-to-top/back-to-top.js +1 -1
  10. package/components/browser-banner/_macro.spec.js +11 -11
  11. package/components/button/_macro.njk +1 -1
  12. package/components/button/_macro.spec.js +405 -351
  13. package/components/button/example-button-group.njk +1 -0
  14. package/components/checkboxes/_checkbox.scss +3 -3
  15. package/components/details/_details.scss +1 -2
  16. package/components/details/example-details-open.njk +10 -0
  17. package/components/external-link/_macro.spec.js +66 -69
  18. package/components/external-link/_test_examples.js +4 -0
  19. package/components/feedback/_macro.spec.js +109 -80
  20. package/components/feedback/_test_examples.js +17 -0
  21. package/components/field/_macro.spec.js +106 -69
  22. package/components/section-navigation/_macro.njk +9 -6
  23. package/components/table-of-contents/_macro.njk +3 -3
  24. package/components/table-of-contents/_macro.spec.js +3 -3
  25. package/components/table-of-contents/{_toc.scss → _table-of-contents.scss} +1 -1
  26. package/components/table-of-contents/table-of-contents.dom.js +13 -0
  27. package/components/table-of-contents/{toc.js → table-of-contents.js} +4 -4
  28. package/components/table-of-contents/{toc.spec.js → table-of-contents.spec.js} +2 -2
  29. package/components/tabs/_tabs.scss +10 -11
  30. package/components/tabs/tabs.js +3 -3
  31. package/components/timeout-modal/timeout-modal.spec.js +1 -1
  32. package/css/main.css +1 -1
  33. package/js/main.js +1 -1
  34. package/package.json +1 -1
  35. package/scripts/main.es5.js +1 -1
  36. package/scripts/main.js +1 -1
  37. package/scss/main.scss +1 -1
  38. package/scss/utilities/_margin.scss +4 -0
  39. package/scss/utilities/_padding.scss +4 -0
  40. package/components/table-of-contents/toc.dom.js +0 -13
@@ -31,9 +31,12 @@
31
31
  class="ons-section-nav__item{{ ' ' + item.classes if item.classes else '' }}{{ ' ons-section-nav__item--active' if isCurrent == true }}"
32
32
  >
33
33
  {% if isCurrent == true %}
34
- {{ openingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
35
- class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}"
36
- aria-current="location">{{ item.text }}{{ closingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
34
+ <a
35
+ class="ons-section-nav__link ons-section-nav__item-header"
36
+ href="{{ item.url }}"
37
+ aria-current="location"
38
+ >{{ item.text }}</a
39
+ >
37
40
  {% else %}
38
41
  <a class="ons-section-nav__link" href="{{ item.url }}">{{ item.text }}</a>
39
42
  {% endif %}
@@ -71,9 +74,9 @@
71
74
  class="ons-section-nav__item{{ ' ' + item.classes if item.classes else '' }}{% if isCurrent == true %}{{ ' ' }}ons-section-nav__item--active{% endif %}"
72
75
  >
73
76
  {% if isCurrent == true %}
74
- {{ openingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
75
- class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}"
76
- aria-current="location">{{ item.text }}{{ closingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
77
+ <a class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location"
78
+ >{{ item.text }}</a
79
+ >
77
80
  {% else %}
78
81
  <a class="ons-section-nav__link" href="{{ item.url }}">{{ item.text }}</a>
79
82
  {% endif %}
@@ -2,7 +2,7 @@
2
2
  {% from "components/list/_macro.njk" import onsList %}
3
3
  {% from "components/skip-to-content/_macro.njk" import onsSkipToContent %}
4
4
 
5
- <aside class="ons-toc-container" role="complementary">
5
+ <aside class="ons-table-of-contents-container" role="complementary">
6
6
  {% if params.skipLink %}
7
7
  {{
8
8
  onsSkipToContent({
@@ -12,8 +12,8 @@
12
12
  }}
13
13
  {% endif %}
14
14
 
15
- <nav class="ons-toc" aria-label="{{ params.ariaLabel | default('Table of contents') }}">
16
- <h2 class="ons-toc__title ons-u-fs-r--b ons-u-mb-s">{{ params.title }}</h2>
15
+ <nav class="ons-table-of-contents" aria-label="{{ params.ariaLabel | default('Table of contents') }}">
16
+ <h2 class="ons-table-of-contents__title ons-u-fs-r--b ons-u-mb-s">{{ params.title }}</h2>
17
17
  {% if params.lists %}
18
18
  {% for list in params.lists %}
19
19
  {% if list.listHeading %}
@@ -59,7 +59,7 @@ describe('macro: table-of-contents', () => {
59
59
  it('renders a default aria label', () => {
60
60
  const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_SINGLE));
61
61
 
62
- expect($('.ons-toc').attr('aria-label')).toBe('Table of contents');
62
+ expect($('.ons-table-of-contents').attr('aria-label')).toBe('Table of contents');
63
63
  });
64
64
 
65
65
  it('renders the provided `ariaLabel`', () => {
@@ -70,13 +70,13 @@ describe('macro: table-of-contents', () => {
70
70
  }),
71
71
  );
72
72
 
73
- expect($('.ons-toc').attr('aria-label')).toBe('Contents');
73
+ expect($('.ons-table-of-contents').attr('aria-label')).toBe('Contents');
74
74
  });
75
75
 
76
76
  it('renders title as heading element', () => {
77
77
  const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_SINGLE));
78
78
 
79
- expect($('.ons-toc__title').text().trim()).toBe('Contents');
79
+ expect($('.ons-table-of-contents__title').text().trim()).toBe('Contents');
80
80
  });
81
81
 
82
82
  describe('skip to content when `skipLink` is provided', () => {
@@ -1,4 +1,4 @@
1
- .ons-toc {
1
+ .ons-table-of-contents {
2
2
  &-container {
3
3
  border-bottom: 1px solid var(--ons-color-grey-15);
4
4
  margin-bottom: 2rem;
@@ -0,0 +1,13 @@
1
+ import domready from '../../js/domready';
2
+
3
+ async function tableOfContents() {
4
+ const tableOfContents = [...document.querySelectorAll('.ons-js-toc-container')];
5
+
6
+ if (tableOfContents.length) {
7
+ const TableOfContents = (await import('./table-of-contents')).default;
8
+
9
+ tableOfContents.forEach((component) => new TableOfContents(component));
10
+ }
11
+ }
12
+
13
+ domready(tableOfContents);
@@ -1,4 +1,4 @@
1
- export default class Toc {
1
+ export default class TableOfContents {
2
2
  constructor(component) {
3
3
  this.component = component;
4
4
  this.sections = [...this.component.querySelectorAll('section[id]')];
@@ -28,11 +28,11 @@ export default class Toc {
28
28
  this.activeSection = activeSection;
29
29
 
30
30
  for (let section of this.sections) {
31
- const tocItem = document.querySelector(`.ons-toc .ons-list__link[href="#${section.id}"]`);
31
+ const tocItem = document.querySelector(`.ons-table-of-contents .ons-list__link[href="#${section.id}"]`);
32
32
  if (section === activeSection) {
33
- tocItem.classList.add('ons-toc__link-active');
33
+ tocItem.classList.add('ons-table-of-contents__link-active');
34
34
  } else {
35
- tocItem.classList.remove('ons-toc__link-active');
35
+ tocItem.classList.remove('ons-table-of-contents__link-active');
36
36
  }
37
37
  }
38
38
  }
@@ -59,7 +59,7 @@ describe('script: table-of-contents', () => {
59
59
  await page.$eval(`#${sectionId}`, (node) => node.scrollIntoView());
60
60
  await setTimeout(250);
61
61
 
62
- const activeSection = await page.$eval('.ons-toc__link-active', (node) => node.innerText.trim());
62
+ const activeSection = await page.$eval('.ons-table-of-contents__link-active', (node) => node.innerText.trim());
63
63
  expect(activeSection).toBe(sectionTitle);
64
64
  });
65
65
  });
@@ -151,7 +151,7 @@ describe('script: table-of-contents-fixed-position', () => {
151
151
  );
152
152
  });
153
153
 
154
- it('when the "ons-grid__col--sticky" class is used, then the ToC stays in a fixed position while scrolling', async () => {
154
+ it('when the "ons-grid__col--sticky" class is used, then the table of contents stays in a fixed position while scrolling', async () => {
155
155
  await page.evaluate(() => {
156
156
  window.scrollTo(0, 1000);
157
157
  });
@@ -43,11 +43,10 @@
43
43
  border-radius: 3px 3px 0 0;
44
44
  color: var(--ons-color-text);
45
45
  display: inline-block;
46
- height: 2.55rem;
47
- line-height: 2.25rem;
46
+ height: 2.5rem;
48
47
  margin: 0 0.5rem 0 0;
49
48
  overflow: visible;
50
- padding: 0 1rem;
49
+ padding: 0.25rem 1rem 0.25rem;
51
50
  position: relative;
52
51
  text-decoration: underline;
53
52
 
@@ -62,10 +61,10 @@
62
61
  background-color: var(--ons-color-focus);
63
62
  border-bottom: 1px solid var(--ons-color-borders);
64
63
  box-shadow:
65
- inset 0 0 0 9px var(--ons-color-button-secondary),
66
- inset 17px 0 0 0 var(--ons-color-button-secondary),
67
- inset -17px 0 0 0 var(--ons-color-button-secondary),
68
- inset 0 -13px 0 0 var(--ons-color-text-link-focus);
64
+ inset 0 0 0 5px var(--ons-color-button-secondary),
65
+ inset 15px 0 0 0 var(--ons-color-button-secondary),
66
+ inset -14px 0 0 0 var(--ons-color-button-secondary),
67
+ inset 0 -9px 0 0 var(--ons-color-text-link-focus);
69
68
  color: var(--ons-color-text-link-focus);
70
69
 
71
70
  // Add transparent outline because Windows High Contrast Mode doesn't show box-shadows
@@ -88,10 +87,10 @@
88
87
  &:focus {
89
88
  background-color: var(--ons-color-focus);
90
89
  box-shadow:
91
- inset 0 0 0 9px var(--ons-color-page-light),
92
- inset 17px 0 0 0 var(--ons-color-page-light),
93
- inset -17px 0 0 0 var(--ons-color-page-light),
94
- inset 0 -13px 0 0 var(--ons-color-text-link-focus);
90
+ inset 0 0 0 5px var(--ons-color-page-light),
91
+ inset 15px 0 0 0 var(--ons-color-page-light),
92
+ inset -14px 0 0 0 var(--ons-color-page-light),
93
+ inset 0 -9px 0 0 var(--ons-color-text-link-focus);
95
94
  text-decoration: none;
96
95
  }
97
96
  }
@@ -40,8 +40,8 @@ export default class Tabs {
40
40
 
41
41
  // Set up checks for responsive functionality
42
42
  // The tabs will display as tabs up until this.breakpoint is reached
43
- // Tabs will display as a TOC list and show full content for <this.breakpoint viewports
44
- // Aria tags are added only in toc view
43
+ // Tabs will then display as a table of contents list and show full content for this.breakpoint viewports
44
+ // Aria tags are added only in table of contents view
45
45
  setupViewportChecks() {
46
46
  const breakpoint = () => {
47
47
  let finalBreakpoint = 0;
@@ -183,7 +183,7 @@ export default class Tabs {
183
183
  panel.classList.add(this.jsHiddenClass);
184
184
  }
185
185
 
186
- // Remove aria tags for TOC view
186
+ // Remove aria tags for table of contents view
187
187
  unsetAttributes(tab) {
188
188
  tab.removeAttribute('id');
189
189
  tab.removeAttribute('role');
@@ -216,7 +216,7 @@ describe('script: timeout modal', () => {
216
216
  it('closes the modal', async () => {
217
217
  const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
218
218
 
219
- await setTimeout(50);
219
+ await setTimeout(100);
220
220
 
221
221
  expect(modalIsVisible).toBe(false);
222
222
  });