import React from 'react'; type StepStatus = 'wait' | 'process' | 'finish'; /** * StepItem 用于描述步骤条的单个步骤信息 */ export interface StepItem { /** 步骤标题 */ title: string; /** 步骤的说明文本(可选) */ description?: string; /** 步骤序号(可选) */ number?: number; /** 步骤状态,可选: wait | process | finish,默认为 wait */ status?: StepStatus; /** 可自定义扩展内容(可选) */ extra?: React.ReactNode; } export interface StepProps { steps: StepItem[]; className?: string; showArrow?: boolean; onStepClick?: (step: StepItem, index: number) => void; } const gradientPresets = [ 'bg-gradient-to-r from-[#95D3F4] to-white', 'bg-gradient-to-r from-[#9ABEFF] to-white', 'bg-gradient-to-r from-[#87CEFA] to-white', ]; const statusRingMap: Record = { wait: 'ring-1 ring-slate-200', process: 'ring-2 ring-[#4195E5]', finish: 'ring-2 ring-emerald-300', }; const statusTitleMap: Record = { wait: 'text-gray-900', process: 'text-[#1d5fbf]', finish: 'text-emerald-700', }; const cx = (...classNames: Array) => classNames.filter(Boolean).join(' '); const Step: React.FC = ({ steps, className, showArrow = true, onStepClick }) => { if (!steps?.length) { return null; } return (
{steps.map((step, index) => { const status = step.status ?? 'wait'; const gradient = gradientPresets[index % gradientPresets.length]; const card = (
onStepClick?.(step, index)} >
{step.number ?? index + 1}
step

{step.title}

{step.description && (

{step.description}

)} {step.extra &&
{step.extra}
}
); return ( {card} {showArrow && index < steps.length - 1 && (
{'>'}
)}
); })}
); }; Step.displayName = 'Step'; export default Step;