Skip to content

Commit cd687c7

Browse files
committed
feat: add Cases swiper/case/loaders
use hanging cards
1 parent bac9141 commit cd687c7

File tree

9 files changed

+124
-49
lines changed

9 files changed

+124
-49
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Skeleton } from "@/components/ui/skeleton"
2+
3+
const SwiperHangerLoading = () => (
4+
<div className="flex w-full gap-2">
5+
<Skeleton className="ms-4 h-80 w-[85vw] shrink-0 rounded-4xl" />
6+
<Skeleton className="h-full w-full rounded-e-none rounded-s-4xl" />
7+
</div>
8+
)
9+
10+
export default SwiperHangerLoading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Card } from "@/components/ui/card"
2+
3+
import { cn } from "@/lib/utils/cn"
4+
5+
import type { Case } from "../types"
6+
7+
type CaseCardProps = {
8+
caseStudy: Case
9+
className?: string
10+
}
11+
12+
const CaseCard = ({
13+
caseStudy: { name, content },
14+
className,
15+
}: CaseCardProps) => (
16+
<Card
17+
className={cn(
18+
"space-y-1 rounded-4xl border bg-background p-6 shadow-window-box",
19+
className
20+
)}
21+
>
22+
<h3 className="text-xl">{name}</h3>
23+
<p className="text-body-medium">{content}</p>
24+
</Card>
25+
)
26+
27+
export default CaseCard
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { cn } from "@/lib/utils/cn"
2+
3+
import type { Case } from "../types"
4+
5+
import CaseCard from "./CaseCard"
6+
7+
const CasesColumn = ({
8+
cases,
9+
className,
10+
}: {
11+
cases: Case[]
12+
className?: string
13+
}) => (
14+
<div className={cn("flex w-full flex-col gap-4", className)}>
15+
{cases.map((caseStudy) => (
16+
<CaseCard key={caseStudy.name} caseStudy={caseStudy} />
17+
))}
18+
</div>
19+
)
20+
21+
export default CasesColumn
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"use client"
2+
3+
import { Swiper, SwiperSlide } from "@/components/ui/swiper"
4+
5+
import type { Case } from "../types"
6+
7+
import CaseCard from "./CaseCard"
8+
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+
)
24+
25+
export default CasesSwiper

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ const IconComponents = {
3030
type IconComponent = keyof typeof IconComponents
3131

3232
const FeatureCard = ({
33-
header,
34-
content,
35-
iconName,
33+
feature: { header, content, iconName },
3634
className,
37-
}: Feature & { className?: string }) => {
35+
}: {
36+
feature: Feature
37+
className?: string
38+
}) => {
3839
const Icon = IconComponents[iconName as IconComponent]
3940
return (
4041
<Card

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,14 @@ import type { Feature } from "../types"
66

77
import FeatureCard from "./FeatureCard"
88

9-
const FeaturesSwiper = ({
10-
features,
11-
className,
12-
}: {
13-
features: Feature[]
14-
className?: string
15-
}) => (
16-
<Swiper className={className} spaceBetween={8} slidesPerView={1.1}>
9+
const FeaturesSwiper = ({ features }: { features: Feature[] }) => (
10+
<Swiper spaceBetween={8} slidesPerView={1.1}>
1711
{features.map((feature) => (
1812
<SwiperSlide
1913
key={feature.header}
2014
className="first:ms-4 [&:last-child_div]:me-8"
2115
>
22-
<FeatureCard {...feature} className="h-full !shadow-none" />
16+
<FeatureCard feature={feature} className="h-full !shadow-none" />
2317
</SwiperSlide>
2418
))}
2519
</Swiper>

app/[locale]/enterprise/page.tsx

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,46 +37,28 @@ import Walmart from "@/components/icons/enterprise/walmart.svg"
3737
import WFP from "@/components/icons/enterprise/wfp.svg"
3838
import MainArticle from "@/components/MainArticle"
3939
import { ButtonLink } from "@/components/ui/buttons/Button"
40-
import { Card } from "@/components/ui/card"
4140
import { Skeleton } from "@/components/ui/skeleton"
4241

4342
import { cn } from "@/lib/utils/cn"
4443
import { getMetadata } from "@/lib/utils/metadata"
4544

45+
import CasesColumn from "./_components/CasesColumn"
4646
import FeatureCard from "./_components/FeatureCard"
47-
import type { Case, Feature } from "./types"
47+
import SwiperHangerLoading from "./SwiperHangerLoading"
48+
import type { Case, EcosystemPlayer, Feature } from "./types"
4849

4950
import EthGlyph from "@/public/images/assets/svgs/eth-diamond-rainbow.svg"
5051
import heroImage from "@/public/images/heroes/enterprise-hero-white.png"
5152

5253
const FeaturesSwiper = dynamic(() => import("./_components/FeaturesSwiper"), {
53-
ssr: false,
54-
loading: () => (
55-
<div className="flex w-full gap-2">
56-
<Skeleton className="ms-4 h-80 w-[85vw] shrink-0 rounded-4xl" />
57-
<Skeleton className="h-full w-full rounded-e-none rounded-s-4xl" />
58-
</div>
59-
),
54+
// ssr: false,
55+
loading: () => <SwiperHangerLoading />,
56+
})
57+
58+
const CasesSwiper = dynamic(() => import("./_components/CasesSwiper"), {
59+
// ssr: false,
60+
loading: () => <SwiperHangerLoading />,
6061
})
61-
const CasesColumn = ({
62-
cases,
63-
className,
64-
}: {
65-
cases: Case[]
66-
className?: string
67-
}) => (
68-
<div className={cn("flex w-full flex-col gap-4", className)}>
69-
{cases.map(({ name, content }) => (
70-
<Card
71-
key={name}
72-
className="space-y-1 rounded-4xl border bg-background p-6 shadow-window-box"
73-
>
74-
<h3 className="text-xl">{name}</h3>
75-
<p className="text-body-medium">{content}</p>
76-
</Card>
77-
))}
78-
</div>
79-
)
8062

8163
const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
8264
const { locale } = await params
@@ -180,12 +162,6 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
180162
},
181163
]
182164

183-
type EcosystemPlayer = {
184-
name: string
185-
Logo: React.FC<React.SVGProps<SVGElement>>
186-
className?: string
187-
}
188-
189165
const players: EcosystemPlayer[] = [
190166
{ name: "Adidas", Logo: Adidas, className: "scale-105 origin-bottom" },
191167
{ name: "Azure", Logo: Azure, className: "-translate-y-1" },
@@ -282,11 +258,12 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
282258
<div className="-mx-4 -my-6 flex py-6 md:hidden">
283259
<FeaturesSwiper features={features} />
284260
</div>
261+
285262
<div className="grid grid-cols-1 gap-2 max-md:hidden sm:grid-cols-2 md:gap-6 xl:grid-cols-4">
286263
{features.map((feature) => (
287264
<FeatureCard
288265
key={feature.header}
289-
{...feature}
266+
feature={feature}
290267
className="h-full"
291268
/>
292269
))}
@@ -343,9 +320,21 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
343320
</div>
344321
))}
345322
</div>
323+
324+
<div
325+
className="w-screen ring ring-offset-[-2px]"
326+
style={{
327+
mask: `linear-gradient(to right, transparent 1rem, white 2rem, white calc(100% - 2rem), transparent calc(100% - 1rem)`,
328+
}}
329+
>
330+
<div className="-my-6 flex px-4 py-6 md:hidden">
331+
<CasesSwiper cases={cases} />
332+
</div>
333+
</div>
334+
346335
<div
347336
data-label="case-studies"
348-
className="grid w-full max-w-screen-lg grid-cols-1 gap-4 px-4 md:grid-cols-3 md:px-6"
337+
className="grid w-full max-w-screen-lg grid-cols-1 gap-4 px-4 max-md:hidden md:grid-cols-3 md:px-6"
349338
>
350339
<CasesColumn cases={cases.slice(0, 2)} />
351340
<CasesColumn cases={cases.slice(2, 4)} />

app/[locale]/enterprise/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ export type Feature = {
88
content: string[]
99
iconName: string
1010
}
11+
12+
export type EcosystemPlayer = {
13+
name: string
14+
Logo: React.FC<React.SVGProps<SVGElement>>
15+
className?: string
16+
}

src/components/ui/swiper.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client"
2+
13
import * as React from "react"
24
import { cva, VariantProps } from "class-variance-authority"
35
import { EffectCards, Keyboard, Navigation, Pagination } from "swiper/modules"

0 commit comments

Comments
 (0)