Skip to content

Commit 4b4161c

Browse files
committed
feat: useBreakpointValues for slidesPerView
1 parent 00a363e commit 4b4161c

File tree

2 files changed

+45
-27
lines changed

2 files changed

+45
-27
lines changed

app/[locale]/enterprise/_components/CasesSwiper.tsx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,29 @@ import type { Case } from "../types"
66

77
import CaseCard from "./CaseCard"
88

9-
const CasesSwiper = ({ cases }: { cases: Case[] }) => (
10-
<Swiper spaceBetween={8} slidesPerView={1.2}>
11-
{cases.map((caseStudy) => (
12-
<SwiperSlide
13-
key={caseStudy.name}
14-
className="first:ms-4 [&:last-child_div]:w-[calc(100%-2rem)]"
15-
>
16-
<CaseCard
17-
caseStudy={caseStudy}
18-
className="h-full w-full !shadow-none"
19-
/>
20-
</SwiperSlide>
21-
))}
22-
</Swiper>
23-
)
9+
import { useBreakpointValue } from "@/hooks/useBreakpointValue"
10+
11+
const CasesSwiper = ({ cases }: { cases: Case[] }) => {
12+
const slidesPerView = useBreakpointValue({
13+
base: 1.2,
14+
sm: 2.4,
15+
})
16+
17+
return (
18+
<Swiper spaceBetween={8} slidesPerView={slidesPerView}>
19+
{cases.map((caseStudy) => (
20+
<SwiperSlide
21+
key={caseStudy.name}
22+
className="first:ms-4 [&:last-child_div]:w-[calc(100%-2rem)]"
23+
>
24+
<CaseCard
25+
caseStudy={caseStudy}
26+
className="h-full w-full !shadow-none"
27+
/>
28+
</SwiperSlide>
29+
))}
30+
</Swiper>
31+
)
32+
}
2433

2534
export default CasesSwiper

app/[locale]/enterprise/_components/FeaturesSwiper.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,26 @@ import type { Feature } from "../types"
66

77
import FeatureCard from "./FeatureCard"
88

9-
const FeaturesSwiper = ({ features }: { features: Feature[] }) => (
10-
<Swiper spaceBetween={8} slidesPerView={1.1}>
11-
{features.map((feature) => (
12-
<SwiperSlide
13-
key={feature.header}
14-
className="first:ms-4 [&:last-child_div]:me-8"
15-
>
16-
<FeatureCard feature={feature} className="h-full !shadow-none" />
17-
</SwiperSlide>
18-
))}
19-
</Swiper>
20-
)
9+
import { useBreakpointValue } from "@/hooks/useBreakpointValue"
10+
11+
const FeaturesSwiper = ({ features }: { features: Feature[] }) => {
12+
const slidesPerView = useBreakpointValue({
13+
base: 1.1,
14+
sm: 1.5,
15+
})
16+
17+
return (
18+
<Swiper spaceBetween={8} slidesPerView={slidesPerView}>
19+
{features.map((feature) => (
20+
<SwiperSlide
21+
key={feature.header}
22+
className="first:ms-4 [&:last-child_div]:me-8"
23+
>
24+
<FeatureCard feature={feature} className="h-full !shadow-none" />
25+
</SwiperSlide>
26+
))}
27+
</Swiper>
28+
)
29+
}
2130

2231
export default FeaturesSwiper

0 commit comments

Comments
 (0)