Skip to content

Commit f45a4cb

Browse files
committed
Adds Carousel and Serie layout
1 parent 404a733 commit f45a4cb

10 files changed

Lines changed: 124 additions & 28 deletions

File tree

package-lock.json

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@testing-library/jest-dom": "^5.16.2",
88
"@testing-library/react": "^12.1.4",
99
"@testing-library/user-event": "^13.5.0",
10+
"@trendyol-js/react-carousel": "^2.0.1",
1011
"react": "^17.0.2",
1112
"react-dom": "^17.0.2",
1213
"react-router-dom": "^6.2.2",

src/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ function App() {
1818
</BrowserRouter>
1919
);
2020
}
21-
2221
export default App;

src/components/LeagueContainer.jsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/components/SeriesCard.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import PropTypes from 'prop-types';
2+
3+
const SeriesCard = ({ title }) => {
4+
return (
5+
<div className="Series-box">
6+
<h4>{title}</h4>
7+
</div>
8+
);
9+
};
10+
11+
SeriesCard.propTypes = {
12+
title: PropTypes.string
13+
};
14+
15+
export default SeriesCard;

src/components/SeriesContainer.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import PropTypes from 'prop-types';
2+
import SeriesCard from 'components/SeriesCard';
3+
4+
const SeriesContainer = ({ series }) => {
5+
console.log(series);
6+
return (
7+
<div className="Series">
8+
{series &&
9+
series.length &&
10+
series.map((serie, index) => <SeriesCard key={index} title={serie?.full_name ?? ''} />)}
11+
</div>
12+
);
13+
};
14+
15+
SeriesContainer.propTypes = {
16+
series: PropTypes.array
17+
};
18+
19+
export default SeriesContainer;

src/img/LArrow.png

1.8 KB
Loading

src/img/RArrow.png

1.62 KB
Loading

src/pages/GamePage.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,65 @@
11
import 'App.css';
22
import 'style.css';
3-
import LeagueContainer from 'components/LeagueContainer';
3+
import LeagueCard from 'components/LeagueCard';
4+
import { Carousel } from '@trendyol-js/react-carousel';
45
import { useParams } from 'react-router-dom';
56
import { useState, useEffect } from 'react';
67
import { http } from 'http';
8+
import SeriesContainer from 'components/SeriesContainer';
9+
10+
function handleClick() {
11+
window.location.href = '/';
12+
}
713

814
const GamePage = () => {
915
const params = useParams();
1016
const [gameName, setGameName] = useState(params.gameName);
1117
const [leagues, setLeagues] = useState([]);
18+
const [resize, setResize] = useState(window.innerWidth);
1219

1320
useEffect(async () => {
1421
const { leagues: response, name } = await http(
1522
`https://api.pandascore.co/videogames/${params.gameName}`
1623
);
1724
setGameName(name);
1825
setLeagues(
19-
response.map(({ image_url, name }) => {
20-
return { image: image_url, title: name };
26+
response.map(({ image_url, name, series }) => {
27+
return { image: image_url, title: name, series };
2128
})
2229
);
2330
}, []);
31+
useEffect(() => {
32+
function handleResize() {
33+
setResize(window.innerWidth);
34+
}
35+
36+
window.addEventListener('resize', handleResize);
37+
return () => {
38+
window.removeEventListener('resize', handleResize);
39+
};
40+
}, []);
41+
2442
return (
2543
<div>
2644
<div className="sidenav">
2745
<h4 className="sidenav-title">Series</h4>
28-
<button className="Homebtn" onClick={clickFun}>
46+
<button className="Homebtn" onClick={handleClick}>
2947
Home
3048
</button>
49+
<SeriesContainer series={leagues.map(({ series }) => series).flat()} />
3150
</div>
3251
<div className="main">
3352
<h1 className="Title">{gameName.toUpperCase()}</h1>
34-
<LeagueContainer leagues={leagues} />
53+
{leagues.length && !!resize && (
54+
<Carousel className="Carousel" responsive={false} dynamic={false}>
55+
{leagues.map(({ image, title }, index) => (
56+
<LeagueCard key={index} title={title ?? ''} image={image} />
57+
))}
58+
</Carousel>
59+
)}
3560
</div>
3661
</div>
3762
);
3863
};
39-
function clickFun() {
40-
window.location.href = '/';
41-
}
64+
4265
export default GamePage;

src/style.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ h3 {
1313
-webkit-text-stroke-width: 0.5px;
1414
-webkit-text-stroke-color: rgb(255, 255, 255);
1515
}
16+
.Carousel {
17+
border-style: none;
18+
}
19+
20+
.Carousel > div > button[data-direction*='right'],
21+
.Carousel > div > button[data-direction*='left'] {
22+
border-color: #17171b;
23+
cursor: pointer;
24+
margin: 60px 4px 0 4px;
25+
width: 30px;
26+
height: 30px;
27+
background-size: cover;
28+
}
29+
button[data-direction*='left'] {
30+
background: url(img/LArrow.png) no-repeat;
31+
}
32+
button[data-direction*='right'] {
33+
background: url(img/RArrow.png) no-repeat;
34+
}
35+
1636
/* From cssbuttons.io by @nikk7007 */
1737
.Homebtn {
1838
padding: 0.8em 1.8em;
@@ -62,6 +82,23 @@ h3 {
6282
'Open Sans', 'Helvetica Neue', sans-serif;
6383
font-size: 45px;
6484
}
85+
.Series {
86+
height: content;
87+
display: flex;
88+
justify-content: center;
89+
align-content: start;
90+
flex-wrap: wrap;
91+
}
92+
.Series-box {
93+
border-color: #17c3b2;
94+
border-style: solid;
95+
border-width: 2px;
96+
border-radius: 15px;
97+
padding: 0 2px 0 2px;
98+
margin: 4px 2px 4px 2px;
99+
font-size: 14px;
100+
background-color: #108074;
101+
}
65102
.leagues {
66103
height: content;
67104
display: flex;
@@ -82,6 +119,11 @@ h3 {
82119
box-shadow: inset 0 0 0 1000px rgba(0, 0, 0, 0.5);
83120
border-radius: 8px;
84121
}
122+
.league-box:hover {
123+
outline-style: solid;
124+
outline-color: radial-gradient(whitesmoke, #17171b);
125+
box-shadow: none;
126+
}
85127
.games {
86128
height: content;
87129
display: flex;

0 commit comments

Comments
 (0)