This repository was archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathYTVideo.tsx
54 lines (52 loc) · 1.59 KB
/
YTVideo.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Card, CardContent, Link } from '@material-ui/core';
import * as QR from 'avenger/lib/QueryResult';
import { WithQueries } from 'avenger/lib/react';
import React from 'react';
import { oneCreatorVideo } from '../../state/dashboard/creator.queries';
import { getYTVideoURLById, getYTEmbeddingURLById } from '../../utils/yt.utils';
import { ErrorBox } from '@trex/shared/components/Error/ErrorBox';
import { LazyFullSizeLoader } from './FullSizeLoader';
interface YTVideoProps {
videoId: string;
}
export const YTVideo: React.FC<YTVideoProps> = ({ videoId }) => (
<WithQueries
queries={{ oneCreatorVideo }}
params={{ oneCreatorVideo: { params: { videoId } } }}
render={QR.fold(
LazyFullSizeLoader,
ErrorBox,
({ oneCreatorVideo: video }) => (
<Card style={{ boxShadow: 'none', backgroundColor: 'transparent' }}>
<iframe
sandbox="allow-scripts allow-same-origin"
src={getYTEmbeddingURLById(videoId)}
width="100%"
height={315}
style={{
border: 'none',
}}
/>
<CardContent
style={{
paddingLeft: '0px',
paddingTop: '10px',
paddingBottom: '0px',
}}
>
<Link
color="textSecondary"
variant="h5"
href={getYTVideoURLById(videoId)}
rel="noreferrer"
target="_blank"
underline="none"
>
{video.title}
</Link>
</CardContent>
</Card>
)
)}
/>
);