forked from ShaneIsrael/fireshare
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisibilityCard.js
More file actions
53 lines (50 loc) · 1.42 KB
/
VisibilityCard.js
File metadata and controls
53 lines (50 loc) · 1.42 KB
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
import React, { useRef } from 'react'
import { useIsVisible } from 'react-is-visible'
import { Grid } from '@mui/material'
import CompactVideoCard from './CompactVideoCard'
const VisibilityCard = ({
video,
openVideo,
handleAlert,
cardWidth,
authenticated,
openDetailsModal,
deleted,
editMode = false,
isSelected = false,
onSelect = () => {},
}) => {
const nodeRef = useRef()
const isVisible = useIsVisible(nodeRef)
const previewVideoHeight =
video.info?.width && video.info?.height ? cardWidth * (video.info.height / video.info.width) : cardWidth / 1.77
return (
<Grid item sx={{ width: cardWidth, ml: 0.75, mr: 0.75, mb: 1.5 }} ref={nodeRef}>
{isVisible ? (
<CompactVideoCard
visible={false}
video={video}
openVideoHandler={openVideo}
alertHandler={handleAlert}
cardWidth={cardWidth}
authenticated={authenticated}
openDetailsModal={openDetailsModal}
deleted={deleted}
editMode={editMode}
isSelected={isSelected}
onSelect={onSelect}
/>
) : (
<div
// calculate the rendered cards height based on the video dimesions and our css styling heights
style={{
width: cardWidth,
background: '#000e393b',
height: previewVideoHeight + 32,
}}
/>
)}
</Grid>
)
}
export default VisibilityCard