import React from 'react' import classnames from 'classnames' import { Icon } from '~components/Icon' import { VisuallyHidden } from '~components/VisuallyHidden' import styles from './ProgressStepper.module.css' export type Step = { id: string label: string } export type Steps = [Step, ...Step[]] export type ProgressStepperProps = { /** The id reference to within a Step object */ currentStepId: Step['id'] /** A non-empty array of Steps */ steps: Steps isComplete?: boolean } const getStepStatus = ( isComplete: boolean, isCurrentStep: boolean, step: Step, index: number, ): { icon: JSX.Element accessibleName: string } => { if (isComplete) { return { icon: , accessibleName: `Completed: ${step.label}`, } } if (isCurrentStep) { return { icon: , accessibleName: `Current: ${step.label}`, } } return { icon: , accessibleName: `Not started: ${step.label}`, } } export const ProgressStepper = ({ currentStepId, steps, isComplete = false, ...restprops }: ProgressStepperProps): JSX.Element => { const currentStepIndex = steps.findIndex((stepItem) => stepItem.id === currentStepId) return (
    {steps.map((step, index: number) => { const isCurrentStep = currentStepIndex === index const isCompletedStep = index < currentStepIndex || isComplete const { accessibleName, icon } = getStepStatus( isCompletedStep, isCurrentStep, step, index, ) return (
  1. {/* will need to be translated */} {accessibleName} {step.label}
    {icon}
    {index < steps.length - 1 && (
    )}
  2. ) })}
Step {currentStepIndex + 1} of {steps.length}
) } ProgressStepper.displayName = 'Workflow.ProgressStepper'