Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all 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
122 changes: 61 additions & 61 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,67 @@ import { breakpoints } from '@guardian/source-foundations';
import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport';

const customViewports = {
desktop: {
name: 'Wide',
styles: {
width: `${breakpoints.wide}px`,
height: '100%',
},
type: 'wide',
},
desktop: {
name: 'Desktop',
styles: {
width: `${breakpoints.desktop}px`,
height: '100%',
},
type: 'desktop',
},
tablet: {
name: 'Tablet',
styles: {
width: `${breakpoints.tablet}px`,
height: MINIMAL_VIEWPORTS.tablet.styles.height,
},
type: 'tablet',
},
phablet: {
name: 'Phablet',
styles: {
width: `${breakpoints.phablet}px`,
height: MINIMAL_VIEWPORTS.mobile2.styles.height,
},
type: 'other',
},
mobileLandscape: {
name: 'Mobile Landscape',
styles: {
width: `${breakpoints.mobileLandscape}px`,
height: MINIMAL_VIEWPORTS.mobile2.styles.width,
},
type: 'mobile',
},
mobileMedium: {
name: 'Mobile Medium',
styles: {
width: `${breakpoints.mobileMedium}px`,
height: MINIMAL_VIEWPORTS.mobile2.styles.height,
},
type: 'mobile',
},
mobile: {
name: 'Mobile',
styles: {
width: `${breakpoints.mobile}px`,
height: MINIMAL_VIEWPORTS.mobile1.styles.height,
},
type: 'mobile',
},
desktop: {
name: 'Wide',
styles: {
width: `${breakpoints.wide}px`,
height: '100%',
},
type: 'wide',
},
desktop: {
name: 'Desktop',
styles: {
width: `${breakpoints.desktop}px`,
height: '100%',
},
type: 'desktop',
},
tablet: {
name: 'Tablet',
styles: {
width: `${breakpoints.tablet}px`,
height: MINIMAL_VIEWPORTS.tablet.styles.height,
},
type: 'tablet',
},
phablet: {
name: 'Phablet',
styles: {
width: `${breakpoints.phablet}px`,
height: MINIMAL_VIEWPORTS.mobile2.styles.height,
},
type: 'other',
},
mobileLandscape: {
name: 'Mobile Landscape',
styles: {
width: `${breakpoints.mobileLandscape}px`,
height: MINIMAL_VIEWPORTS.mobile2.styles.width,
},
type: 'mobile',
},
mobileMedium: {
name: 'Mobile Medium',
styles: {
width: `${breakpoints.mobileMedium}px`,
height: MINIMAL_VIEWPORTS.mobile2.styles.height,
},
type: 'mobile',
},
mobile: {
name: 'Mobile',
styles: {
width: `${breakpoints.mobile}px`,
height: MINIMAL_VIEWPORTS.mobile1.styles.height,
},
type: 'mobile',
},
};

export const parameters = {
viewport: {
defaultViewport: 'wide',
viewports: customViewports,
},
};
viewport: {
defaultViewport: 'wide',
viewports: customViewports,
},
};
46 changes: 46 additions & 0 deletions src/YoutubeAtom.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,49 @@ export const MultipleVideos = (): JSX.Element => {
</div>
);
};

export const WithZeroDuration = (): JSX.Element => {
return (
<div style={containerStyle}>
<YoutubeAtom
elementId="xyz"
videoId="N9Cgy-ke5-s"
alt=""
role="inline"
eventEmitters={[
(e) => console.log(`analytics event ${e} called`),
]}
duration={0}
pillar={ArticlePillar.Opinion}
consentState={{}}
posterImage={[
{
srcSet: [
{
src: 'https://media.guim.co.uk/757dd4db5818984fd600b41cdaf687668497051d/0_0_1920_1080/1000.jpg',
width: 1000,
},
{
src: 'https://media.guim.co.uk/757dd4db5818984fd600b41cdaf687668497051d/0_0_1920_1080/500.jpg',
width: 500,
},
{
src: 'https://media.guim.co.uk/757dd4db5818984fd600b41cdaf687668497051d/0_0_1920_1080/140.jpg',
width: 140,
},
{
src: 'https://media.guim.co.uk/757dd4db5818984fd600b41cdaf687668497051d/0_0_1920_1080/1920.jpg',
width: 1920,
},
],
},
]}
height={450}
width={800}
shouldStick={false}
isMainMedia={false}
title="How Donald Trump’s broken promises failed Ohio"
/>
</div>
);
};
4 changes: 2 additions & 2 deletions src/YoutubeAtomOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ export const YoutubeAtomOverlay = ({
>
<SvgPlay />
</div>
{duration !== undefined && duration > 0 && (
{duration ? (
Copy link
Copy Markdown
Contributor

@oliverlloyd oliverlloyd Jul 20, 2022

Choose a reason for hiding this comment

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

Did you mean to add this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it’s a refactor that I believe keeps thing clearer, but happy to drop it. Any thoughts @AshCorr, as you implemented the initial fix?

In any case it would not require a version bump as the result is identical.

<div css={videoDurationStyles(pillar)}>
{formatTime(duration)}
</div>
)}
) : null}
</div>
</button>
);
Expand Down