import React, { HTMLAttributes, ReactNode } from 'react'; import SuccessIcon from '../icons/success.svg'; import './index.scss'; export interface StepsProps extends HTMLAttributes { children: React.ReactNode[]; current?: number; } type VNode = ReactNode & { type: { name: string } }; const Steps: React.FC = (props) => { const { children, current, ...rest } = props; const render = () => { return React.Children.map(children, (child, index) => { const vNode = child as VNode; if (React.isValidElement(vNode) && vNode.props.name === 'Step') { if (index < children!.length - 1) { return ( <>
index ? 'none' : 'flex', backgroundColor: current === index ? '#1890ff' : '#c9c9c9' }} > {index + 1}
{vNode}

); } return (
index ? 'none' : 'flex', backgroundColor: current === index ? '#1890ff' : '#c9c9c9' }} > {index + 1}
{vNode}
); } return child; }); }; return (
{render()}
); }; Steps.defaultProps = { current: 0 }; export default Steps;