@ons/design-system 62.0.0 → 62.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.
- package/components/button/_button.scss +5 -3
- package/components/cookies-banner/_macro.njk +2 -2
- package/components/cookies-banner/_macro.spec.js +40 -0
- package/components/header/_macro.spec.js +97 -0
- package/components/navigation/_macro.njk +1 -1
- package/components/table/_macro.njk +1 -1
- package/components/table/_table.scss +10 -10
- package/components/table/sortable-table.dom.js +1 -1
- package/components/table/sortable-table.js +14 -7
- package/css/main.css +2 -2
- package/css/print.css +1 -1
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +2 -2
- package/scss/print.scss +7 -17
|
@@ -99,7 +99,7 @@ $button-shadow-size: 3px;
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
&:active
|
|
102
|
+
&:active {
|
|
103
103
|
top: ems($button-shadow-size);
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -280,10 +280,12 @@ $button-shadow-size: 3px;
|
|
|
280
280
|
&--ghost,
|
|
281
281
|
&--ghost-dark,
|
|
282
282
|
&--dropdown,
|
|
283
|
-
&--text-link
|
|
283
|
+
&--text-link,
|
|
284
|
+
&--disabled,
|
|
285
|
+
&--loader.ons-is-loading {
|
|
284
286
|
&:active,
|
|
285
287
|
.active {
|
|
286
|
-
top: 0;
|
|
288
|
+
top: 0 !important; // Override 'pressed' state for flat and non-selectable buttons
|
|
287
289
|
}
|
|
288
290
|
}
|
|
289
291
|
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
{% endif %}
|
|
31
31
|
|
|
32
32
|
<div class="ons-cookies-banner" role="region" aria-label="{{ params.ariaLabel | default(ariaLabel)}}">
|
|
33
|
-
<div class="ons-container ons-cookies-banner__primary">
|
|
33
|
+
<div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }} ons-cookies-banner__primary">
|
|
34
34
|
<div class="ons-grid">
|
|
35
35
|
<div class="ons-grid__col ons-col-8@m">
|
|
36
36
|
<h2 class="ons-cookies-banner__title ons-u-mb-xs">{{ params.statementTitle | default(statementTitle) }} {{ params.serviceName | default(serviceName) }}</h2>
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
</div>
|
|
69
69
|
</div>
|
|
70
70
|
</div>
|
|
71
|
-
<div class="ons-container ons-cookies-banner__confirmation ons-u-d-no">
|
|
71
|
+
<div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }} ons-cookies-banner__confirmation ons-u-d-no">
|
|
72
72
|
<div class="ons-grid ons-grid--flex ons-grid--between ons-grid--gutterless ons-grid--no-wrap@s ons-grid--vertical-center">
|
|
73
73
|
<div class="ons-grid__col ons-grid__col--flex ons-col-auto ons-u-flex-shrink@s">
|
|
74
74
|
<p class="ons-cookies-banner__desc ons-u-mb-no@s ons-u-mr-s@s"><span class="ons-js-accepted-text ons-u-d-no">{{ params.acceptedText | default(acceptedText) | safe }} </span><span class="ons-js-rejected-text ons-u-d-no">{{ params.rejectedText | default(rejectedText) | safe }} </span><span class="ons-cookies-banner__preferences-text">{{ params.preferencesText | default(preferencesText) | safe }}</span></p>
|
|
@@ -184,6 +184,26 @@ describe('macro: cookies-banner', () => {
|
|
|
184
184
|
const linkText = $('.ons-cookies-banner__link').attr('href');
|
|
185
185
|
expect(linkText).toBe('/cookies');
|
|
186
186
|
});
|
|
187
|
+
|
|
188
|
+
it('has `container--wide` class when `wide` is true', () => {
|
|
189
|
+
const $ = cheerio.load(
|
|
190
|
+
renderComponent('cookies-banner', {
|
|
191
|
+
wide: true,
|
|
192
|
+
}),
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
expect($('.ons-container.ons-cookies-banner__primary').hasClass('ons-container--wide')).toBe(true);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('has `container--full-width` class when `fullWidth` is true', () => {
|
|
199
|
+
const $ = cheerio.load(
|
|
200
|
+
renderComponent('cookies-banner', {
|
|
201
|
+
fullWidth: true,
|
|
202
|
+
}),
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
expect($('.ons-container.ons-cookies-banner__primary').hasClass('ons-container--full-width')).toBe(true);
|
|
206
|
+
});
|
|
187
207
|
});
|
|
188
208
|
|
|
189
209
|
describe('confirmation banner', () => {
|
|
@@ -213,6 +233,26 @@ describe('macro: cookies-banner', () => {
|
|
|
213
233
|
|
|
214
234
|
expect(buttonSpy.occurrences[2].buttonContext).toBe('this message');
|
|
215
235
|
});
|
|
236
|
+
|
|
237
|
+
it('has `container--wide` class when `wide` is true', () => {
|
|
238
|
+
const $ = cheerio.load(
|
|
239
|
+
renderComponent('cookies-banner', {
|
|
240
|
+
wide: true,
|
|
241
|
+
}),
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
expect($('.ons-container.ons-cookies-banner__confirmation').hasClass('ons-container--wide')).toBe(true);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('has `container--full-width` class when `fullWidth` is true', () => {
|
|
248
|
+
const $ = cheerio.load(
|
|
249
|
+
renderComponent('cookies-banner', {
|
|
250
|
+
fullWidth: true,
|
|
251
|
+
}),
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
expect($('.ons-container.ons-cookies-banner__confirmation').hasClass('ons-container--full-width')).toBe(true);
|
|
255
|
+
});
|
|
216
256
|
});
|
|
217
257
|
});
|
|
218
258
|
|
|
@@ -117,6 +117,50 @@ const EXAMPLE_HEADER_NAVIGATION_CONFIG = {
|
|
|
117
117
|
},
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
+
const EXAMPLE_HEADER_NAVIGATION_WITH_SUBNAVIGATION_CONFIG = {
|
|
121
|
+
navigation: {
|
|
122
|
+
id: 'main-nav',
|
|
123
|
+
ariaLabel: 'Main menu',
|
|
124
|
+
currentPath: '#1',
|
|
125
|
+
currentPageTitle: 'Guidance',
|
|
126
|
+
itemsList: [
|
|
127
|
+
{
|
|
128
|
+
title: 'Home',
|
|
129
|
+
url: '#0',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
title: 'Guidance',
|
|
133
|
+
url: '#1',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
toggleNavigationButton: {
|
|
137
|
+
text: 'Menu',
|
|
138
|
+
ariaLabel: 'Toggle main menu',
|
|
139
|
+
},
|
|
140
|
+
subNavigation: {
|
|
141
|
+
id: 'sub-nav',
|
|
142
|
+
overviewURL: '#overview',
|
|
143
|
+
overviewText: 'Overview',
|
|
144
|
+
ariaLabel: 'Section menu',
|
|
145
|
+
currentPath: '#1',
|
|
146
|
+
itemsList: [
|
|
147
|
+
{
|
|
148
|
+
title: 'Sub nav item 1',
|
|
149
|
+
url: '#0',
|
|
150
|
+
classes: 'custom-class-sub-item-1',
|
|
151
|
+
id: 'sub-item-1',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
title: 'Sub nav item 2',
|
|
155
|
+
url: '#1',
|
|
156
|
+
classes: 'custom-class-sub-item-2',
|
|
157
|
+
id: 'sub-item-2',
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
|
|
120
164
|
describe('macro: header', () => {
|
|
121
165
|
describe('mode: basic', () => {
|
|
122
166
|
it('passes jest-axe checks', async () => {
|
|
@@ -644,5 +688,58 @@ describe('macro: header', () => {
|
|
|
644
688
|
},
|
|
645
689
|
});
|
|
646
690
|
});
|
|
691
|
+
|
|
692
|
+
it('renders the navigation in the correct container if `wide`', () => {
|
|
693
|
+
const $ = cheerio.load(
|
|
694
|
+
renderComponent('header', {
|
|
695
|
+
...EXAMPLE_HEADER_BASIC,
|
|
696
|
+
wide: true,
|
|
697
|
+
...EXAMPLE_HEADER_NAVIGATION_CONFIG,
|
|
698
|
+
}),
|
|
699
|
+
);
|
|
700
|
+
|
|
701
|
+
const navContainer = $('.ons-navigation-wrapper .ons-container');
|
|
702
|
+
expect($(navContainer).hasClass('ons-container--wide')).toBe(true);
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
it('renders the navigation in the correct container if `fullWidth`', () => {
|
|
706
|
+
const $ = cheerio.load(
|
|
707
|
+
renderComponent('header', {
|
|
708
|
+
...EXAMPLE_HEADER_BASIC,
|
|
709
|
+
fullWidth: true,
|
|
710
|
+
...EXAMPLE_HEADER_NAVIGATION_CONFIG,
|
|
711
|
+
}),
|
|
712
|
+
);
|
|
713
|
+
|
|
714
|
+
const navContainer = $('.ons-navigation-wrapper .ons-container');
|
|
715
|
+
expect($(navContainer).hasClass('ons-container--full-width')).toBe(true);
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
it('renders the sub-navigation in the correct container if `wide`', () => {
|
|
719
|
+
const $ = cheerio.load(
|
|
720
|
+
renderComponent('header', {
|
|
721
|
+
...EXAMPLE_HEADER_BASIC,
|
|
722
|
+
wide: true,
|
|
723
|
+
...EXAMPLE_HEADER_NAVIGATION_WITH_SUBNAVIGATION_CONFIG,
|
|
724
|
+
}),
|
|
725
|
+
);
|
|
726
|
+
|
|
727
|
+
const subNavContainer = $('.ons-navigation--sub .ons-container');
|
|
728
|
+
expect($(subNavContainer).hasClass('ons-container--wide')).toBe(true);
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
it('renders the sub-navigation in the correct container if `fullWidth`', () => {
|
|
732
|
+
const $ = cheerio.load(
|
|
733
|
+
renderComponent('header', {
|
|
734
|
+
...EXAMPLE_HEADER_BASIC,
|
|
735
|
+
fullWidth: true,
|
|
736
|
+
...EXAMPLE_HEADER_NAVIGATION_WITH_SUBNAVIGATION_CONFIG,
|
|
737
|
+
}),
|
|
738
|
+
);
|
|
739
|
+
console.log($.html());
|
|
740
|
+
|
|
741
|
+
const subNavContainer = $('.ons-navigation--sub .ons-container');
|
|
742
|
+
expect($(subNavContainer).hasClass('ons-container--full-width')).toBe(true);
|
|
743
|
+
});
|
|
647
744
|
});
|
|
648
745
|
});
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
</div>
|
|
52
52
|
{% if params.navigation.subNavigation %}
|
|
53
53
|
<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">
|
|
54
|
-
<div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.wide or params.navigation.wide }}">
|
|
54
|
+
<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 }}">
|
|
55
55
|
<ul class="ons-navigation__list ons-navigation__list">
|
|
56
56
|
{% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
|
|
57
57
|
<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) }}">
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
[aria-sort='descending'].ons-table__header {
|
|
158
158
|
.ons-svg-icon {
|
|
159
159
|
.ons-topTriangle {
|
|
160
|
-
fill: var(--ons-color-grey-
|
|
160
|
+
fill: var(--ons-color-grey-15);
|
|
161
161
|
}
|
|
162
162
|
.ons-bottomTriangle {
|
|
163
163
|
fill: var(--ons-color-text);
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
.ons-table__sort-button:focus {
|
|
167
167
|
.ons-svg-icon {
|
|
168
168
|
.ons-topTriangle {
|
|
169
|
-
fill: #
|
|
169
|
+
fill: #e3ba02;
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -178,13 +178,13 @@
|
|
|
178
178
|
fill: var(--ons-color-text);
|
|
179
179
|
}
|
|
180
180
|
.ons-bottomTriangle {
|
|
181
|
-
fill: var(--ons-color-grey-
|
|
181
|
+
fill: var(--ons-color-grey-15);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
.ons-table__sort-button:focus {
|
|
185
185
|
.ons-svg-icon {
|
|
186
186
|
.ons-bottomTriangle {
|
|
187
|
-
fill: #
|
|
187
|
+
fill: #e3ba02;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
}
|
|
@@ -196,26 +196,26 @@
|
|
|
196
196
|
border: 0;
|
|
197
197
|
box-shadow: none;
|
|
198
198
|
color: var(--ons-color-text-link);
|
|
199
|
+
cursor: pointer;
|
|
199
200
|
display: inline-block;
|
|
200
201
|
font-family: $font-sans;
|
|
201
202
|
font-weight: $font-weight-bold;
|
|
202
203
|
line-height: 1rem;
|
|
203
204
|
padding: 0 0 0.2rem;
|
|
204
|
-
text-decoration: underline;
|
|
205
|
-
text-underline-position: under;
|
|
206
205
|
white-space: nowrap;
|
|
207
206
|
|
|
208
|
-
&:hover {
|
|
207
|
+
&:hover:not(:focus) {
|
|
209
208
|
color: var(--ons-color-text-link-hover);
|
|
210
|
-
cursor: pointer;
|
|
211
209
|
text-decoration: underline solid var(--ons-color-text-link-hover) 2px;
|
|
210
|
+
text-underline-position: under;
|
|
212
211
|
}
|
|
213
212
|
|
|
214
213
|
.ons-svg-icon {
|
|
215
214
|
fill: var(--ons-color-grey-75);
|
|
216
|
-
height:
|
|
215
|
+
height: 16px;
|
|
216
|
+
margin-left: 0.2rem;
|
|
217
217
|
padding-bottom: 0.1rem;
|
|
218
|
-
width:
|
|
218
|
+
width: 16px;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
&:focus {
|
|
@@ -3,12 +3,13 @@ export const classTableBody = 'ons-table__body';
|
|
|
3
3
|
export let status;
|
|
4
4
|
|
|
5
5
|
export default class TableSort {
|
|
6
|
-
constructor(table) {
|
|
6
|
+
constructor(table, index) {
|
|
7
7
|
this.table = table;
|
|
8
8
|
this.options = {};
|
|
9
9
|
this.options.statusMessage = table.getAttribute('data-aria-sort');
|
|
10
10
|
this.options.ascendingText = table.getAttribute('data-aria-asc');
|
|
11
11
|
this.options.descendingText = table.getAttribute('data-aria-desc');
|
|
12
|
+
this.index = index;
|
|
12
13
|
this.init();
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -35,16 +36,18 @@ export default class TableSort {
|
|
|
35
36
|
button.setAttribute('data-index', i);
|
|
36
37
|
button.setAttribute('class', 'ons-table__sort-button');
|
|
37
38
|
button.textContent = text;
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
const sortSpriteIdText = text.replace(/\s+/g, '-').toLowerCase();
|
|
40
|
+
const sortSprite = document.getElementById('sort-sprite-' + sortSpriteIdText);
|
|
41
|
+
sortSprite.id = 'sort-sprite-' + sortSpriteIdText + '-' + this.index;
|
|
40
42
|
const sortSpriteParent = sortSprite.parentNode;
|
|
41
43
|
sortSpriteParent.replaceChild(button, sortSprite);
|
|
42
44
|
button.appendChild(sortSprite);
|
|
45
|
+
button.addEventListener('click', this.sortButtonClicked.bind(this));
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
sortButtonClicked(event) {
|
|
46
|
-
const columnNumber = event.target.getAttribute('data-index');
|
|
47
|
-
const sortDirection = event.target.
|
|
49
|
+
const columnNumber = event.target.closest('[data-index]').getAttribute('data-index');
|
|
50
|
+
const sortDirection = event.target.closest('[aria-sort]').getAttribute('aria-sort');
|
|
48
51
|
let newSortDirection;
|
|
49
52
|
|
|
50
53
|
if (sortDirection === 'none' || sortDirection === 'ascending') {
|
|
@@ -63,7 +66,7 @@ export default class TableSort {
|
|
|
63
66
|
});
|
|
64
67
|
|
|
65
68
|
this.removeButtonStates();
|
|
66
|
-
this.updateButtonState(event.target, newSortDirection);
|
|
69
|
+
this.updateButtonState(event.target.closest('[aria-sort]'), newSortDirection);
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
getTableRowsArray(tbody) {
|
|
@@ -109,6 +112,10 @@ export default class TableSort {
|
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
getCellValue(cell) {
|
|
115
|
+
if (!cell) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
112
119
|
let cellValue = cell.getAttribute('data-sort-value') || cell.textContent;
|
|
113
120
|
cellValue = parseFloat(cellValue) || cellValue;
|
|
114
121
|
|
|
@@ -130,7 +137,7 @@ export default class TableSort {
|
|
|
130
137
|
}
|
|
131
138
|
|
|
132
139
|
updateButtonState(button, direction) {
|
|
133
|
-
button.
|
|
140
|
+
button.setAttribute('aria-sort', direction);
|
|
134
141
|
let message = this.options.statusMessage;
|
|
135
142
|
message = message + ' ' + button.textContent.replace(/^\s+|\s+$/g, '');
|
|
136
143
|
message = message + ' (' + direction + ')';
|