@ons/design-system 67.0.3 → 67.0.4

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.
@@ -23,6 +23,7 @@ $details-caret-width: 1.5rem;
23
23
  margin-left: -$details-caret-width;
24
24
  padding-left: $details-caret-width;
25
25
  }
26
+
26
27
  .ons-details__icon .ons-icon {
27
28
  fill: var(--ons-color-text-link-focus);
28
29
  }
@@ -30,9 +31,11 @@ $details-caret-width: 1.5rem;
30
31
 
31
32
  &:hover:not(:focus) {
32
33
  color: var(--ons-color-text-link-hover);
34
+
33
35
  .ons-details__icon {
34
36
  fill: var(--ons-color-text-link-hover);
35
37
  }
38
+
36
39
  .ons-details__title {
37
40
  text-decoration: underline solid var(--ons-color-text-link-hover) 2px;
38
41
  }
@@ -60,6 +63,7 @@ $details-caret-width: 1.5rem;
60
63
  margin-bottom: 0;
61
64
  text-underline-position: under;
62
65
  transform: translateY(-1px);
66
+ pointer-events: none;
63
67
  }
64
68
  }
65
69
 
@@ -126,5 +130,6 @@ $details-caret-width: 1.5rem;
126
130
 
127
131
  &__icon {
128
132
  display: none;
133
+ pointer-events: none;
129
134
  }
130
135
  }
@@ -11,15 +11,15 @@
11
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
- {% set titleTag = params.titleTag | default("h2") %}
15
- <{{ titleTag }} class="ons-details__title">{{ params.title }}</{{ titleTag }}>
16
- <span class="ons-details__icon">
17
- {% from "components/icon/_macro.njk" import onsIcon %}
18
- {{-
19
- onsIcon({
20
- "iconType": "chevron"
21
- })
22
- -}}</span>
14
+ {% set titleTag = params.titleTag | default("h2") %}
15
+ <{{ titleTag }} class="ons-details__title">{{ params.title }}</{{ titleTag }}>
16
+ <span class="ons-details__icon">
17
+ {% from "components/icon/_macro.njk" import onsIcon %}
18
+ {{-
19
+ onsIcon({
20
+ "iconType": "chevron"
21
+ })
22
+ -}}</span>
23
23
  </div>
24
24
  <div id="{{ params.id }}-content" class="ons-details__content ons-js-details-content"
25
25
  {% if params.contentAttributes %}{% for attribute, value in (params.contentAttributes.items() if params.contentAttributes is mapping and params.contentAttributes.items else params.contentAttributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
@@ -0,0 +1,70 @@
1
+ ---
2
+ "fullWidth": true
3
+ ---
4
+ {% from "components/header/_macro.njk" import onsHeader %}
5
+
6
+ {{
7
+ onsHeader({
8
+ "title": 'Service manual',
9
+ "mastheadLogoUrl": '#0',
10
+ "titleUrl": '#0',
11
+ "navigation": {
12
+ "id": 'main-nav',
13
+ "ariaLabel": 'Main menu',
14
+ "currentPath": [ '#design-system', '#patterns', '#access-codes' ],
15
+ "currentPageTitle": 'Design system',
16
+ "itemsList": [
17
+ {
18
+ "text": 'Service standard',
19
+ "url": '#0'
20
+ },
21
+ {
22
+ "text": 'Design system',
23
+ "url": '#design-system'
24
+ },
25
+ {
26
+ "text": 'Accessibility',
27
+ "url": '#0'
28
+ },
29
+ {
30
+ "text": 'Brand guidelines',
31
+ "url": '#0'
32
+ },
33
+ {
34
+ "text": 'Content style guide',
35
+ "url": '#0'
36
+ }
37
+ ],
38
+ "toggleNavigationButton": {
39
+ "text": 'Menu',
40
+ "ariaLabel": 'Toggle menu'
41
+ },
42
+ "subNavigation": {
43
+ "id": 'sub-nav',
44
+ "overviewURL": '#design-system',
45
+ "overviewText": 'Overview',
46
+ "ariaLabel": 'Section menu',
47
+ "currentPath": '#access-codes',
48
+ "removeHorizontalSubNav": true,
49
+ "itemsList": [
50
+ {
51
+ "text": 'Guidance',
52
+ "url": '#0'
53
+ },
54
+ {
55
+ "text": 'Foundations',
56
+ "url": '#0'
57
+ },
58
+ {
59
+ "text": 'Components',
60
+ "url": '#0'
61
+ },
62
+ {
63
+ "text": 'Patterns',
64
+ "url": '#patterns'
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ })
70
+ }}
@@ -62,6 +62,12 @@
62
62
  &--with-description {
63
63
  margin-bottom: 0.55rem;
64
64
  }
65
+
66
+ &--with-text-description {
67
+ position: relative;
68
+
69
+ }
70
+
65
71
  }
66
72
 
67
73
  // Text input widths
@@ -57,7 +57,7 @@
57
57
  {% endif %}
58
58
  {% endset %}
59
59
  {% set field %}
60
- {% if params.label and params.label.text %}
60
+ {% if (not params.accessiblePlaceholder or params.label.description) and (params.label and params.label.text)%}
61
61
  {{ onsLabel({
62
62
  "for": params.id,
63
63
  "id": params.label.id,
@@ -68,6 +68,7 @@
68
68
  "accessiblePlaceholder": params.accessiblePlaceholder,
69
69
  "inline": params.label.inline
70
70
  }) }}
71
+
71
72
  {% endif %}
72
73
 
73
74
  {% if params.prefix or params.suffix %}
@@ -100,7 +101,19 @@
100
101
  </span>
101
102
  {% endif %}
102
103
  {% elif params.searchButton %}
103
- <span class="ons-grid--flex ons-input_search-button">
104
+ <span class="ons-grid--flex ons-input_search-button{% if params.label.description %} ons-input--with-text-description{% endif %}">
105
+ {% if params.accessiblePlaceholder %}
106
+ {{ onsLabel({
107
+ "for": params.id,
108
+ "id": params.label.id,
109
+ "text": params.label.text,
110
+ "classes": params.label.classes,
111
+ "attributes": params.label.attributes,
112
+ "accessiblePlaceholder": params.accessiblePlaceholder,
113
+ "inline": params.label.inline
114
+ }) }}
115
+ {% endif %}
116
+
104
117
  {{ input | safe }}
105
118
  {%- set buttonLabel -%}
106
119
  {%- if params.searchButton.visuallyHideButtonText == true -%}
@@ -124,7 +137,24 @@
124
137
  }}
125
138
  </span>
126
139
  {% else %}
140
+ {% if params.accessiblePlaceholder %}
141
+ <span class="ons-grid--flex {% if params.label.description %} ons-input--with-text-description{% endif %}">
142
+ {% if params.accessiblePlaceholder %}
143
+ {{ onsLabel({
144
+ "for": params.id,
145
+ "id": params.label.id,
146
+ "text": params.label.text,
147
+ "classes": params.label.classes,
148
+ "attributes": params.label.attributes,
149
+ "accessiblePlaceholder": params.accessiblePlaceholder,
150
+ "inline": params.label.inline
151
+ }) }}
152
+ {% endif %}
153
+ {% endif %}
127
154
  {{ input | safe }}
155
+ {% if params.accessiblePlaceholder %}
156
+ </span>
157
+ {% endif %}
128
158
  {% endif %}
129
159
  {% endset %}
130
160
 
@@ -1,7 +1,7 @@
1
1
  {% from "components/input/_macro.njk" import onsInput %}
2
2
  {{
3
3
  onsInput({
4
- "id": "text-width",
4
+ "id": "postcode",
5
5
  "width": "7",
6
6
  "autocomplete": "postal-code",
7
7
  "label": {
@@ -16,7 +16,9 @@
16
16
  {{- params.description -}}
17
17
  </span>
18
18
  {%- endset %}
19
-
19
+ {%- if params.description and params.accessiblePlaceholder -%}
20
+ {{- description | safe -}}
21
+ {%- else -%}
20
22
  <label
21
23
  class="{% if params.inputType is not defined -%}ons-label{%- endif %}{{- ' ' + params.classes if params.classes else "" -}}{%- if params.description %} ons-label--with-description{%- endif %} {{- ' ons-label--placeholder' if params.accessiblePlaceholder else "" -}}"
22
24
  {% if params.description %}aria-describedby="{{ descriptionID }}"{% endif %}
@@ -41,4 +43,5 @@
41
43
  {{- description | safe -}}
42
44
  {%- endif -%}
43
45
  {%- endif %}
46
+ {%- endif -%}
44
47
  {% endmacro %}
@@ -58,21 +58,23 @@
58
58
  </div>
59
59
  </div>
60
60
  {% if params.navigation.subNavigation %}
61
- <nav class="ons-navigation ons-navigation--sub ons-u-d-no@xxs@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes }}" id="{{ params.navigation.subNavigation.id }}" aria-label="{{ params.navigation.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
62
- <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth or params.navigation.fullWidth }}{{ ' ons-container--wide' if params.wide or params.navigation.wide }}">
63
- <ul class="ons-navigation__list ons-navigation__list">
64
- {% for item in params.navigation.subNavigation.itemsList %}
65
- <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
66
- <a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}" {% endif %}>
67
- {% if item.title %}{{ item.title }}
68
- {% elif item.text %}{{ item.text }}
69
- {% endif %}
70
- </a>
71
- </li>
72
- {% endfor %}
73
- </ul>
74
- </div>
75
- </nav>
61
+ {% if not params.navigation.subNavigation.removeHorizontalSubNav %}
62
+ <nav class="ons-navigation ons-navigation--sub ons-u-d-no@xxs@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes }}" id="{{ params.navigation.subNavigation.id }}" aria-label="{{ params.navigation.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
63
+ <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth or params.navigation.fullWidth }}{{ ' ons-container--wide' if params.wide or params.navigation.wide }}">
64
+ <ul class="ons-navigation__list ons-navigation__list">
65
+ {% for item in params.navigation.subNavigation.itemsList %}
66
+ <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
67
+ <a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}" {% endif %}>
68
+ {% if item.title %}{{ item.title }}
69
+ {% elif item.text %}{{ item.text }}
70
+ {% endif %}
71
+ </a>
72
+ </li>
73
+ {% endfor %}
74
+ </ul>
75
+ </div>
76
+ </nav>
77
+ {% endif %}
76
78
  <div class="ons-u-d-no@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes }}">
77
79
  {{ onsButton({
78
80
  "text": params.navigation.currentPageTitle,
@@ -86,6 +86,66 @@ const EXAMPLE_NAVIGATION_WITH_SUBNAVIGATION = {
86
86
  },
87
87
  };
88
88
 
89
+ const EXAMPLE_NAVIGATION_WITH_SUBNAVIGATION_REMOVED = {
90
+ navigation: {
91
+ id: 'main-nav',
92
+ ariaLabel: 'Main menu',
93
+ currentPath: '#1',
94
+ currentPageTitle: 'Main nav item 2',
95
+ itemsList: [
96
+ {
97
+ title: 'Main nav item 1',
98
+ url: '#0',
99
+ classes: 'custom-class-main-item-1',
100
+ id: 'main-item-1',
101
+ },
102
+ {
103
+ title: 'Main nav item 2',
104
+ url: '#1',
105
+ classes: 'custom-class-main-item-2',
106
+ id: 'main-item-2',
107
+ },
108
+ ],
109
+ subNavigation: {
110
+ id: 'sub-nav-hidden',
111
+ overviewURL: '#overview',
112
+ overviewText: 'Overview',
113
+ ariaLabel: 'Section menu',
114
+ currentPath: '#1',
115
+ removeHorizontalSubNav: true,
116
+ itemsList: [
117
+ {
118
+ title: 'Sub nav item 1',
119
+ url: '#0',
120
+ classes: 'custom-class-sub-item-1',
121
+ id: 'sub-item-1',
122
+ },
123
+ {
124
+ title: 'Sub nav item 2',
125
+ url: '#1',
126
+ classes: 'custom-class-sub-item-2',
127
+ id: 'sub-item-2',
128
+ sections: [
129
+ {
130
+ sectionTitle: 'Section 1',
131
+ children: [
132
+ {
133
+ title: 'Child item 1',
134
+ url: '#0',
135
+ },
136
+ {
137
+ title: 'Child item 2',
138
+ url: '#1',
139
+ },
140
+ ],
141
+ },
142
+ ],
143
+ },
144
+ ],
145
+ },
146
+ },
147
+ };
148
+
89
149
  describe('script: navigation', () => {
90
150
  afterEach(async () => {
91
151
  // Clear viewport size and browser emulation after each test.
@@ -102,7 +162,7 @@ describe('script: navigation', () => {
102
162
  });
103
163
 
104
164
  it('has removed the display class from the menu toggle button', async () => {
105
- const hasClass = await page.$eval(buttonEl, node => node.classList.contains('ons-u-d-no'));
165
+ const hasClass = await page.$eval(buttonEl, (node) => node.classList.contains('ons-u-d-no'));
106
166
  expect(hasClass).toBe(false);
107
167
  });
108
168
  });
@@ -115,13 +175,13 @@ describe('script: navigation', () => {
115
175
 
116
176
  it('has the correct aria hidden attribute on the navigation list', async () => {
117
177
  const nav = await page.$(navEl);
118
- const hasAriaAttribute = await nav.evaluate(node => node.getAttribute('aria-hidden') !== null);
178
+ const hasAriaAttribute = await nav.evaluate((node) => node.getAttribute('aria-hidden') !== null);
119
179
  expect(hasAriaAttribute).toBe(ariaStatus);
120
180
  });
121
181
 
122
182
  it('has aria-expanded set as `false` on the navigation toggle button', async () => {
123
183
  const button = await page.$(buttonEl);
124
- const ariaExpandedIsFalse = await button.evaluate(node => node.getAttribute('aria-expanded') === 'false');
184
+ const ariaExpandedIsFalse = await button.evaluate((node) => node.getAttribute('aria-expanded') === 'false');
125
185
  expect(ariaExpandedIsFalse).toBe(true);
126
186
  });
127
187
  });
@@ -134,7 +194,7 @@ describe('script: navigation', () => {
134
194
 
135
195
  it('has aria-hidden set as `true` on the navigation list', async () => {
136
196
  const nav = await page.$(navEl);
137
- const hasAriaAttribute = await nav.evaluate(node => node.getAttribute('aria-hidden') === 'true');
197
+ const hasAriaAttribute = await nav.evaluate((node) => node.getAttribute('aria-hidden') === 'true');
138
198
  expect(hasAriaAttribute).toBe(true);
139
199
  });
140
200
 
@@ -146,12 +206,12 @@ describe('script: navigation', () => {
146
206
 
147
207
  it('has aria-hidden set as `false` on the navigation list', async () => {
148
208
  const nav = await page.$(navEl);
149
- const hasAriaAttribute = await nav.evaluate(node => node.getAttribute('aria-hidden') === 'false');
209
+ const hasAriaAttribute = await nav.evaluate((node) => node.getAttribute('aria-hidden') === 'false');
150
210
  expect(hasAriaAttribute).toBe(true);
151
211
  });
152
212
 
153
213
  it('has the hide class removed from the navigation list', async () => {
154
- const hasClass = await page.$eval(navEl, node =>
214
+ const hasClass = await page.$eval(navEl, (node) =>
155
215
  node.classList.contains('ons-u-d-no@xxs@l' || 'ons-u-d-no' || 'ons-u-d-no@xs@l'),
156
216
  );
157
217
  expect(hasClass).toBe(false);
@@ -159,12 +219,12 @@ describe('script: navigation', () => {
159
219
 
160
220
  it('has aria-expanded set as `true` on the navigation toggle button', async () => {
161
221
  const button = await page.$(buttonEl);
162
- const ariaExpandedIsTrue = await button.evaluate(node => node.getAttribute('aria-expanded') === 'true');
222
+ const ariaExpandedIsTrue = await button.evaluate((node) => node.getAttribute('aria-expanded') === 'true');
163
223
  expect(ariaExpandedIsTrue).toBe(true);
164
224
  });
165
225
 
166
226
  it('has the correct class applied to the navigation toggle button', async () => {
167
- const hasClass = await page.$eval(buttonEl, node => node.classList.contains('active'));
227
+ const hasClass = await page.$eval(buttonEl, (node) => node.classList.contains('active'));
168
228
  expect(hasClass).toBe(true);
169
229
  });
170
230
  });
@@ -180,18 +240,18 @@ describe('script: navigation', () => {
180
240
 
181
241
  it('has aria-hidden set as `true` on the navigation list', async () => {
182
242
  const nav = await page.$(navEl);
183
- const hasAriaAttribute = await nav.evaluate(node => node.getAttribute('aria-hidden') === 'true');
243
+ const hasAriaAttribute = await nav.evaluate((node) => node.getAttribute('aria-hidden') === 'true');
184
244
  expect(hasAriaAttribute).toBe(true);
185
245
  });
186
246
 
187
247
  it('has aria-expanded set as `false` on the navigation toggle button', async () => {
188
248
  const button = await page.$(buttonEl);
189
- const ariaExpandedIsTrue = await button.evaluate(node => node.getAttribute('aria-expanded') === 'false');
249
+ const ariaExpandedIsTrue = await button.evaluate((node) => node.getAttribute('aria-expanded') === 'false');
190
250
  expect(ariaExpandedIsTrue).toBe(true);
191
251
  });
192
252
 
193
253
  it('has the active class removed from the navigation toggle button', async () => {
194
- const hasClass = await page.$eval(buttonEl, node => node.classList.contains('active'));
254
+ const hasClass = await page.$eval(buttonEl, (node) => node.classList.contains('active'));
195
255
  expect(hasClass).toBe(false);
196
256
  });
197
257
  });
@@ -210,18 +270,18 @@ describe('script: navigation', () => {
210
270
 
211
271
  it('has the aria-hidden attribute removed from the navigation list', async () => {
212
272
  const nav = await page.$(navEl);
213
- const hasAriaAttribute = await nav.evaluate(node => node.getAttribute('aria-hidden') !== null);
273
+ const hasAriaAttribute = await nav.evaluate((node) => node.getAttribute('aria-hidden') !== null);
214
274
  expect(hasAriaAttribute).toBe(false);
215
275
  });
216
276
 
217
277
  it('has aria-expanded removed from the navigation toggle button', async () => {
218
278
  const button = await page.$(buttonEl);
219
- const hasAriaExpanded = await button.evaluate(node => node.getAttribute('aria-expanded') !== null);
279
+ const hasAriaExpanded = await button.evaluate((node) => node.getAttribute('aria-expanded') !== null);
220
280
  expect(hasAriaExpanded).toBe(false);
221
281
  });
222
282
 
223
283
  it('has the hide class removed from the navigation list', async () => {
224
- const hasClass = await page.$eval(navEl, node =>
284
+ const hasClass = await page.$eval(navEl, (node) =>
225
285
  node.classList.contains('ons-u-d-no@xxs@l' || 'ons-u-d-no' || 'ons-u-d-no@xs@l'),
226
286
  );
227
287
  expect(hasClass).toBe(false);
@@ -230,3 +290,18 @@ describe('script: navigation', () => {
230
290
  },
231
291
  );
232
292
  });
293
+
294
+ describe('level: sub navigation', () => {
295
+ describe('when removeHorizontalSubNav is set to true', () => {
296
+ beforeEach(async () => {
297
+ await setTestPage('/test', renderComponent('header', EXAMPLE_NAVIGATION_WITH_SUBNAVIGATION_REMOVED));
298
+ });
299
+
300
+ it('does not render the sub-nav element', async () => {
301
+ const hasSubNavEl = (await page.content()).includes('.ons-navigation--sub');
302
+ expect(hasSubNavEl).toBe(false);
303
+ });
304
+ });
305
+ });
306
+
307
+
@@ -15,7 +15,7 @@
15
15
  <div>
16
16
  <ul class="ons-tabs__list">
17
17
  {%- for tab in params.tabs -%}
18
- <li class="ons-tab__list-item"><a href="#{{ tab.id if tab.id else tab.title|trim|replace(' ','-')|lower}}" class="ons-tab" data-ga="click" data-ga-category="tabs" data-ga-action="Show: {{ tab.title }}" data-ga-label="Show: {{ tab.title }}">{{ tab.title }}{% if tab.hiddenSpan %}<span class='ons-u-vh'>{{tab.hiddenSpan}}</span>{% endif %}</a></li>
18
+ <li class="ons-tab__list-item"><a href="#{{ tab.id if tab.id else tab.title|trim|replace(' ','-')|lower}}" class="ons-tab"{% if tab.attributes %}{% for attribute, value in (tab.attributes.items() if tab.attributes is mapping and tab.attributes.items else tab.attributes) %} {{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}>{{ tab.title }}{% if tab.hiddenSpan %}<span class='ons-u-vh'>{{tab.hiddenSpan}}</span>{% endif %}</a></li>
19
19
  {%- endfor -%}
20
20
  </ul>
21
21
  </div>
@@ -112,16 +112,6 @@ describe('macro: tabs', () => {
112
112
  expect($('.ons-tab:last').text().trim()).toBe('Tab 2');
113
113
  });
114
114
 
115
- it('has Google Analytics integration on tab links', () => {
116
- const $ = cheerio.load(renderComponent('tabs', EXAMPLE_TABS));
117
-
118
- const tabItem = $('.ons-tab');
119
- expect(tabItem.attr('data-ga')).toBe('click');
120
- expect(tabItem.attr('data-ga-category')).toBe('tabs');
121
- expect(tabItem.attr('data-ga-action')).toBe('Show: Tab 1');
122
- expect(tabItem.attr('data-ga-label')).toBe('Show: Tab 1');
123
- });
124
-
125
115
  it('has expected content in tab panels', () => {
126
116
  const $ = cheerio.load(renderComponent('tabs', EXAMPLE_TABS));
127
117