import { Check } from '@mui/icons-material' import clsx from 'clsx' import { ComponentType, ReactNode } from 'react' enum StepStatus { Past = 'past', Current = 'current', Future = 'future', } export type SteppedWalkthroughProps = { // Optional title of the walkthrough. title?: string // Optional description of the walkthrough. description?: string // Steps in the walkthrough. steps: { // Label for the step to display next to the step index. label: string // Optional content for the step. If not passed, only the label will be // displayed. The status refers to whether the step is in the past, is the // current step, or is a future step. content?: (status: `${StepStatus}`) => ReactNode // If passed, will override the default icon for the step. OverrideIcon?: ComponentType<{ className: string }> // Optional class names for the icon and its container. iconContainerClassName?: string iconClassName?: string // Optional statuses to override the default statuses to show the content // for. overrideShowStepContentStatuses?: `${StepStatus}`[] }[] // Index of the current step. stepIndex: number // Determines what step statuses the content should be shown for. Defaults to // only current. showStepContentStatuses?: `${StepStatus}`[] // Optional container class name. className?: string // Optional text class name, for the step number and step label. textClassName?: string } export const SteppedWalkthrough = ({ title, description, steps, stepIndex, showStepContentStatuses = [StepStatus.Current], className, textClassName = 'link-text', }: SteppedWalkthroughProps) => (
{(title || description) && (
{title &&

{title}

} {description && (

{description}

)}
)}
{steps.map((step, index) => { const past = stepIndex > index const current = stepIndex === index const future = stepIndex < index const status = past ? StepStatus.Past : current ? StepStatus.Current : StepStatus.Future const stepContent = ( step.overrideShowStepContentStatuses ?? showStepContentStatuses ).includes(status) ? step.content?.(status) : undefined const Icon = step.OverrideIcon ?? Check return (
1) || future) && 'bg-background-base' )} >
{past && ( )}

{index + 1}.

{step.label}

{/* Orb is w-6, gap is w-3, step number is w-4, gap is w-3 */} {!!stepContent &&
{stepContent}
}
) })}
)