Skip to content

Commit c70498f

Browse files
Adjust swipable CardsColumns.js on mobile
1 parent 89811ac commit c70498f

File tree

4 files changed

+51
-52
lines changed

4 files changed

+51
-52
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +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
28+
- swipable feature on CardsColumns.js
2929

3030
### Fixed
3131

@@ -38,5 +38,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3838
- installed yarn
3939
- normalized buttons' and links' styling
4040
- updated `package.json` commands for macOs
41-
42-
41+
- swipable CardsColumns.js on mobile

components/CardsColumns.js

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Swiper, SwiperSlide } from 'swiper/react';
22
import { Pagination, Navigation } from 'swiper';
33
import 'swiper/css';
4-
import "swiper/css/pagination";
5-
import "swiper/css/navigation";
6-
4+
import 'swiper/css/pagination';
5+
import 'swiper/css/navigation';
76
import Card from './Card';
87
import Container from './Container';
98
import styles from '../styles/CardsColumns.module.scss';
@@ -17,42 +16,42 @@ export default function CardsColumns({
1716
linkText,
1817
}) {
1918
return (
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>
19+
<Container>
20+
<Swiper
21+
className={styles.swiper}
22+
mousewheel={true}
23+
grabCursor={true}
24+
modules={[Pagination]}
25+
pagination
26+
centerInsufficientSlides={true}
27+
slidesPerView={1}
28+
breakpoints={{
29+
768: {
30+
slidesPerView: 2,
31+
spaceBetween: 20,
32+
},
33+
1334: {
34+
slidesPerView: 3,
35+
spaceBetween: 20,
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+
</Swiper>
55+
</Container>
5756
);
5857
}

styles/Card.module.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@
22
@use './mixins' as *;
33

44
.card {
5-
margin: 1.5rem 0;
5+
margin: 1rem 1rem 0 .5rem;
66
padding: 1.5rem;
77
border-radius: 1.5rem;
88
box-shadow: $box-shadow;
99
min-width: 32%;
1010
height: 37rem;
1111

1212
@include desktop {
13-
1413
margin: 1.5rem 1.5rem 0 1.5rem;
15-
1614
&:first-child,
1715
&:last-child {
18-
margin: 1.5rem 0 0 0;
16+
margin: 1.5rem .5rem 0 .5rem;
1917
}
2018
}
2119

styles/CardsColumns.module.scss

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
@include desktop-breakpoint-plus {
1010
display: flex;
1111
}
12+
}
13+
14+
.swiper {
15+
margin-bottom: 5rem;
1216

13-
@include desktop-breakpoint-minus {
14-
padding-bottom: 1rem;
17+
:global(.swiper-pagination-bullet-active) {
18+
background-color: $dark-bg-color;
1519
}
20+
1621
}
1722

18-
.swiper{
19-
margin-bottom: 6rem;
20-
}
23+

0 commit comments

Comments
 (0)