Skip to content

Commit 117c8a0

Browse files
committed
fix cards justify when less than 3 cards
1 parent e7fad62 commit 117c8a0

File tree

5 files changed

+55
-46
lines changed

5 files changed

+55
-46
lines changed

components/containers/CardsColumns.js

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,41 @@ import styles from '@/styles/CardsColumns.module.scss';
1010
export default function CardsColumns({ cards, customClass }) {
1111
return (
1212
<Container>
13-
<Swiper
14-
className={styles.swiper}
15-
mousewheel={true}
16-
grabCursor={true}
17-
modules={[Pagination]}
18-
pagination
19-
centerInsufficientSlides={false}
20-
slidesPerView={1}
21-
breakpoints={{
22-
768: {
23-
slidesPerView: 2,
24-
spaceBetween: 20,
25-
},
26-
1334: {
27-
slidesPerView: cards.length,
28-
spaceBetween: cards.length < 3 ? 75 : 20,
29-
},
30-
}}
13+
<div
14+
className={
15+
customClass
16+
? `${styles.cardColumns} ${styles[customClass]}`
17+
: styles.cardColumns
18+
}
3119
>
32-
{cards.map((card, index) => (
33-
<SwiperSlide key={index} className={styles.swiperSlide}>
34-
<div className={styles.inner__content}>
35-
<Card key={index} card={card} customClass={customClass} />
36-
</div>
37-
</SwiperSlide>
38-
))}
39-
</Swiper>
20+
<Swiper
21+
className={styles.swiper}
22+
mousewheel={true}
23+
grabCursor={true}
24+
modules={[Pagination]}
25+
pagination
26+
centerInsufficientSlides={false}
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+
{cards.map((card, index) => (
40+
<SwiperSlide key={index} className={styles.swiperSlide}>
41+
<div className={styles.inner__content}>
42+
<Card key={index} card={card} customClass={customClass} />
43+
</div>
44+
</SwiperSlide>
45+
))}
46+
</Swiper>
47+
</div>
4048
</Container>
4149
);
4250
}

pages/blog/category/[tag].js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default function BlogCategory({ posts }) {
1010
posts={posts}
1111
swipe={false}
1212
heading={tagToHeading[tag]}
13+
viewall={false}
1314
/>
1415
);
1516
}

pages/blog/category/all.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import BlogPostsContainer from '@/components/blog/BlogPostsContainer';
22

33
export default function BlogCategory({ posts }) {
4-
// TODO: Temporary, to show more posts
5-
posts = posts.concat(posts).concat(posts);
6-
74
return (
85
<BlogPostsContainer
96
posts={posts}

styles/Card.module.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120

121121
@include desktop {
122122
min-width: 25%;
123+
max-width: 18.75rem;
123124
}
124125

125126
.card__image {
@@ -133,8 +134,8 @@
133134
overflow: hidden;
134135
}
135136

136-
&.swiper-wrapper {
137-
justify-content: flex-start;
137+
.swiper-wrapper {
138+
justify-content: flex-end;
138139
}
139140
}
140141

styles/CardsColumns.module.scss

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
@use './variables' as *;
22
@use './mixins' as *;
33

4-
.inner__content {
5-
margin: 0 auto;
6-
padding-bottom: 4rem;
7-
justify-content: center;
4+
.cardColumns {
5+
.inner__content {
6+
margin: 0 auto;
7+
padding-bottom: 4rem;
8+
justify-content: center;
89

9-
@include desktop-breakpoint-plus {
10-
display: flex;
10+
@include desktop-breakpoint-plus {
11+
display: flex;
12+
}
1113
}
12-
}
1314

14-
.swiper {
15-
margin-bottom: 5rem;
16-
padding: 0 1rem;
15+
.swiper {
16+
margin-bottom: 5rem;
17+
padding: 0 1rem;
1718

18-
:global(.swiper-pagination-bullet-active) {
19-
background-color: $dark-bg-color;
19+
:global(.swiper-pagination-bullet-active) {
20+
background-color: $dark-bg-color;
21+
}
2022
}
21-
}
2223

23-
.swiperSlide {
24-
max-width: 34.375rem;
24+
.swiperSlide {
25+
max-width: 34.375rem;
26+
}
2527
}

0 commit comments

Comments
 (0)