mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
37c894f1a2
* #24532 Progress with steps does not reverse indicator when moving reducing progress percent * updating snapshots * Update components/progress/Steps.tsx Co-authored-by: Amumu <yoyo837@hotmail.com> * fix tsd and add transition * add default color for Progress steps * color => background * @success-color => @info-color * @progress-default-color Co-authored-by: Amumu <yoyo837@hotmail.com> Co-authored-by: afc163 <afc163@gmail.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
import { ProgressProps, ProgressSize } from './progress';
|
|
|
|
interface StepsProps extends ProgressProps {
|
|
steps: number;
|
|
size?: ProgressSize;
|
|
strokeColor?: string;
|
|
}
|
|
|
|
const Steps: React.FC<StepsProps> = props => {
|
|
const { size, steps, percent = 0, strokeWidth = 8, strokeColor, prefixCls, children } = props;
|
|
const current = Math.floor(steps * (percent / 100));
|
|
const stepWidth = size === 'small' ? 2 : 14;
|
|
const styledSteps = [];
|
|
for (let i = 0; i < steps; i += 1) {
|
|
styledSteps.push(
|
|
<div
|
|
key={i}
|
|
className={classNames(`${prefixCls}-steps-item`, {
|
|
[`${prefixCls}-steps-item-active`]: i <= current - 1,
|
|
})}
|
|
style={{
|
|
backgroundColor: i <= current - 1 ? strokeColor : undefined,
|
|
width: stepWidth,
|
|
height: strokeWidth,
|
|
}}
|
|
/>,
|
|
);
|
|
}
|
|
return (
|
|
<div className={`${prefixCls}-steps-outer`}>
|
|
{styledSteps}
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Steps;
|