Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | import React from "react";
import { cn } from "@/lib/utils";
interface ProgressBarProps {
steps: string[];
currentStep: number; // 0-based index
}
export const ProgressBar: React.FC<ProgressBarProps> = ({
steps,
currentStep,
}) => {
return (
<div className="flex items-center w-full mx-auto">
{steps.map((stepLabel, index) => (
<div
key={index}
className="relative flex-1 flex flex-col items-center text-center"
>
{/* Left Connector */}
{index !== 0 && (
<div
className={cn(
"absolute left-0 top-4 h-1 w-1/2 -translate-y-1/2 z-0",
index <= currentStep ? "bg-primary" : "bg-border"
)}
/>
)}
{/* Step Circle */}
<div className="relative z-10">
<div
className={cn(
"w-8 h-8 flex items-center justify-center rounded-full border-2 text-sm font-medium transition-colors",
index < currentStep
? "bg-primary text-white border-primary"
: index === currentStep
? "bg-white text-primary border-primary"
: "bg-muted text-muted-foreground border-border"
)}
>
{index + 1}
</div>
</div>
{/* Step Label */}
<div className="mt-2 text-sm text-muted-foreground">{stepLabel}</div>
{/* Right Connector */}
{index !== steps.length - 1 && (
<div
className={cn(
"absolute right-0 top-4 h-1 w-1/2 -translate-y-1/2 z-0",
index < currentStep ? "bg-primary" : "bg-border"
)}
/>
)}
</div>
))}
</div>
);
};
|