Open History to see the last commit
1import { CheckIcon } from "lucide-react";
2import type { ComponentProps } from "react";
3
4import { cn } from "../../lib/utils";
5import { AnimatedHeight } from "../AnimatedHeight";
6
7export function WizardSteps({
8 steps,
9 currentStep,
10 summaries,
11 onStepChange,
12 isStepDisabled,
13}: {
14 readonly steps: readonly string[];
15 readonly currentStep: number;
16 readonly summaries?: readonly (string | null)[];
17 readonly isStepDisabled?: (step: number) => boolean;
18 readonly onStepChange?: (step: number) => void;
19}) {
20 const Step = onStepChange ? "button" : "div";
21 return (
22 <ol
23 className="grid auto-cols-fr grid-flow-col gap-1 rounded-xl bg-zinc-25 p-1 ring-1 ring-black/5 dark:bg-white/4 dark:ring-white/5"
24 role="list"
25 aria-label="Setup progress"
26 >
27 {steps.map((step, index) => (
28 <li key={step} className="min-w-0">
29 <Step
30 {...(onStepChange
31 ? { type: "button" as const, disabled: isStepDisabled?.(index) }
32 : {})}
33 className={cn(
34 "flex w-full min-w-0 items-center gap-2 rounded-lg px-2.5 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring max-sm:justify-center max-sm:px-2",
35 onStepChange &&
36 "cursor-pointer hover:bg-card disabled:cursor-default disabled:hover:bg-transparent",
37 index === currentStep &&
38 "bg-card text-foreground shadow-xs ring-1 ring-black/5 hover:bg-card dark:shadow-none dark:ring-white/5",
39 )}
40 aria-current={index === currentStep ? "step" : undefined}
41 aria-label={`${step}, step ${index + 1}${index < currentStep && summaries?.[index] ? `, ${summaries?.[index]}` : ""}`}
42 onClick={onStepChange ? () => onStepChange(index) : undefined}
43 >
44 <span
45 className={cn(
46 "grid size-5 shrink-0 place-items-center rounded-full text-sm font-medium ring-1",
47 index < currentStep
48 ? "bg-primary text-primary-foreground ring-primary"
49 : index === currentStep
50 ? "bg-primary/10 text-primary ring-primary/30"
51 : "bg-card text-muted-foreground ring-black/10 dark:bg-white/5 dark:ring-white/10",
52 )}
53 aria-hidden
54 >
55 {index < currentStep ? <CheckIcon className="size-4 shrink-0" /> : index + 1}
56 </span>
57 <span
58 className={cn(
59 "min-w-0 truncate text-sm font-medium max-sm:hidden",
60 index === currentStep ? "text-foreground" : "text-muted-foreground",
61 )}
62 >
63 {step}
64 </span>
65 </Step>
66 </li>
67 ))}
68 </ol>
69 );
70}
71
72export function WizardPanel({
73 className,
74 children,
75 holdHeight = false,
76 ...props
77}: ComponentProps<"div"> & { readonly holdHeight?: boolean }) {
78 return (
79 <div
80 data-slot="dialog-panel"
81 className={cn(
82 "space-y-4 bg-zinc-25/80 px-6 py-5 ring-1 ring-black/5 dark:bg-white/2 dark:ring-white/5",
83 className,
84 )}
85 {...props}
86 >
87 <AnimatedHeight holdHeight={holdHeight}>{children}</AnimatedHeight>
88 </div>
89 );
90}