@ons/design-system 72.1.0 → 72.1.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 (53) 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/_button.scss +1 -1
  12. package/components/button/_macro.njk +1 -1
  13. package/components/button/_macro.spec.js +405 -351
  14. package/components/button/example-button-group.njk +1 -0
  15. package/components/checkboxes/_checkbox.scss +3 -3
  16. package/components/description-list/_description-list.scss +40 -9
  17. package/components/description-list/_macro.njk +20 -12
  18. package/components/description-list/_macro.spec.js +11 -1
  19. package/components/description-list/example-inline-description-list.njk +58 -0
  20. package/components/details/_details.scss +1 -2
  21. package/components/details/example-details-open.njk +10 -0
  22. package/components/external-link/_macro.spec.js +66 -69
  23. package/components/external-link/_test_examples.js +4 -0
  24. package/components/feedback/_macro.spec.js +109 -80
  25. package/components/feedback/_test_examples.js +17 -0
  26. package/components/field/_macro.spec.js +106 -69
  27. package/components/header/_macro.njk +92 -90
  28. package/components/header/_macro.spec.js +10 -0
  29. package/components/header/example-header-basic.njk +11 -0
  30. package/components/hero/_hero.scss +239 -2
  31. package/components/hero/_macro.njk +7 -0
  32. package/components/hero/_macro.spec.js +5 -0
  33. package/components/hero/example-hero-navy-blue.njk +14 -0
  34. package/components/section-navigation/_macro.njk +9 -6
  35. package/components/table-of-contents/_macro.njk +3 -3
  36. package/components/table-of-contents/_macro.spec.js +3 -3
  37. package/components/table-of-contents/{_toc.scss → _table-of-contents.scss} +1 -1
  38. package/components/table-of-contents/table-of-contents.dom.js +13 -0
  39. package/components/table-of-contents/{toc.js → table-of-contents.js} +4 -4
  40. package/components/table-of-contents/{toc.spec.js → table-of-contents.spec.js} +2 -2
  41. package/components/tabs/_tabs.scss +10 -11
  42. package/components/tabs/tabs.js +3 -3
  43. package/components/timeout-modal/timeout-modal.spec.js +1 -1
  44. package/css/main.css +1 -1
  45. package/js/main.js +1 -1
  46. package/package.json +1 -1
  47. package/scripts/main.es5.js +1 -1
  48. package/scripts/main.js +1 -1
  49. package/scss/main.scss +1 -1
  50. package/scss/utilities/_margin.scss +4 -0
  51. package/scss/utilities/_padding.scss +4 -0
  52. package/scss/vars/_colors.scss +2 -0
  53. package/components/table-of-contents/toc.dom.js +0 -13
@@ -10,6 +10,24 @@
10
10
  background-color: var(--ons-color-hero-bg-dark);
11
11
  }
12
12
 
13
+ &--navy-blue {
14
+ background-color: var(--ons-color-navy-blue);
15
+ &::before {
16
+ content: '';
17
+ background-color: var(--ons-color-navy-blue-light);
18
+ border-radius: 0 0 50% 50%;
19
+ inset: 0;
20
+ left: -40%;
21
+ position: absolute;
22
+ width: 150%;
23
+ @include mq(l) {
24
+ border-radius: 0 0 300% 150%;
25
+ left: 0;
26
+ width: 100%;
27
+ }
28
+ }
29
+ }
30
+
13
31
  &__container {
14
32
  align-items: center;
15
33
  display: flex;
@@ -25,8 +43,8 @@
25
43
  height: 100%;
26
44
  }
27
45
 
28
- &__text {
29
- padding-bottom: 1rem;
46
+ &__text:has(+ .ons-btn) {
47
+ margin-bottom: 2rem;
30
48
  }
31
49
 
32
50
  &__pre-title {
@@ -62,4 +80,223 @@
62
80
  }
63
81
  }
64
82
  }
83
+ &--navy-blue & {
84
+ &__details {
85
+ color: var(--ons-color-text-inverse);
86
+ padding: 2rem 0 6rem;
87
+ @include mq(l) {
88
+ padding: 4rem 0;
89
+ }
90
+ }
91
+
92
+ &__circle-1 {
93
+ @include mq(l) {
94
+ background-color: var(--ons-color-spring-green);
95
+ border-radius: 50%;
96
+ height: 59px;
97
+ position: absolute;
98
+ right: 289px;
99
+ top: -11px;
100
+ width: 59px;
101
+ }
102
+ }
103
+
104
+ &__circle-2 {
105
+ @include mq(l) {
106
+ background-color: var(--ons-color-white);
107
+ border-radius: 50%;
108
+ position: absolute;
109
+ height: 30px;
110
+ right: 193px;
111
+ top: 11px;
112
+ width: 30px;
113
+ }
114
+ }
115
+
116
+ &__circle-3 {
117
+ @include mq(l) {
118
+ height: 60px;
119
+ right: 112px;
120
+ top: 25px;
121
+ width: 60px;
122
+ background-color: var(--ons-color-white);
123
+ border-radius: 50%;
124
+ position: absolute;
125
+ }
126
+ }
127
+
128
+ &__circle-4 {
129
+ @include mq(l) {
130
+ background-color: var(--ons-color-white);
131
+ border-radius: 50%;
132
+ height: 60px;
133
+ position: absolute;
134
+ right: 208px;
135
+ top: 80px;
136
+ width: 60px;
137
+ }
138
+
139
+ &::before {
140
+ @include mq(l) {
141
+ background-color: var(--ons-color-ocean-blue);
142
+ border-radius: 50%;
143
+ content: '';
144
+ height: 100%;
145
+ left: 0;
146
+ opacity: 0.4;
147
+ position: absolute;
148
+ top: 0;
149
+ width: 100%;
150
+ }
151
+ }
152
+ }
153
+
154
+ &__circle-5 {
155
+ @include mq(l) {
156
+ background-color: var(--ons-color-white);
157
+ border-radius: 50%;
158
+ height: 14px;
159
+ position: absolute;
160
+ right: 222px;
161
+ top: 187px;
162
+ width: 14px;
163
+ }
164
+
165
+ &::before {
166
+ @include mq(l) {
167
+ background-color: var(--ons-color-sky-blue);
168
+ border-radius: 50%;
169
+ content: '';
170
+ height: 100%;
171
+ left: 0;
172
+ opacity: 0.7;
173
+ position: absolute;
174
+ top: 0;
175
+ width: 100%;
176
+ }
177
+ }
178
+ }
179
+
180
+ &__circle-6 {
181
+ @include mq(l) {
182
+ background-color: var(--ons-color-spring-green);
183
+ border-radius: 50%;
184
+ height: 15px;
185
+ position: absolute;
186
+ right: 135px;
187
+ top: 188px;
188
+ width: 15px;
189
+ }
190
+ }
191
+
192
+ &__circle-7 {
193
+ @include mq(l) {
194
+ background-color: var(--ons-color-white);
195
+ border-radius: 50%;
196
+ height: 60px;
197
+ position: absolute;
198
+ right: 24px;
199
+ bottom: 92px;
200
+ width: 60px;
201
+ }
202
+
203
+ &::before {
204
+ @include mq(l) {
205
+ background-color: var(--ons-color-night-blue);
206
+ border-radius: 50%;
207
+ content: '';
208
+ height: 100%;
209
+ left: 0;
210
+ opacity: 0.7;
211
+ position: absolute;
212
+ top: 0;
213
+ width: 100%;
214
+ }
215
+ }
216
+ }
217
+
218
+ &__circle-8 {
219
+ @include mq(l) {
220
+ background-color: var(--ons-color-white);
221
+ border-radius: 50%;
222
+ bottom: 70px;
223
+ height: 15px;
224
+ position: absolute;
225
+ right: 275px;
226
+ width: 15px;
227
+ }
228
+ }
229
+
230
+ &__circle-9 {
231
+ background-color: var(--ons-color-spring-green);
232
+ border-radius: 50%;
233
+ bottom: 28px;
234
+ position: absolute;
235
+ right: 15px;
236
+ width: 40px;
237
+ height: 40px;
238
+ @include mq(l) {
239
+ bottom: 40px;
240
+ height: 30px;
241
+ position: absolute;
242
+ right: 215px;
243
+ width: 30px;
244
+ }
245
+ }
246
+
247
+ &__circle-10 {
248
+ @include mq(l) {
249
+ background-color: var(--ons-color-white);
250
+ border-radius: 50%;
251
+ bottom: 63px;
252
+ height: 15px;
253
+ position: absolute;
254
+ right: 120px;
255
+ width: 15px;
256
+ }
257
+
258
+ &::before {
259
+ @include mq(l) {
260
+ background-color: var(--ons-color-aqua-teal);
261
+ border-radius: 50%;
262
+ content: '';
263
+ height: 100%;
264
+ left: 0;
265
+ opacity: 0.4;
266
+ position: absolute;
267
+ top: 0;
268
+ width: 100%;
269
+ }
270
+ }
271
+ }
272
+
273
+ &__circle-11 {
274
+ background-color: var(--ons-color-sky-blue);
275
+ border-radius: 50%;
276
+ height: 14px;
277
+ width: 14px;
278
+ position: absolute;
279
+ bottom: -7px;
280
+ right: 50px;
281
+ @include mq(l) {
282
+ bottom: 33px;
283
+ height: 30px;
284
+ position: absolute;
285
+ right: 75px;
286
+ width: 30px;
287
+ }
288
+ }
289
+
290
+ &__circle-12 {
291
+ @include mq(l) {
292
+ background-color: var(--ons-color-night-blue);
293
+ border-radius: 50%;
294
+ bottom: -35px;
295
+ height: 59px;
296
+ position: absolute;
297
+ right: 125px;
298
+ width: 59px;
299
+ }
300
+ }
301
+ }
65
302
  }
@@ -6,6 +6,13 @@
6
6
  <section
7
7
  class="ons-hero ons-grid--gutterless{% if params.variants and params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-hero--{{ variant }}{% endfor %}{% else %}{{ ' ' }}ons-hero--{{ params.variants }}{% endif %}"
8
8
  >
9
+ {% if params.variants == 'navy-blue' %}
10
+ <div class="ons-hero__circles" aria-hidden="true">
11
+ {% for i in range(1, 13) %}
12
+ <div class="ons-hero__circle-{{ i }}"></div>
13
+ {% endfor %}
14
+ </div>
15
+ {% endif %}
9
16
  <div class="ons-hero__container ons-container{{ ' ons-container--wide' if params.wide }}">
10
17
  <div class="ons-hero__details ons-grid__col ons-col-{{ detailsColumns }}@m ons-col-10@s@m">
11
18
  <header>
@@ -87,4 +87,9 @@ describe('macro: hero', () => {
87
87
  const content = $('.ons-hero__additional-content').text().trim();
88
88
  expect(content).toEqual(expect.stringContaining('Example content...'));
89
89
  });
90
+
91
+ it('renders circles when variant is `navy blue`', () => {
92
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'navy-blue' }));
93
+ expect($('.ons-hero--navy-blue .ons-hero__circles').length).toBe(1);
94
+ });
90
95
  });
@@ -0,0 +1,14 @@
1
+ ---
2
+ 'fullWidth': true
3
+ ---
4
+
5
+ {% from "components/hero/_macro.njk" import onsHero %}
6
+ {{
7
+ onsHero({
8
+ "title": 'Welcome to the ONS Beta',
9
+ "text": 'Thank you for participating in our beta test. This limited preview of the ONS website focuses on our
10
+ new design and navigation for the retail insutry section. Please be aware that greyed-out links indicate sections still under development.
11
+ The active links will take you through the journey to test the new design features.',
12
+ "variants": 'navy-blue'
13
+ })
14
+ }}
@@ -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;
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
  });