ant-design/components/progress/Steps.tsx
偏右 a5efa7a81a
test: increase coverage of Progress/Comment/Avatar/Dropdown (#24439)
* test: increase test case of Progress and Comment

* test: add test case for Avatar

* test: add test case for Dropdown

* fix snapshot

* fix snapshot

* remove console.log

* fix lint

* add avatar
2020-05-25 16:27:02 +08:00

38 lines
1.0 KiB
TypeScript

import * as React from 'react';
import { ProgressProps, ProgressSize } from './progress';
interface StepsProps extends ProgressProps {
steps: number;
size?: ProgressSize;
}
const Steps: React.FC<StepsProps> = props => {
const { size, 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;
if (i <= current - 1) {
color = strokeColor;
}
const stepStyle = {
backgroundColor: `${color}`,
width: `${stepWidth}px`,
height: `${strokeWidth}px`,
};
styleSteps.push(<div key={i} className={`${prefixCls}-steps-item`} style={stepStyle} />);
}
return styleSteps;
};
return (
<div className={`${prefixCls}-steps-outer`}>
{getStyledSteps()}
{children}
</div>
);
};
export default Steps;