11import { css } from '@emotion/react' ;
22import {
3- space ,
43 textSans15 ,
54 textSans17 ,
65 textSans20 ,
@@ -9,28 +8,50 @@ import { palette } from '../palette';
98import type { SubtitleSize } from './LoopVideoPlayer' ;
109
1110const subtitleOverlayStyles = css `
11+ max-width : 71% ;
12+ pointer-events : none;
1213 position : absolute;
13- left : 0 ;
14- right : 0 ;
15- bottom : ${ space [ 4 ] } px;
16- display : flex;
17- justify-content : center;
14+ bottom : 16px ;
15+ left : 50% ;
16+ transform : translateX (-50% );
17+ ` ;
18+
19+ const cueBoxStyles = css `
20+ width : 100% ;
21+ margin : 0 auto;
22+ text-align : center;
1823 pointer-events : none;
1924` ;
20- const subtitleCueBoxStyles = ( subtitleSize : SubtitleSize ) => css `
21- max-width : 71% ;
22- background-color : rgba (18 , 18 , 18 , 0.7 );
25+
26+ const cueStyles = css `
2327 color : ${ palette ( '--loop-video-subtitle-text' ) } ;
24- ${ subtitleSize === 'small' && textSans15 } ;
25- ${ subtitleSize === 'medium' && textSans17 } ;
26- ${ subtitleSize === 'large' && textSans20 } ;
27- padding: 4px ;
28- text-align : center;
2928 display : inline;
30- box-decoration-break : clone ;
29+ background-color : rgba ( 18 , 18 , 18 , 0.7 ) ;
3130 -webkit-box-decoration-break : clone;
31+ box-decoration-break : clone;
32+ pointer-events : none;
33+ padding : 3px 4px 3px ;
3234` ;
3335
36+ const cueTextStyles = ( subtitleSize : SubtitleSize ) => {
37+ const sizeStyles = {
38+ small : css `
39+ ${ textSans15 } ;
40+ line-height: 24px;
41+ ` ,
42+ medium : css `
43+ ${ textSans17 } ;
44+ line-height: 26px;
45+ ` ,
46+ large : css `
47+ ${ textSans20 } ;
48+ line-height: 30px;
49+ ` ,
50+ } ;
51+
52+ return sizeStyles [ subtitleSize ] ;
53+ } ;
54+
3455export const SubtitleOverlay = ( {
3556 text,
3657 subtitleSize,
@@ -40,7 +61,9 @@ export const SubtitleOverlay = ({
4061} ) => {
4162 return (
4263 < div css = { subtitleOverlayStyles } >
43- < div css = { subtitleCueBoxStyles ( subtitleSize ) } > { text } </ div >
64+ < div css = { cueBoxStyles } >
65+ < div css = { [ cueStyles , cueTextStyles ( subtitleSize ) ] } > { text } </ div >
66+ </ div >
4467 </ div >
4568 ) ;
4669} ;
0 commit comments