mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-01 23:29:30 +08:00
2f1c2e1208
* feat: Tag add status props * feat: change solution for status tag * fix: fix coding specification issues * fix coding specification issues in demo * add Steps subcomponent in Progress component * update doc and demo * fix lint * small change for progress api * fix lint * fix wrong omit * update test suites * fix test failed * use inline-block * fix test issue * fix ci issue * update demo * optimize demo * update progress api * fix stylelint issue * remove overflow * reset some prettier * reset some prettier again * fix test failed * resolve bad code
38 lines
1.0 KiB
TypeScript
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.SFC<StepsProps> = 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(<div key={i} className={`${prefixCls}-steps-item`} style={stepStyle} />);
|
|
}
|
|
return styleSteps;
|
|
};
|
|
return (
|
|
<div className={`${prefixCls}-steps-outer`}>
|
|
{getStyledSteps()}
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Steps;
|