Files
frigate/web/src/components/indicators/StepIndicator.tsx
T

60 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-03-17 13:50:13 -06:00
import { cn } from "@/lib/utils";
2025-04-15 12:09:47 -06:00
import { useTranslation } from "react-i18next";
2025-03-17 13:50:13 -06:00
type StepIndicatorProps = {
steps: string[];
currentStep: number;
2025-10-13 11:52:08 -05:00
variant?: "default" | "dots";
translationNameSpace?: string;
className?: string;
2025-03-17 13:50:13 -06:00
};
2025-10-13 11:52:08 -05:00
2025-03-17 13:50:13 -06:00
export default function StepIndicator({
steps,
currentStep,
2025-10-13 11:52:08 -05:00
variant = "default",
2025-04-15 12:09:47 -06:00
translationNameSpace,
2025-10-13 11:52:08 -05:00
className,
2025-03-17 13:50:13 -06:00
}: StepIndicatorProps) {
2025-04-15 12:09:47 -06:00
const { t } = useTranslation(translationNameSpace);
2025-10-13 11:52:08 -05:00
if (variant == "dots") {
return (
<div className={cn("flex flex-row justify-center gap-2", className)}>
{steps.map((_, idx) => (
<div
key={idx}
className={cn(
"size-3 rounded-full border border-primary/10 transition-colors",
currentStep === idx
? "bg-selected"
: currentStep > idx
? "bg-muted-foreground"
: "bg-muted",
)}
/>
))}
</div>
);
}
// Default variant (original behavior)
2025-03-17 13:50:13 -06:00
return (
2025-10-13 11:52:08 -05:00
<div className={cn("flex flex-row justify-evenly", className)}>
2025-03-17 13:50:13 -06:00
{steps.map((name, idx) => (
2025-05-17 17:11:19 -05:00
<div key={idx} className="flex flex-col items-center gap-2">
2025-03-17 13:50:13 -06:00
<div
className={cn(
"flex size-16 items-center justify-center rounded-full",
currentStep == idx ? "bg-selected" : "border-2 border-selected",
)}
>
{idx + 1}
</div>
2025-04-15 12:09:47 -06:00
<div className="w-24 text-center md:w-24">{t(name)}</div>
2025-03-17 13:50:13 -06:00
</div>
))}
</div>
);
}