This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Poster.js
77 lines (69 loc) · 1.41 KB
/
Poster.js
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
import React, { useState } from "react";
import styled from "styled-components";
import { Link } from "react-router-dom";
const Container = styled.div``;
const Image = styled.div`
background-image: url(${(props) =>
`https://image.tmdb.org/t/p/w300/${props.bgUrl}`});
height: 200px;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
`;
const Rating = styled.span`
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
line-height: 200px;
text-align: center;
margin: auto;
background-color: rgba(255, 0, 0, 0.5);
color: white;
font-size: 20px;
opacity: 0;
`;
const ImageContainer = styled.div`
position: relative;
&:hover {
${Rating} {
opacity: 1;
}
}
`;
const Title = styled.h5`
font-weight: bold;
margin-top: 5px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;
const Year = styled.small`
font-size: 10px;
color: #d6313d;
`;
const Poster = ({
id,
imageUrl,
title,
rating,
year,
isMovie = false
}) => {
return (
<>
<Link key={id} to={isMovie ? `/movie/${id}` : `/tv/${id}`}>
<Container>
<ImageContainer>
<Image bgUrl={imageUrl} />
<Rating>평점 | {rating}</Rating>
</ImageContainer>
<Title>{title}</Title>
<Year>{year}</Year>
</Container>
</Link>
</>
);
};
export default Poster;