Skip to content

Commit

Permalink
Hide play icon on small cards and relocate duration pill
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmockett committed Dec 10, 2024
1 parent e06f4ba commit cc3680c
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions dotcom-rendering/src/components/YoutubeAtom/YoutubeAtomOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { FormatBoundary } from '../FormatBoundary';
import { Kicker } from '../Kicker';
import { secondsToDuration } from '../MediaDuration';
import { Pill } from '../Pill';
import { SvgMediaControlsPlay } from '../SvgMediaControlsPlay';
import { YoutubeAtomPicture } from './YoutubeAtomPicture';

export type VideoCategory = 'live' | 'documentary' | 'explainer';
Expand Down Expand Up @@ -71,10 +72,17 @@ const overlayStyles = css`
}
`;

const pillStyles = css`
const pillPositionStyles = (smallCard: boolean) => css`
position: absolute;
top: ${space[2]}px;
right: ${space[2]}px;
${smallCard
? css`
bottom: ${space[1]}px;
left: ${space[1]}px;
`
: css`
top: ${space[2]}px;
right: ${space[2]}px;
`};
`;

const liveStyles = css`
Expand Down Expand Up @@ -139,8 +147,8 @@ export const YoutubeAtomOverlay = ({
const showPill = !!videoCategory || hasDuration;
const isLive = videoCategory === 'live';
const image = overrideImage ?? posterImage;
// const hidePillOnMobile =
// imagePositionOnMobile === 'right' || imagePositionOnMobile === 'left';
const isSmallCard =
imagePositionOnMobile === 'right' || imagePositionOnMobile === 'left';

return (
<FormatBoundary format={format}>
Expand All @@ -161,9 +169,9 @@ export const YoutubeAtomOverlay = ({
/>
)}
{showPill && (
<div css={pillStyles}>
<div css={pillPositionStyles(isSmallCard)}>
<Pill>
{!!videoCategory && (
{!!videoCategory && !isSmallCard && (
<Pill.Segment>
<span css={isLive && liveStyles}>
{capitalise(videoCategory)}
Expand All @@ -172,16 +180,19 @@ export const YoutubeAtomOverlay = ({
)}
{!!hasDuration && (
<Pill.Segment>
{isSmallCard && <SvgMediaControlsPlay />}
{secondsToDuration(duration)}
</Pill.Segment>
)}
</Pill>
</div>
)}
<PlayIcon
imageSize={imageSize}
imagePositionOnMobile={imagePositionOnMobile}
/>
{!isSmallCard && (
<PlayIcon
imageSize={imageSize}
imagePositionOnMobile={imagePositionOnMobile}
/>
)}
{showTextOverlay && (
<div css={textOverlayStyles}>
{!!kicker && (
Expand Down

0 comments on commit cc3680c

Please sign in to comment.