@ons/design-system 60.0.3 → 61.0.0
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/accordion/_macro.njk +2 -3
- package/components/accordion/_macro.spec.js +9 -9
- package/components/accordion/accordion.dom.js +4 -4
- package/components/accordion/accordion.js +14 -14
- package/components/accordion/accordion.spec.js +6 -6
- package/components/collapsible/_macro.njk +20 -28
- package/components/collapsible/_macro.spec.js +15 -15
- package/components/{collapsible/_collapsible.scss → details/_details.scss} +14 -14
- package/components/details/_macro.njk +30 -0
- package/components/details/_macro.spec.js +151 -0
- package/components/details/details.dom.js +13 -0
- package/components/details/details.js +66 -0
- package/components/details/details.spec.js +103 -0
- package/components/hero/_hero.scss +2 -2
- package/components/question/_macro.njk +4 -4
- package/components/question/_macro.spec.js +14 -14
- package/components/summary/_macro.njk +1 -1
- package/components/summary/_macro.spec.js +148 -1
- package/components/summary/_summary.scss +6 -2
- package/components/table/_macro.spec.js +10 -8
- package/components/video/_macro.njk +18 -4
- package/components/video/_macro.spec.js +46 -33
- package/components/video/_video.scss +4 -0
- package/components/video/video.dom.js +13 -0
- package/components/video/video.js +30 -0
- package/components/video/video.spec.js +72 -0
- package/css/main.css +3 -3
- package/css/print.css +1 -1
- package/js/main.js +2 -1
- package/package.json +2 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +1 -1
- package/scss/objects/_page.scss +1 -1
- package/scss/objects/_spacing.scss +1 -1
- package/scss/overrides/hcm.scss +1 -1
- package/scss/print.scss +1 -1
- package/components/collapsible/collapsible.dom.js +0 -13
- package/components/collapsible/collapsible.js +0 -66
- package/components/collapsible/collapsible.spec.js +0 -103
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default class Video {
|
|
2
|
+
constructor(component) {
|
|
3
|
+
this.component = component;
|
|
4
|
+
this.placeholder = component.querySelector('.ons-js-video-placeholder');
|
|
5
|
+
this.iframe = component.querySelector('.ons-js-video-iframe');
|
|
6
|
+
|
|
7
|
+
this.acceptCookiesButton = document.querySelector('.ons-js-accept-cookies');
|
|
8
|
+
if (this.acceptCookiesButton) {
|
|
9
|
+
this.acceptCookiesButton.addEventListener('click', this.showIframe.bind(this));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const allowsVideoEmbed = this.checkCookie();
|
|
13
|
+
if (allowsVideoEmbed) {
|
|
14
|
+
this.showIframe();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
checkCookie() {
|
|
19
|
+
const campaignsCookieRegex = /^(.*)?\s*'campaigns':true\s*[^;]+(.*)?$/;
|
|
20
|
+
const cookieMatch = document.cookie.match(campaignsCookieRegex);
|
|
21
|
+
return !!cookieMatch;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
showIframe() {
|
|
25
|
+
const src = this.iframe.getAttribute('data-src');
|
|
26
|
+
this.iframe.src = src;
|
|
27
|
+
this.iframe.classList.remove('ons-u-d-no');
|
|
28
|
+
this.placeholder.classList.add('ons-u-d-no');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
2
|
+
|
|
3
|
+
const EXAMPLE_VIDEO_YOUTUBE = {
|
|
4
|
+
videoEmbedUrl: 'https://www.youtube.com/embed/_EGJlvkgbPo',
|
|
5
|
+
title: 'Census 2021 promotional TV advert',
|
|
6
|
+
linkText: 'Example link text',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const EXAMPLE_APPROVED_COOKIE = JSON.stringify({ campaigns: true }).replace(/"/g, "'");
|
|
10
|
+
|
|
11
|
+
describe('script: video', () => {
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
const client = await page.target().createCDPSession();
|
|
14
|
+
await client.send('Network.clearBrowserCookies');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should show the placeholder content', async () => {
|
|
18
|
+
await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
|
|
19
|
+
|
|
20
|
+
const displayStyle = await page.$eval('.ons-js-video-placeholder', node => window.getComputedStyle(node).getPropertyValue('display'));
|
|
21
|
+
expect(displayStyle).toBe('block');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should not show the iframe', async () => {
|
|
25
|
+
await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
|
|
26
|
+
|
|
27
|
+
const displayStyle = await page.$eval('.ons-js-video-iframe', node => window.getComputedStyle(node).getPropertyValue('display'));
|
|
28
|
+
expect(displayStyle).toBe('none');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('when cookies are accepted on page load', () => {
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
await page.setCookie({
|
|
34
|
+
name: 'ons_cookie_policy',
|
|
35
|
+
value: EXAMPLE_APPROVED_COOKIE,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should hide the placeholder content', async () => {
|
|
42
|
+
const displayStyle = await page.$eval('.ons-js-video-placeholder', node => window.getComputedStyle(node).getPropertyValue('display'));
|
|
43
|
+
expect(displayStyle).toBe('none');
|
|
44
|
+
}, 10000);
|
|
45
|
+
|
|
46
|
+
it('should show the iframe', async () => {
|
|
47
|
+
const displayStyle = await page.$eval('.ons-js-video-iframe', node => window.getComputedStyle(node).getPropertyValue('display'));
|
|
48
|
+
expect(displayStyle).toBe('block');
|
|
49
|
+
}, 10000);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('when cookies are accepted via banner', () => {
|
|
53
|
+
beforeEach(async () => {
|
|
54
|
+
await setTestPage(
|
|
55
|
+
'/test',
|
|
56
|
+
`${renderComponent('video', EXAMPLE_VIDEO_YOUTUBE)}
|
|
57
|
+
<div class="ons-cookies-banner ons-u-db"><button class="ons-js-accept-cookies">Accept</button></div>`,
|
|
58
|
+
);
|
|
59
|
+
await page.click('.ons-js-accept-cookies');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should hide the placeholder content', async () => {
|
|
63
|
+
const displayStyle = await page.$eval('.ons-js-video-placeholder', node => window.getComputedStyle(node).getPropertyValue('display'));
|
|
64
|
+
expect(displayStyle).toBe('none');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should show the iframe', async () => {
|
|
68
|
+
const displayStyle = await page.$eval('.ons-js-video-iframe', node => window.getComputedStyle(node).getPropertyValue('display'));
|
|
69
|
+
expect(displayStyle).toBe('block');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|