Skip to content
Open
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
14 changes: 9 additions & 5 deletions dotcom-rendering/src/components/SelfHostedVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ import { VideoProgressBar } from './VideoProgressBar';

export type SubtitleSize = 'small' | 'medium' | 'large';

const videoStyles = (aspectRatio: number) => css`
const videoStyles = (aspectRatio: number, isCinemagraph: boolean) => css`
position: relative;
display: block;
height: auto;
width: 100%;
cursor: pointer;
${!isCinemagraph &&
css`
cursor: pointer;
`}

/* Prevents CLS by letting the browser know the space the video will take up. */
aspect-ratio: ${aspectRatio};
Expand Down Expand Up @@ -171,12 +174,13 @@ export const SelfHostedVideoPlayer = forwardRef(
}: Props,
ref: React.ForwardedRef<HTMLVideoElement>,
) => {
const isCinemagraph = videoStyle === 'Cinemagraph';
const videoId = `video-${uniqueId}`;
const showSubtitles =
videoStyle !== 'Cinemagraph' && !!subtitleSource && !!subtitleSize;
!isCinemagraph && !!subtitleSource && !!subtitleSize;

const showControls =
videoStyle !== 'Cinemagraph' &&
!isCinemagraph &&
ref &&
'current' in ref &&
ref.current &&
Expand All @@ -194,7 +198,7 @@ export const SelfHostedVideoPlayer = forwardRef(
<video
id={videoId}
css={[
videoStyles(aspectRatio),
videoStyles(aspectRatio, isCinemagraph),
showSubtitles && subtitleStyles(subtitleSize),
]}
crossOrigin="anonymous"
Expand Down
Loading