import * as React from 'react'; import { ProgressProps, ProgressSize } from './progress'; interface StepsProps extends ProgressProps { steps: number; size?: ProgressSize; } const Steps: React.SFC = props => { const { size = 'default', steps, percent = 0, strokeWidth = 8, strokeColor, prefixCls, children } = props; const getStyledSteps = () => { const current = Math.floor(steps * (percent / 100)); const stepWidth = size === 'small' ? 2 : 14; const styleSteps = []; for (let i = 0; i < steps; i++) { let color = strokeColor; if (i > current - 1) { color = '#f3f3f3'; } const stepStyle = { backgroundColor: `${color}`, width: `${stepWidth}px`, height: `${strokeWidth}px`, }; styleSteps.push(
); } return styleSteps; }; return (
{getStyledSteps()} {children}
); }; export default Steps;