import React, { useRef } from "react"; import { cn } from "@/lib/utils"; import { Check } from "lucide-react"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; interface Step { number: number; label: string; } interface StepperProps { steps: Step[]; currentStep: number; onStepClick: (stepNumber: number) => void; } const Stepper: React.FC = ({ steps, currentStep, onStepClick, }) => { const scrollAreaRef = useRef(null); const scrollToCurrentStep = (stepIndex: number) => { const scrollArea = scrollAreaRef.current; if (scrollArea && scrollArea.children.length) { const stepElement = scrollArea.children[stepIndex] as HTMLElement; if (stepElement) { stepElement.scrollIntoView({ behavior: "smooth", block: "center", inline: "center", }); } } }; React.useEffect(() => { scrollToCurrentStep(currentStep - 1); }, [currentStep]); return (
{steps.map((step, index) => (
onStepClick(step.number)} className={cn( "w-10 h-10 rounded-full flex items-center justify-center text-sm font-bold cursor-pointer transform-gpu", step.number === currentStep ? "bg-primary text-primary-foreground shadow-sm" : step.number < currentStep ? "bg-primary text-primary-foreground" : "bg-secondary text-secondary-foreground" )} // style={{ // backfaceVisibility: 'hidden' // }} > {step.number < currentStep ? ( ) : ( step.number )}
{step.label}
{index < steps.length - 1 && (
)}
))}
); }; export default Stepper;