-
Notifications
You must be signed in to change notification settings - Fork 1
/
Movie.tsx
62 lines (53 loc) · 1.5 KB
/
Movie.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
55
56
57
58
59
60
61
62
import React from 'react'
import { Link } from 'react-router-dom'
import { MovieType } from '../@types/Movie'
import styled from 'styled-components'
import { useSpring, animated } from 'react-spring'
import NO_POSTER from '../no-poster.jpg'
export const Poster = styled.img`
box-shadow: 0 0 35px black;
`
export const Wrapper = styled.div`
overflow: hidden;
height: 231px;
@media only screen
and (max-width : 750px)
and (max-height : 1334px) {
height: 100%;
}
`
export const POSTER_PATH = 'http://image.tmdb.org/t/p/w154/'
export const BACKDROP_PATH = 'http://image.tmdb.org/t/p/w1280/'
export type Props = {
movie: MovieType;
}
function Movie(props: Props) {
const { movie } = props
const fade = useSpring({
from: {
opacity : 0,
transform: 'translate3d(0,-50px,0)',
},
opacity: 1,
transform: 'translate3d(0,0,0)',
})
if(!movie) return null
const { id, title, poster_path } = movie
const movieId = id
return(
<animated.div style={fade}>
<Wrapper>
<Link to={`/${movieId}`} data-testid="movie-link" className={poster_path ? "" : "posterLinkWrapper"}>
<span className={poster_path ? "visuallyhidden hideElement" : "posterLabel"}>{title}</span>
<Poster
className="mini-poster"
src={poster_path ? `${POSTER_PATH}${poster_path}` : NO_POSTER}
alt={title}
data-testid="movie-img"
/>
</Link>
</Wrapper>
</animated.div>
)
}
export default Movie