@ons/design-system 61.0.0 → 61.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/access-code/_macro.njk +6 -8
- package/components/modal/modal.js +12 -6
- package/components/modal/modal.spec.js +0 -11
- package/components/summary/_macro.njk +2 -2
- package/components/summary/_summary.scss +3 -12
- package/components/timeout-modal/_macro.njk +19 -20
- package/components/timeout-modal/timeout-modal.spec.js +17 -13
- package/css/main.css +1 -1
- package/js/analytics.js +1 -5
- package/js/timeout.js +7 -0
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
|
@@ -28,9 +28,8 @@
|
|
|
28
28
|
|
|
29
29
|
{% if not params.error %}
|
|
30
30
|
{% call onsPanel({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
%}
|
|
31
|
+
"classes": "ons-u-mb-s" + (' ' + params.classes if params.classes)
|
|
32
|
+
}) %}
|
|
34
33
|
{{ content | safe }}
|
|
35
34
|
{% endcall %}
|
|
36
35
|
{% else %}
|
|
@@ -39,11 +38,10 @@
|
|
|
39
38
|
|
|
40
39
|
{% if params.securityMessage %}
|
|
41
40
|
{% call onsPanel({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
%}
|
|
41
|
+
"type": "bare",
|
|
42
|
+
"iconType": "lock",
|
|
43
|
+
"classes": "ons-u-mb-s"
|
|
44
|
+
}) %}
|
|
47
45
|
{{ params.securityMessage }}
|
|
48
46
|
{% endcall %}
|
|
49
47
|
{% endif %}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import dialogPolyfill from 'dialog-polyfill';
|
|
2
|
+
import initAnalytics from '../../js/analytics';
|
|
2
3
|
|
|
3
4
|
const overLayClass = 'ons-modal-overlay';
|
|
4
5
|
const ie11Class = 'ons-modal-ie11';
|
|
@@ -8,7 +9,7 @@ export default class Modal {
|
|
|
8
9
|
this.component = component;
|
|
9
10
|
this.launcher = document.querySelector(`[data-modal-id=${component.id}]`);
|
|
10
11
|
this.closeButton = component.querySelector('.ons-js-modal-btn');
|
|
11
|
-
this.
|
|
12
|
+
this.setGAAttributes = component.getAttribute('data-enable-ga');
|
|
12
13
|
this.lastFocusedEl = null;
|
|
13
14
|
this.dialogCSSSupported = true;
|
|
14
15
|
this.modalType = this.component.classList.contains('ons-js-timeout-modal') ? 'Timeout' : 'Generic';
|
|
@@ -33,9 +34,10 @@ export default class Modal {
|
|
|
33
34
|
if (this.modalType !== 'Timeout') {
|
|
34
35
|
window.addEventListener('keydown', this.escToClose.bind(this));
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
if (this.setGAAttributes) {
|
|
39
|
+
this.component.setAttribute('data-ga', `visible`);
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
dialogSupported() {
|
|
@@ -71,13 +73,15 @@ export default class Modal {
|
|
|
71
73
|
this.component.showModal();
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
if (this.
|
|
76
|
+
if (this.setGAAttributes) {
|
|
75
77
|
if (event) {
|
|
76
78
|
this.component.setAttribute('data-ga-action', `Modal opened by ${event.type} event`);
|
|
77
79
|
} else {
|
|
78
80
|
this.component.setAttribute('data-ga-action', 'Modal opened by timed event');
|
|
79
81
|
}
|
|
80
82
|
this.component.setAttribute('data-ga-label', `${this.modalType} modal opened`);
|
|
83
|
+
this.component.setAttribute('data-ga-category', `${this.modalType} modal`);
|
|
84
|
+
initAnalytics();
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
}
|
|
@@ -116,13 +120,15 @@ export default class Modal {
|
|
|
116
120
|
this.component.close();
|
|
117
121
|
this.setFocusOnLastFocusedEl(this.lastFocusedEl);
|
|
118
122
|
|
|
119
|
-
if (this.
|
|
123
|
+
if (this.setGAAttributes) {
|
|
120
124
|
if (event) {
|
|
121
125
|
this.component.setAttribute('data-ga-action', `Modal closed by ${event.type} event`);
|
|
122
126
|
} else {
|
|
123
127
|
this.component.setAttribute('data-ga-action', 'Modal closed by timed event');
|
|
124
128
|
}
|
|
125
129
|
this.component.setAttribute('data-ga-label', `${this.modalType} modal closed`);
|
|
130
|
+
this.component.setAttribute('data-ga-category', `${this.modalType} modal`);
|
|
131
|
+
initAnalytics();
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
}
|
|
@@ -82,17 +82,6 @@ describe('script: modal', () => {
|
|
|
82
82
|
await setTestPage('/test', template);
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
describe('when the page has been loaded but the modal has not been opened yet', () => {
|
|
86
|
-
it('has the correct attributes set on the modal', async () => {
|
|
87
|
-
const gaLabel = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-label'));
|
|
88
|
-
const gaAction = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-action'));
|
|
89
|
-
const gaCategory = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-category'));
|
|
90
|
-
expect(gaLabel).toBe('Generic modal initialised');
|
|
91
|
-
expect(gaAction).toBe('Modal initialised');
|
|
92
|
-
expect(gaCategory).toBe('Generic modal');
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
85
|
describe('when the modal is launched by a click event', () => {
|
|
97
86
|
beforeEach(async () => {
|
|
98
87
|
await page.focus('#launcher');
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
{% for rowItem in row.rowItems %}
|
|
40
40
|
<dl class="ons-summary__row{{ " ons-summary__row--has-values" if rowItem.valueList else "" }}"{% if rowItem.id %} id="{{ rowItem.id }}"{% endif %}>
|
|
41
|
-
<dt class="ons-summary__item-title
|
|
41
|
+
<dt class="ons-summary__item-title"
|
|
42
42
|
{% if rowItem.rowTitleAttributes %}{% for attribute, value in (rowItem.rowTitleAttributes.items() if rowItem.rowTitleAttributes is mapping and rowItem.rowTitleAttributes.items else rowItem.rowTitleAttributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
|
|
43
43
|
>
|
|
44
44
|
{% if rowItem.iconType %}
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
</dt>
|
|
64
64
|
{% if rowItem.valueList %}
|
|
65
65
|
<dd
|
|
66
|
-
class="ons-summary__values"
|
|
66
|
+
class="ons-summary__values{% if not rowItem.actions %} ons-summary__values--2{% endif %}"
|
|
67
67
|
{% if rowItem.attributes %}{% for attribute, value in (rowItem.attributes.items() if rowItem.attributes is mapping and rowItem.attributes.items else rowItem.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
|
|
68
68
|
>
|
|
69
69
|
{% if rowItem.valueList | length == 1 %}
|
|
@@ -178,7 +178,7 @@ $hub-row-spacing: 1.3rem;
|
|
|
178
178
|
&__item-title,
|
|
179
179
|
&__values,
|
|
180
180
|
&__actions {
|
|
181
|
-
flex:
|
|
181
|
+
flex: 5 1 33%;
|
|
182
182
|
padding-top: $summary-row-spacing;
|
|
183
183
|
vertical-align: top;
|
|
184
184
|
|
|
@@ -196,13 +196,8 @@ $hub-row-spacing: 1.3rem;
|
|
|
196
196
|
align-self: flex-start;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
&
|
|
200
|
-
|
|
201
|
-
flex: 7.3;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
&__item-title--2 {
|
|
205
|
-
flex: 4.5;
|
|
199
|
+
&__values--2 {
|
|
200
|
+
flex: 10.5 1 66%;
|
|
206
201
|
}
|
|
207
202
|
|
|
208
203
|
&--hub & {
|
|
@@ -211,10 +206,6 @@ $hub-row-spacing: 1.3rem;
|
|
|
211
206
|
&__actions {
|
|
212
207
|
padding-top: $hub-row-spacing;
|
|
213
208
|
}
|
|
214
|
-
|
|
215
|
-
&__actions {
|
|
216
|
-
flex: 6;
|
|
217
|
-
}
|
|
218
209
|
}
|
|
219
210
|
}
|
|
220
211
|
}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
{% from "components/modal/_macro.njk" import onsModal %}
|
|
2
2
|
{% macro onsTimeoutModal(params) %}
|
|
3
3
|
{% call onsModal({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
%}
|
|
4
|
+
"title": params.title,
|
|
5
|
+
"btnText": params.btnText,
|
|
6
|
+
"classes": "ons-js-timeout-modal",
|
|
7
|
+
"enableGA": params.enableGA,
|
|
8
|
+
"attributes": {
|
|
9
|
+
"data-redirect-url": params.redirectUrl,
|
|
10
|
+
"data-server-session-expires-at": params.sessionExpiresAt,
|
|
11
|
+
"data-show-modal-time": params.showModalTimeInSeconds,
|
|
12
|
+
"data-server-session-expiry-endpoint": params.serverSessionExpiryEndpoint,
|
|
13
|
+
"data-countdown-text": params.countdownText,
|
|
14
|
+
"data-countdown-expired-text": params.countdownExpiredText,
|
|
15
|
+
"data-minutes-text-singular": params.minutesTextSingular,
|
|
16
|
+
"data-minutes-text-plural": params.minutesTextPlural,
|
|
17
|
+
"data-seconds-text-singular": params.secondsTextSingular,
|
|
18
|
+
"data-seconds-text-plural": params.secondsTextPlural,
|
|
19
|
+
"data-full-stop": params.endWithFullStop,
|
|
20
|
+
"aria-describedby": "timeout-time-remaining"
|
|
21
|
+
}
|
|
22
|
+
}) %}
|
|
24
23
|
<p>{{ params.textFirstLine }}</p>
|
|
25
24
|
<p class="ons-js-timeout-timer" aria-hidden="true" aria-relevant="additions"></p>
|
|
26
25
|
<p class="ons-js-timeout-timer-acc ons-u-vh" role="status" id="timeout-time-remaining"></p>
|
|
@@ -167,6 +167,7 @@ describe('script: timeout modal', () => {
|
|
|
167
167
|
...EXAMPLE_TIMEOUT_MODAL_BASIC,
|
|
168
168
|
showModalTimeInSeconds: 1,
|
|
169
169
|
sessionExpiresAt: expiryTimeInISOFormat,
|
|
170
|
+
enableGA: true,
|
|
170
171
|
});
|
|
171
172
|
|
|
172
173
|
const template = `
|
|
@@ -186,6 +187,15 @@ describe('script: timeout modal', () => {
|
|
|
186
187
|
await page.waitForTimeout(2000);
|
|
187
188
|
expect(page.url()).toContain('#!');
|
|
188
189
|
});
|
|
190
|
+
|
|
191
|
+
it('and GA tracking is enabled it has the correct attributes set on the modal', async () => {
|
|
192
|
+
const gaLabel = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-label'));
|
|
193
|
+
const gaAction = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-action'));
|
|
194
|
+
const gaCategory = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-category'));
|
|
195
|
+
expect(gaLabel).toBe('Timeout modal closed');
|
|
196
|
+
expect(gaAction).toBe('Modal closed by timed event');
|
|
197
|
+
expect(gaCategory).toBe('Timeout modal');
|
|
198
|
+
});
|
|
189
199
|
});
|
|
190
200
|
});
|
|
191
201
|
|
|
@@ -233,23 +243,17 @@ describe('script: timeout modal', () => {
|
|
|
233
243
|
});
|
|
234
244
|
|
|
235
245
|
const template = `
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
246
|
+
<div class="ons-page">
|
|
247
|
+
${component}
|
|
248
|
+
</div>
|
|
249
|
+
`;
|
|
240
250
|
|
|
241
251
|
await setTestPage('/test', template);
|
|
242
252
|
});
|
|
243
253
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const gaAction = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-action'));
|
|
248
|
-
const gaCategory = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-category'));
|
|
249
|
-
expect(gaLabel).toBe('Timeout modal initialised');
|
|
250
|
-
expect(gaAction).toBe('Modal initialised');
|
|
251
|
-
expect(gaCategory).toBe('Timeout modal');
|
|
252
|
-
});
|
|
254
|
+
it('has ga initialise attribute set', async () => {
|
|
255
|
+
const gaInitialise = await page.$eval('.ons-modal', node => node.getAttribute('data-ga'));
|
|
256
|
+
expect(gaInitialise).toBe('visible');
|
|
253
257
|
});
|
|
254
258
|
|
|
255
259
|
describe('when the modal is open', () => {
|