Skip to content

Commit cbe9a11

Browse files
Merge pull request #81 from sp9324/master
added slider for games
2 parents 57b40e6 + 6b4488c commit cbe9a11

File tree

7 files changed

+251
-131
lines changed

7 files changed

+251
-131
lines changed

package-lock.json

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"react-router": "^6.17.0",
1616
"react-router-dom": "^6.17.0",
1717
"react-scripts": "5.0.1",
18+
"react-slick": "^0.30.2",
19+
"slick-carousel": "^1.8.1",
1820
"web-vitals": "^2.1.4"
1921
},
2022
"scripts": {

src/App.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {Games} from "./pages/Games";
55
import {Activities} from "./pages/Activities";
66
import {activities, games} from "./data/content";
77
import {Navbar} from './components/common/Navbar';
8+
import "slick-carousel/slick/slick.css";
9+
import "slick-carousel/slick/slick-theme.css";
10+
811

912
function App() {
1013
return (

src/components/Home/CardItem.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ const CardItem = (props) => {
1010
height: '100%',
1111
};
1212

13+
const cardStyle = {
14+
width: '500px',
15+
margin: '20px'
16+
};
17+
1318
return (
1419
<div className="col-md-4 col-sm-6 mb-4">
15-
<div class="card container-fluid">
20+
<div class="card container-fluid" style={cardStyle}>
1621
<div className="card-image">
1722
<img
1823
className="card-img-top"

src/pages/home/Cards.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
11
import React from 'react'
22
import CardItem from '../../components/Home/CardItem'
3-
// import "../../styles/pages/Home/Cards.css"
3+
import Slider from 'react-slick';
4+
import "../../styles/pages/Home/Cards.css"
45
import Wordle from "../../assets/games/Wordle/wordlejpg.png"
56
import flagGame from "../../assets/games/flag guess/flagger.png"
67
import magicSquare from "../../assets/numberblocks.png"
78

89
const Cards = () => {
9-
return (
10+
// Slick settings for the carousel
11+
const settings = {
12+
dots: true,
13+
infinite: true,
14+
speed: 500,
15+
slidesToShow: 3, // Number of cards to show at once
16+
slidesToScroll: 1,
17+
responsive: [
18+
{
19+
breakpoint: 1024,
20+
settings: {
21+
slidesToShow: 2,
22+
slidesToScroll: 1,
23+
infinite: true,
24+
dots: true
25+
}
26+
},
27+
{
28+
breakpoint: 600,
29+
settings: {
30+
slidesToShow: 1,
31+
slidesToScroll: 1,
32+
}
33+
}
34+
]
35+
};
1036

37+
return (
1138
<div className='container'>
12-
<div className='row justify-content-center'>
13-
39+
<Slider {...settings}>
1440
<CardItem
1541
src={Wordle}
1642
text="Wordle Game"
@@ -59,8 +85,7 @@ const Cards = () => {
5985
label="Search Words"
6086
path='/activities/search-any-word'
6187
title='Search Words' />
62-
63-
</div>
88+
</Slider>
6489
</div>
6590
)
6691
}

src/styles/pages/Home/CardItem.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
.card-image{
2-
width: 100%;
2+
width: 266px;
33
height: 35vh;
44
display: flex;
55
justify-content: center;
66
overflow: hidden;
77
/* padding: 0 !important; */
88
}
99
.card-body{
10-
width: 100%;
10+
width: 266px;
1111
height: 22vh;
1212
display: flex;
1313
flex-direction: column;

0 commit comments

Comments
 (0)