..
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130 | import React from 'react';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
import { Relation } from '../../index';
const SeasonCardContainer = styled.div`
display: flex;
flex-wrap: wrap;
justify-content: left;
gap: 1rem;
margin-top: 1rem;
margin-bottom: 1rem;
@media (max-width: 500px) {
justify-content: center;
}
`;
const SeasonCard = styled(Link)`
background-size: cover;
background-position: center;
padding: 0.9rem;
height: 6rem;
width: 20rem;
@media (max-width: 500px) {
height: 3rem;
width: 8rem;
padding: 1.3rem;
}
position: relative;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
border-radius: 0.3rem;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
overflow: hidden;
cursor: pointer;
text-decoration: none;
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
border-radius: var(--global-border-radius);
z-index: 1;
}
transition: transform 0.2s ease-in-out;
&:hover,
&:active &:focus {
transform: translateY(-5px);
@media (max-width: 500px) {
transform: none;
}
}
`;
const Content = styled.div`
position: relative;
z-index: 2;
`;
const SeasonName = styled.div`
font-size: 0.9rem;
@media (max-width: 500px) {
display: none;
width: 8rem;
font-size: 0.8rem;
}
color: white;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
`;
const RelationType = styled.div`
font-size: 1.3rem;
@media (max-width: 500px) {
font-size: 1.1rem;
width: 8rem;
margin-bottom: 0.25rem;
}
font-weight: bold;
color: white;
border-radius: var(--global-border-radius);
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
margin-bottom: 0.75rem;
`;
export const Seasons: React.FC<{ relations: Relation[] }> = ({ relations }) => {
const sortedRelations = relations.sort((a, b) => {
if (a.relationType === 'PREQUEL' && b.relationType !== 'PREQUEL') {
return -1;
}
if (a.relationType !== 'PREQUEL' && b.relationType === 'PREQUEL') {
return 1;
}
return 0;
});
return (
<SeasonCardContainer>
{sortedRelations.map((relation) => (
<SeasonCard
key={relation.id}
to={`/watch/${relation.id}`}
title={`Watch ${relation.title.english || relation.title.romaji || relation.title.userPreferred}`}
aria-label={`Watch ${relation.title.english || relation.title.romaji || relation.title.userPreferred}`}
style={{ backgroundImage: `url(${relation.image})` }}
>
<img
src={relation.image}
alt={`${relation.title.english || relation.title.romaji || relation.title.userPreferred} Cover`}
style={{ display: 'none' }}
/>
<Content>
<RelationType>{relation.relationType}</RelationType>
<SeasonName>
{relation.title.english ||
relation.title.romaji ||
relation.title.userPreferred}
</SeasonName>
</Content>
</SeasonCard>
))}
</SeasonCardContainer>
);
};
|
|