Skip to content

Commit a977b21

Browse files
committed
Show native subtitles when the video is fullscreen
1 parent 143ea31 commit a977b21

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

dotcom-rendering/src/components/SelfHostedVideoPlayer.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { css } from '@emotion/react';
2-
import {
3-
space,
4-
textSans15,
5-
textSans17,
6-
textSans20,
7-
} from '@guardian/source/foundations';
2+
import { space } from '@guardian/source/foundations';
83
import type { IconProps } from '@guardian/source/react-components';
94
import type { ReactElement, SyntheticEvent } from 'react';
105
import { forwardRef } from 'react';
@@ -38,15 +33,21 @@ const interactiveStyles = css`
3833
cursor: pointer;
3934
`;
4035

41-
const subtitleStyles = (subtitleSize: SubtitleSize | undefined) => css`
36+
const nativeSubtitleStyles = css`
4237
::cue {
4338
/* Hide the cue by default as we prefer custom overlay */
4439
visibility: hidden;
45-
4640
color: ${palette('--video-subtitle-text')};
47-
${subtitleSize === 'small' && textSans15};
48-
${subtitleSize === 'medium' && textSans17};
49-
${subtitleSize === 'large' && textSans20};
41+
}
42+
43+
/* Display the native cues when in fullscreen */
44+
45+
&:fullscreen::cue {
46+
visibility: visible;
47+
}
48+
49+
&:-webkit-full-screen::cue {
50+
visibility: visible;
5051
}
5152
`;
5253

@@ -206,7 +207,7 @@ export const SelfHostedVideoPlayer = forwardRef(
206207
css={[
207208
videoStyles(aspectRatio),
208209
isInteractive && interactiveStyles,
209-
showSubtitles && subtitleStyles(subtitleSize),
210+
showSubtitles && nativeSubtitleStyles,
210211
]}
211212
crossOrigin="anonymous"
212213
ref={ref}

0 commit comments

Comments
 (0)