Skip to content

Commit 89811ac

Browse files
Merge pull request #103 from Web-Dev-Path/feature/implement-slider
2 parents 31fbf25 + 3e06b79 commit 89811ac

File tree

6 files changed

+76
-21
lines changed

6 files changed

+76
-21
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2525
- Header.js component
2626
- reCAPTCHA
2727
- useIntersect Hook, Reveal container for scrolling using intersection API
28+
- A new swipable feature on CardColumns.js
2829

2930
### Fixed
3031

@@ -37,3 +38,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3738
- installed yarn
3839
- normalized buttons' and links' styling
3940
- updated `package.json` commands for macOs
41+
42+

components/CardsColumns.js

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import { Swiper, SwiperSlide } from 'swiper/react';
2+
import { Pagination, Navigation } from 'swiper';
3+
import 'swiper/css';
4+
import "swiper/css/pagination";
5+
import "swiper/css/navigation";
6+
17
import Card from './Card';
28
import Container from './Container';
39
import styles from '../styles/CardsColumns.module.scss';
@@ -11,22 +17,42 @@ export default function CardsColumns({
1117
linkText,
1218
}) {
1319
return (
14-
<Container>
15-
<div className={styles.inner__content}>
16-
{titles.map((title, index) => {
17-
return (
18-
<Card
19-
title={title}
20-
image={images[index]}
21-
altTag={altTags[index]}
22-
content={content[index]}
23-
link={links[index]}
24-
linkText={linkText[index]}
25-
key={index}
26-
/>
27-
);
28-
})}
29-
</div>
30-
</Container>
20+
<Container>
21+
<Swiper className={styles.swiper}
22+
mousewheel={true}
23+
grabCursor={true}
24+
modules={[Pagination]}
25+
pagination
26+
centerInsufficientSlides={true}
27+
slidesPerView={1.09}
28+
breakpoints={{
29+
769: {
30+
slidesPerView: 2,
31+
spaceBetween: 50,
32+
},
33+
1334: {
34+
slidesPerView: 3,
35+
spaceBetween: 50,
36+
}
37+
}}
38+
>
39+
{titles.map((title, index) =>
40+
<SwiperSlide key={index} className={styles.swiperSlide}>
41+
<div className={styles.inner__content}>
42+
<Card
43+
title={title}
44+
image={images[index]}
45+
altTag={altTags[index]}
46+
content={content[index]}
47+
link={links[index]}
48+
linkText={linkText[index]}
49+
key={index}
50+
/>
51+
</div>
52+
</SwiperSlide>
53+
)}
54+
55+
</Swiper>
56+
</Container>
3157
);
3258
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"react-dom": "17.0.1",
1818
"react-google-recaptcha": "^2.1.0",
1919
"react-mailchimp-subscribe": "^2.1.3",
20-
"sass": "^1.35.1"
20+
"sass": "^1.35.1",
21+
"swiper": "^8.2.2"
2122
}
2223
}

styles/Card.module.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
border-radius: 1.5rem;
88
box-shadow: $box-shadow;
99
min-width: 32%;
10+
height: 37rem;
1011

1112
@include desktop {
12-
flex-basis: 32%;
13+
1314
margin: 1.5rem 1.5rem 0 1.5rem;
1415

1516
&:first-child,

styles/CardsColumns.module.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33

44
.inner__content {
55
margin: 0 auto;
6-
padding-bottom: 12rem;
6+
padding-bottom: 4rem;
77
justify-content: center;
88

99
@include desktop-breakpoint-plus {
1010
display: flex;
1111
}
1212

1313
@include desktop-breakpoint-minus {
14-
padding-bottom: 5rem;
14+
padding-bottom: 1rem;
1515
}
1616
}
17+
18+
.swiper{
19+
margin-bottom: 6rem;
20+
}

yarn.lock

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ debug@^2.1.3:
114114
dependencies:
115115
ms "2.0.0"
116116

117+
dom7@^4.0.4:
118+
version "4.0.4"
119+
resolved "https://registry.yarnpkg.com/dom7/-/dom7-4.0.4.tgz#8b68c5d8e5e2ed0fddb1cb93e433bc9060c8f3fb"
120+
integrity sha512-DSSgBzQ4rJWQp1u6o+3FVwMNnT5bzQbMb+o31TjYYeRi05uAcpF8koxdfzeoe5ElzPmua7W7N28YJhF7iEKqIw==
121+
dependencies:
122+
ssr-window "^4.0.0"
123+
117124
fill-range@^7.0.1:
118125
version "7.0.1"
119126
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
@@ -340,11 +347,24 @@ scheduler@^0.20.1:
340347
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
341348
integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==
342349

350+
ssr-window@^4.0.0, ssr-window@^4.0.2:
351+
version "4.0.2"
352+
resolved "https://registry.yarnpkg.com/ssr-window/-/ssr-window-4.0.2.tgz#dc6b3ee37be86ac0e3ddc60030f7b3bc9b8553be"
353+
integrity sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ==
354+
343355
344356
version "5.0.1"
345357
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-5.0.1.tgz#78fecbbad2bf95ce6cd981a08918ce4696f5fc80"
346358
integrity sha512-+PIZ/6Uk40mphiQJJI1202b+/dYeTVd9ZnMPR80pgiWbjIwvN2zIp4r9et0BgqBuShh48I0gttPlAXA7WVvBxw==
347359

360+
swiper@^8.2.2:
361+
version "8.2.2"
362+
resolved "https://registry.yarnpkg.com/swiper/-/swiper-8.2.2.tgz#d16e9d92ec9b5548399c06f2cda9c400f9f32352"
363+
integrity sha512-t7Tts4ZD2ahM3InsHDlZ6YY4gi47zepGHx25cACd6fzgcVdAtYLbUihnEmck0HsDzqtkhciyfKsoUEhummZDEA==
364+
dependencies:
365+
dom7 "^4.0.4"
366+
ssr-window "^4.0.2"
367+
348368
to-querystring@^1.0.4:
349369
version "1.1.1"
350370
resolved "https://registry.yarnpkg.com/to-querystring/-/to-querystring-1.1.1.tgz#98de5b00c79768a98ca48a2c09a960238d960265"

0 commit comments

Comments
 (0)