Skip to content

Commit d0de02b

Browse files
committed
Add stepper component for multi step form
1 parent 25a2a9a commit d0de02b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

frontend/src/app/onboard/_components/StepperComponent.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Separator } from "@radix-ui/react-dropdown-menu";
33
import React from "react";
44

55
interface Activatable {
6-
isActive: boolean;
6+
isActive: boolean;
77
}
88

99
interface StepperComponentProps {
@@ -20,7 +20,9 @@ export default function StepperComponent({
2020
{Array.from({ length: totalSteps }, (e, i) => (
2121
<>
2222
<StepComponent isActive={i + 1 <= currStep} value={i + 1} key={i} />
23-
{i < totalSteps - 1 && <SeparatorComponent isActive={(i + 1) < currStep}/>}
23+
{i < totalSteps - 1 && (
24+
<SeparatorComponent isActive={i + 1 < currStep} />
25+
)}
2426
</>
2527
))}
2628
</div>
@@ -44,8 +46,18 @@ function StepComponent({ isActive, value }: StepComponentProps) {
4446
);
4547
}
4648

47-
interface SeparatorComponentProps extends Activatable {}
49+
interface SeparatorComponentProps extends Activatable {
50+
key?: number;
51+
}
4852

49-
function SeparatorComponent({ isActive }: SeparatorComponentProps) {
50-
return <Separator className={cn("flex-1 h-[2px]", {"bg-primary": isActive,"bg-background-100": !isActive})} />
53+
function SeparatorComponent({ key, isActive }: SeparatorComponentProps) {
54+
return (
55+
<Separator
56+
key={key}
57+
className={cn("flex-1 h-[2px]", {
58+
"bg-primary": isActive,
59+
"bg-background-100": !isActive,
60+
})}
61+
/>
62+
);
5163
}

0 commit comments

Comments
 (0)