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

YouTube Lite #303

Merged
merged 13 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
]
},
"dependencies": {
"@guardian/src-foundations": "^3.12.0",
oliverlloyd marked this conversation as resolved.
Show resolved Hide resolved
"youtube-player": "^5.5.2"
}
}
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}
Comment on lines +233 to +241
Copy link
Contributor

@mxdvl mxdvl Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

450×800 isn’t the same ratio as 630×1200… 🤔

Maybe this is why you’ve experienced jank, @arelra?

/>
</div>
</>
);
};
Loading