@ons/design-system 67.0.0 → 67.0.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.
package/README.md CHANGED
@@ -130,11 +130,12 @@ Checkout the branch locally and run:
130
130
 
131
131
  `yarn test-visual:approve` - This will approve the failures/diff caught by the tests.
132
132
 
133
- `yarn test-visual:reference` - This will update the reference images locally on your machine.
134
133
 
135
134
  `git lfs push --all origin` - First commit the files in the normal way then run the command. This will push the new reference images to Git LFS.
136
135
 
137
- You can then commit and push your changes. The test images that would have been created when you ran `yest test-visual` are gitignored and the new references images will be pushed to Git LFS.
136
+ You can then commit and push the updated references and your changes to your branch. The test images that would have been created when you ran `yarn test-visual` are gitignored and the new references images will be pushed to Git LFS.
137
+
138
+ If your local tests are failing but you have approved them, run `yarn test-visual:reference`. This will update the reference images locally on your machine.
138
139
 
139
140
  ## Build
140
141
 
@@ -8,7 +8,7 @@
8
8
  {% if params.open %} data-open="true"{% endif %}
9
9
  >
10
10
  <div
11
- class="ons-details__heading ons-js-details-heading"
11
+ class="ons-details__heading ons-js-details-heading" role="button"
12
12
  {% if params.headingAttributes %}{% for attribute, value in (params.headingAttributes.items() if params.headingAttributes is mapping and params.headingAttributes.items else params.headingAttributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
13
13
  >
14
14
  {% set titleTag = params.titleTag | default("h2") %}
@@ -229,4 +229,8 @@
229
229
  margin-top: -5px !important;
230
230
  }
231
231
  }
232
+
233
+ .ons-btn {
234
+ top: 0 !important;
235
+ }
232
236
  }
@@ -12,7 +12,7 @@
12
12
  {% set currentLanguageISOCode = currentLanguage.ISOCode %}
13
13
  {% endif %}
14
14
 
15
- <header class="ons-header {% if params.classes %} {{ params.classes }}{% endif %}{% if params.variants is not string %}{% for variant in params.variants %} ons-header--{{ variant }}{% endfor %}{% else %} ons-header--{{ params.variants }}{% endif %}" role="banner">
15
+ <header class="ons-header{% if params.classes %} {{ params.classes }}{% endif %}{% if params.variants is not string %}{% for variant in params.variants %} ons-header--{{ variant }}{% endfor %}{% else %} ons-header--{{ params.variants }}{% endif %}" role="banner">
16
16
  {{
17
17
  onsBrowserBanner({
18
18
  "lang": currentLanguageISOCode,
@@ -141,22 +141,22 @@
141
141
  <ul class="ons-header-service-nav__list">
142
142
  {% for item in params.serviceLinks.itemsList %}
143
143
  <li class="ons-header-service-nav__item ons-header-service-nav__item--mobile">
144
- {% if item.iconType %}
145
- {{
146
- onsIcon({
147
- "iconType": item.iconType
148
- })
149
- }}
150
- {% endif %}
151
- {% if item.url %}
152
- <a
153
- href="{{ item.url }}"
154
- class="ons-header-service-nav__link"
155
- {% if item.id %} id="{{ item.id }}"{% endif %}
156
- >{% if item.title %}{{ item.title }}{% elif item.text %}{{ item.text }}{% endif %}</a>
157
- {% else %}
158
- {% if item.title %}{{ item.title }}{% elif item.text %}{{ item.text }}{% endif %}
159
- {% endif %}
144
+ {% if item.iconType %}
145
+ {{
146
+ onsIcon({
147
+ "iconType": item.iconType
148
+ })
149
+ }}
150
+ {% endif %}
151
+ {% if item.url %}
152
+ <a
153
+ href="{{ item.url }}"
154
+ class="ons-header-service-nav__link"
155
+ {% if item.id %} id="{{ item.id }}"{% endif %}
156
+ >{% if item.title %}{{ item.title }}{% elif item.text %}{{ item.text }}{% endif %}</a>
157
+ {% else %}
158
+ {% if item.title %}{{ item.title }}{% elif item.text %}{{ item.text }}{% endif %}
159
+ {% endif %}
160
160
  </li>
161
161
  {% endfor %}
162
162
  </ul>
@@ -14,12 +14,12 @@
14
14
  z-index: 1;
15
15
 
16
16
  &:focus {
17
- // Overide default input focus so it can wrap prefix/suffix too
17
+ // Override default input focus so it can wrap prefix/suffix too
18
18
  box-shadow: none;
19
19
  outline: none;
20
20
  }
21
21
 
22
- // Overide default input error style so it can wrap prefix/suffix too
22
+ // Override default input error style so it can wrap prefix/suffix too
23
23
  &.ons-input--error:not(:focus) {
24
24
  border-right: $input-border-width solid var(--ons-color-input-border);
25
25
  box-shadow: none;
@@ -76,7 +76,7 @@
76
76
  {% set prefixClass = " ons-input-type--prefix" %}
77
77
  {% endif %}
78
78
 
79
- <span class="ons-input-type{{ prefixClass }}">
79
+ <span class="ons-input-type{{ prefixClass }}{% if params.prefix or params.suffix %} ons-js-input-container-abbr{% endif %}">
80
80
  <span class="ons-input-type__inner">
81
81
  {{ input | safe }}
82
82
 
@@ -245,7 +245,7 @@ describe('macro: input', () => {
245
245
  expect($('.ons-input').attr('autocomplete')).toBe('on');
246
246
  });
247
247
 
248
- it.each([['email'], ['tel'], ['text']])('outputs `type` attribute of "%s"', type => {
248
+ it.each([['email'], ['tel'], ['text']])('outputs `type` attribute of "%s"', (type) => {
249
249
  const $ = cheerio.load(
250
250
  renderComponent('input', {
251
251
  ...EXAMPLE_INPUT_MINIMAL,
@@ -421,11 +421,7 @@ describe('macro: input', () => {
421
421
 
422
422
  expect($('.ons-input-type--prefix .ons-js-input-abbr').attr('id')).toBe('example-prefix-id');
423
423
  expect($('.ons-input-type--prefix .ons-js-input-abbr').attr('title')).toBe('Example prefix title');
424
- expect(
425
- $('.ons-input-type--prefix .ons-js-input-abbr')
426
- .text()
427
- .trim(),
428
- ).toBe('Example prefix text');
424
+ expect($('.ons-input-type--prefix .ons-js-input-abbr').text().trim()).toBe('Example prefix text');
429
425
  });
430
426
 
431
427
  it('does not render prefix element when `prefix.id` not set', () => {
@@ -483,11 +479,7 @@ describe('macro: input', () => {
483
479
 
484
480
  expect($('.ons-js-input-abbr').attr('id')).toBe('example-suffix-id');
485
481
  expect($('.ons-js-input-abbr').attr('title')).toBe('Example suffix title');
486
- expect(
487
- $('.ons-js-input-abbr')
488
- .text()
489
- .trim(),
490
- ).toBe('Example suffix text');
482
+ expect($('.ons-js-input-abbr').text().trim()).toBe('Example suffix text');
491
483
  });
492
484
 
493
485
  it('does not render suffix element when `suffix.id` not set', () => {
@@ -653,11 +645,7 @@ describe('macro: input', () => {
653
645
  );
654
646
 
655
647
  expect($('a.ons-input__post-link').attr('href')).toBe('https://example.com/link');
656
- expect(
657
- $('a.ons-input__post-link')
658
- .text()
659
- .trim(),
660
- ).toBe('Example link');
648
+ expect($('a.ons-input__post-link').text().trim()).toBe('Example link');
661
649
  });
662
650
  });
663
651
 
@@ -0,0 +1,11 @@
1
+ import domready from '../../js/domready';
2
+
3
+ domready(async () => {
4
+ const abbrInputs = [...document.querySelectorAll('.ons-js-input-container-abbr')];
5
+
6
+ if (abbrInputs.length) {
7
+ const abbrInput = (await import('./input')).default;
8
+
9
+ abbrInputs.forEach((element) => new abbrInput(element));
10
+ }
11
+ });
@@ -0,0 +1,14 @@
1
+ export default class AbbrInput {
2
+ constructor(context) {
3
+ this.abbrInput = context;
4
+ this.bindEventListeners();
5
+ }
6
+
7
+ bindEventListeners() {
8
+ this.abbrInput.querySelector('.ons-js-input-abbr').addEventListener('click', this.handleClick.bind(this));
9
+ }
10
+
11
+ handleClick() {
12
+ this.abbrInput.querySelector('.ons-input').focus();
13
+ }
14
+ }
@@ -0,0 +1,28 @@
1
+ import * as cheerio from 'cheerio';
2
+
3
+ import axe from '../../tests/helpers/axe';
4
+ import { renderComponent, templateFaker, setTestPage } from '../../tests/helpers/rendering';
5
+
6
+ const EXAMPLE_INPUT_MINIMAL = {
7
+ id: 'example-id',
8
+ name: 'example-name',
9
+ };
10
+
11
+ describe('script: input', () => {
12
+ it('focuses input when abbreviation is clicked', async () => {
13
+ await setTestPage(
14
+ '/test',
15
+ renderComponent('input', {
16
+ ...EXAMPLE_INPUT_MINIMAL,
17
+ prefix: {
18
+ id: 'example-prefix-id',
19
+ title: 'Example prefix title',
20
+ text: 'Example prefix text',
21
+ },
22
+ }),
23
+ );
24
+ await page.click('.ons-js-input-abbr');
25
+ const focusedElementId = await page.evaluate(() => document.activeElement.id);
26
+ expect(focusedElementId).toEqual('example-id');
27
+ });
28
+ });
@@ -1,11 +1,14 @@
1
1
  {% macro onsSectionNavigation(params) %}
2
+ {% set headingLevel = params.headingLevel | int | default(2) %}
3
+ {% set sectionTitleHeadingLevel = headingLevel + 1 %}
2
4
  <nav class="ons-section-nav{% if params.variants == 'vertical' %} ons-section-nav--vertical{% endif %} {% if params.classes %} {{ params.classes }} {% endif %}"{% if params.id %} id="{{ params.id }}"{% endif %} aria-labelledby="{{ params.hiddenTitleId | default("section-menu-nav-title")}}">
3
- <h2 class="ons-u-vh" id="{{ params.hiddenTitleId | default("section-menu-nav-title") }}">{{ params.hiddenTitle | default("Pages in this section") }}</h2>
5
+ <h{{ headingLevel }} class="ons-u-vh" id="{{ params.hiddenTitleId | default("section-menu-nav-title") }}">{{ params.hiddenTitle | default("Pages in this section") }}</h{{ headingLevel }}>
4
6
  {% if params.sections %}
5
7
  {% for section in params.sections %}
8
+ {% set sectionItemHeadingLevel = headingLevel + 2 if section.title else headingLevel + 1 %}
6
9
  <div class="ons-section-nav__sub">
7
10
  {% if section.title %}
8
- <h3 class="ons-u-fs-r--b ons-u-mb-s">{{ section.title }}</h3>
11
+ <h{{ sectionTitleHeadingLevel }} class="ons-u-fs-r--b ons-u-mb-s">{{ section.title }}</h{{ sectionTitleHeadingLevel }}>
9
12
  {% endif %}
10
13
  <ul class="ons-section-nav__list">
11
14
  {% for item in section.itemsList %}
@@ -14,9 +17,13 @@
14
17
  {% else %}
15
18
  {% set isCurrent = false %}
16
19
  {% endif %}
17
- <li class="ons-section-nav__item{% if item.classes %} ' ' + {{ item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
18
- <a class="ons-section-nav__link" href="{{ item.url }}"{% if isCurrent == true %} aria-current="location"{% endif %}>{{ item.title }}</a>
19
- {% if item.anchors and isCurrent == true %}
20
+ <li class="ons-section-nav__item{% if item.classes %}{{ ' ' + item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
21
+ {% if isCurrent == true %}
22
+ <h{{ sectionItemHeadingLevel }} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ sectionItemHeadingLevel }}>
23
+ {% else %}
24
+ <a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
25
+ {% endif %}
26
+ {% if item.anchors and isCurrent == true %}
20
27
  <ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
21
28
  {% for anchor in item.anchors %}
22
29
  <li class="ons-section-nav__item ons-list__item">
@@ -32,17 +39,22 @@
32
39
  {% endfor %}
33
40
  {% else %}
34
41
  {% if params.title %}
35
- <h3 class="ons-u-fs-r--b ons-u-mb-s">{{ params.title }}</h3>
42
+ <h{{ sectionTitleHeadingLevel }} class="ons-u-fs-r--b ons-u-mb-s">{{ params.title }}</h{{ sectionTitleHeadingLevel }}>
36
43
  {% endif %}
37
44
  <ul class="ons-section-nav__list">
38
45
  {% for item in params.itemsList %}
46
+ {% set sectionItemHeadingLevel = headingLevel + 2 if params.title else headingLevel + 1 %}
39
47
  {% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.title|lower) %}
40
48
  {% set isCurrent = true %}
41
49
  {% else %}
42
50
  {% set isCurrent = false %}
43
51
  {% endif %}
44
- <li class="ons-section-nav__item{% if item.classes %} ' ' + {{ item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
45
- <a class="ons-section-nav__link" href="{{ item.url }}"{% if isCurrent == true %} aria-current="location"{% endif %}>{{ item.title }}</a>
52
+ <li class="ons-section-nav__item{% if item.classes %}{{ ' ' + item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
53
+ {% if isCurrent == true %}
54
+ <h{{ sectionItemHeadingLevel}} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ headingLevel + 2 if section.title else headingLevel + 1 }}>
55
+ {% else %}
56
+ <a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
57
+ {% endif %}
46
58
  {% if item.anchors %}
47
59
  <ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
48
60
  {% for anchor in item.anchors %}
@@ -30,7 +30,12 @@
30
30
  font-weight: $font-weight-bold;
31
31
  margin-left: -18px;
32
32
  padding-left: 14px;
33
- a {
33
+ a,
34
+ h2,
35
+ h3,
36
+ h4,
37
+ h5,
38
+ h6 {
34
39
  color: var(--ons-color-text-link-active);
35
40
  }
36
41
  }
@@ -39,6 +44,14 @@
39
44
  }
40
45
  }
41
46
 
47
+ &__item-header {
48
+ @extend .ons-u-mb-no;
49
+
50
+ font-size: 1rem;
51
+ font-weight: 700;
52
+ line-height: 1.6;
53
+ }
54
+
42
55
  &__sub-items {
43
56
  a {
44
57
  color: var(--ons-color-text-link);
@@ -58,7 +71,12 @@
58
71
  border-color: var(--ons-color-text-link-active);
59
72
  margin: 0 1rem 0 0;
60
73
  padding: 0;
61
- a {
74
+ a,
75
+ h2,
76
+ h3,
77
+ h4,
78
+ h5,
79
+ h6 {
62
80
  color: var(--ons-color-text-link-active);
63
81
  }
64
82
  }