diff --git a/web/src/components/ui/stepper.tsx b/web/src/components/ui/stepper.tsx new file mode 100644 index 0000000..e992a45 --- /dev/null +++ b/web/src/components/ui/stepper.tsx @@ -0,0 +1,93 @@ +import React, { useMemo } from "react"; + +type Step = { + id: string; + label: string; + description?: string; + icon?: React.ReactNode; +}; + +type StepperProps = { + steps: Step[]; + currentStep: string; +}; + +export const Stepper: React.FC = ({ steps, currentStep }) => { + const stepIndex = useMemo( + () => steps.findIndex((s) => s.id === currentStep), + [currentStep, steps], + ); + + const percent = useMemo(() => { + return steps.length === 1 + ? 100 + : Math.round((stepIndex / (steps.length - 1)) * 100); + }, [stepIndex, steps.length]); + + return ( +
+ {steps.map((step, idx) => ( + <> +
+ {/* Step circle */} +
+ {idx < stepIndex ? ( + // Check icon for completed steps + + + + ) : ( + (step.icon ?? {idx + 1}) + )} +
+ + {/* Step label */} +
+ + {step.label} + + {step.description && ( + + {step.description} + + )} +
+ + {/* {idx < steps.length - 1 && ( +
+ )} */} +
+ + ))} +
+
+
+
+ ); +};