File size: 3,788 Bytes
f5071ca |
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
import React from 'react'
import './VideoModal.css'
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faTimes } from '@fortawesome/free-solid-svg-icons'
import Modal from 'react-modal'
import { getSeasonsOrMovieLength } from 'utils/time'
import { faPlay, faPlus } from '@fortawesome/free-solid-svg-icons'
import Button from 'components/UI/Button/Button'
import useHoverStyleButton from 'hooks/useHoverStyleButton'
if (process.env.NODE_ENV !== 'test') {
Modal.setAppElement('#root');
}
// Don't move this to css; it has to be here for the shouldCloseOnOverlay prop to work
const overlayStyle = {
overlay: {
backgroundColor: 'rgba(17,17,17,0.7)'
}
}
const VideoModal = props => {
const { videoDetailModal, closeModalHandler, videoInfo } = props
const [buttonHovered, onButtonHoverHandler] = useHoverStyleButton({
'playButton': true,
'plusButton': true
})
const {
vote_average, seasons, runtime,
backdrop_path, poster_path, title, name,
release_date, first_air_date,
overview
} = videoInfo
const voteAverage = vote_average * 10
const voteStyle = { color: voteAverage > 49 ? '#46d369' : 'red' }
const videoTime = getSeasonsOrMovieLength(seasons, runtime)
const styles = {
backgroundImage: `url(https://image.tmdb.org/t/p/original/${backdrop_path || poster_path}`,
backgroundSize: 'cover'
}
return (
<Modal
className="ModalStyles"
style={overlayStyle}
isOpen={videoDetailModal}
contentLabel="Modal is open"
shouldCloseOnOverlayClick
onRequestClose={closeModalHandler}
>
<div className="VideoDetailSection" style={styles}>
<FontAwesomeIcon onClick={closeModalHandler} style={{ color: 'white', float: 'right', padding: '14px', cursor: 'pointer' }}
size="2x"
icon={faTimes}
/>
<div className="shadowedSection">
<h1>{title || name}</h1>
<div className="horizontalStyles">
<span style={voteStyle}>{`Rating: ${voteAverage}%`} </span>
<span>{(release_date || first_air_date).substring(0, 4)} </span>
{videoTime}
</div>
<div className="Overview">{overview}</div>
<div className="horizontalStyles">
<Button
backgroundColor="#fff"
textColor="rgb(24, 24, 24)"
playButton
height="38px"
width="138px"
image
icon={faPlay}
onButtonHover={() => onButtonHoverHandler('playButton')}
hoverStatus={buttonHovered['playButton']}>
Play
</Button>
<Button
backgroundColor="rgba(133, 133, 133, 0.6)"
textColor="white"
height="38px"
width="138px"
playButton
image
icon={faPlus}
onButtonHover={() => onButtonHoverHandler('plusButton')}
hoverStatus={buttonHovered['plusButton']}>
My List
</Button>
</div>
</div>
</div>
</Modal>
)
}
export default React.memo(VideoModal) |