-
Notifications
You must be signed in to change notification settings - Fork 0
/
Steps.tsx
105 lines (99 loc) · 3.2 KB
/
Steps.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"use client";
import { cn } from "@/lib/utils";
import { usePathname } from "next/navigation";
const STEPS = [
{
name: "Step 1: Add Image",
description: "Choose an Image for your case",
url: "/upload",
},
{
name: "Step 2: Customize the Design",
description: "Customize the design of your case",
url: "/design",
},
{
name: "Step 3: Summary",
description: "Review your final design",
url: "/preview",
},
];
export const StepperComponent = () => {
const pathname = usePathname();
return (
<ol className="rounded-md bg-white lg:flex lg:rounded-none lg:border-l lg:border-r lg:border-gray-200">
{STEPS.map((step, i) => {
const isActive = pathname.endsWith(step.url);
const isCompleted = STEPS.slice(i + 1).some((step) =>
pathname.endsWith(step.url)
);
const imgPath = `/snake-${i + 1}.png`;
return (
<li key={step.name} className="relative overflow-hidden lg:flex-1">
<div>
<span
className={cn(
"absolute left-0 top-0 h-full w-1 bg-zinc-400 lg:bottom-0 lg:top-auto lg:h-1 lg:w-full",
{
"bg-zinc-700": isActive,
"bg-primary": isCompleted,
}
)}
aria-hidden="true"
/>
<span
className={cn(
i !== 0 ? "lg:pl-9" : "",
"flex items-center px-6 py-4 text-sm font-medium"
)}
>
<span className="flex-shrink-0">
<img
className={cn(
"flex h-20 w-20 object-contain items-center justify-center",
{
"border-none": isCompleted,
"border-zinc-700": isActive,
}
)}
src={imgPath}
alt="img"
/>
</span>
<span className="ml-4 h-full mt-0.5 flex min-w-0 flex-col justify-center">
<span
className={cn("text-sm font-semibold text-zinc-700", {
"text-primary": isCompleted,
"text-zinc-700": isActive,
})}
>
{step.name}
</span>
<span className="text-sm text-zinc-500">
{step.description}
</span>
</span>
</span>
{i !== 0 ? (
<div className="absolute inset-0 hidden w-3 lg:block">
<svg
className="h-full w-full text-gray-300"
viewBox="0 0 12 82"
fill="none"
preserveAspectRatio="none"
>
<path
d="M0.5 0V31L10.5 41L0.5 51V82"
stroke="currentcolor"
vectorEffect="non-scaling-stroke"
/>
</svg>
</div>
) : null}
</div>
</li>
);
})}
</ol>
);
};