Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #303 from guardian/oliver/you-tube-consent
Browse files Browse the repository at this point in the history
YouTube Lite
  • Loading branch information
oliverlloyd authored Nov 25, 2021
2 parents 03c10df + b54e4a9 commit 7a86715
Show file tree
Hide file tree
Showing 4 changed files with 395 additions and 104 deletions.
78 changes: 76 additions & 2 deletions src/YoutubeAtom.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { css } from '@emotion/react';

import { YoutubeAtom } from './YoutubeAtom';
Expand All @@ -9,7 +9,7 @@ export default {
component: YoutubeAtom,
};

export const DefaultStory = (): JSX.Element => {
export const NoConsent = (): JSX.Element => {
return (
<div
css={css`
Expand All @@ -26,6 +26,33 @@ export const DefaultStory = (): JSX.Element => {
]}
duration={252}
pillar={ArticlePillar.Culture}
height={450}
width={800}
/>
</div>
);
};

export const NoOverlay = (): JSX.Element => {
return (
<div
css={css`
width: 800px;
margin: 25px;
`}
>
<YoutubeAtom
assetId="-ZCvZmYlQD8"
alt=""
role="inline"
eventEmitters={[
(e) => console.log(`analytics event ${e} called`),
]}
consentState={{}}
duration={252}
pillar={ArticlePillar.Culture}
height={450}
width={800}
/>
</div>
);
Expand All @@ -47,6 +74,7 @@ export const WithOverrideImage = (): JSX.Element => {
(e) => console.log(`analytics event ${e} called`),
]}
duration={252}
consentState={{}}
pillar={ArticlePillar.News}
overrideImage={[
{
Expand Down Expand Up @@ -81,6 +109,7 @@ export const WithPosterImage = (): JSX.Element => {
]}
pillar={ArticlePillar.Sport}
duration={252}
consentState={{}}
posterImage={[
{
srcSet: [
Expand All @@ -107,6 +136,8 @@ export const WithPosterImage = (): JSX.Element => {
],
},
]}
height={450}
width={800}
/>
</div>
);
Expand Down Expand Up @@ -140,6 +171,7 @@ export const WithOverlayAndPosterImage = (): JSX.Element => {
],
},
]}
consentState={{}}
posterImage={[
{
srcSet: [
Expand All @@ -166,7 +198,49 @@ export const WithOverlayAndPosterImage = (): JSX.Element => {
],
},
]}
height={450}
width={800}
/>
</div>
);
};

export const GiveConsent = (): JSX.Element => {
const [consented, setConsented] = useState(false);
return (
<>
<button onClick={() => setConsented(true)}>Give consent</button>
<div
css={css`
width: 800px;
margin: 25px;
`}
>
<YoutubeAtom
assetId="3jpXAMwRSu4"
alt="Microscopic image of COVID"
role="inline"
eventEmitters={[
(e) => console.log(`analytics event ${e} called`),
]}
consentState={consented ? {} : undefined}
duration={252}
pillar={ArticlePillar.News}
overrideImage={[
{
srcSet: [
{
width: 500,
src:
'https://i.guim.co.uk/img/media/4b3808707ec341629932a9d443ff5a812cf4df14/0_309_1800_1081/master/1800.jpg?width=1200&height=630&quality=85&auto=format&fit=crop&overlay-align=bottom%2Cleft&overlay-width=100p&overlay-base64=L2ltZy9zdGF0aWMvb3ZlcmxheXMvdGctZGVmYXVsdC5wbmc&enable=upscale&s=aff4b8255693eb449f13070df88e9cac',
},
],
},
]}
height={450}
width={800}
/>
</div>
</>
);
};
Loading

0 comments on commit 7a86715

Please sign in to comment.