forked from ant-design/ant-design-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.web.tsx
73 lines (67 loc) · 2.09 KB
/
index.web.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import * as React from 'react';
import RcSteps from 'rc-steps';
export interface StepsProps {
prefixCls?: string;
iconPrefix?: string;
direction?: string;
labelPlacement?: string;
children: any;
status?: string;
size?: string;
current?: number;
}
export default class Steps extends React.Component<StepsProps, any> {
static Step = (RcSteps as any).Step;
static defaultProps = {
prefixCls: 'am-steps',
iconPrefix: 'ant',
labelPlacement: 'vertical',
current: 0,
direction: 'vertical',
};
render() {
const { current, direction } = this.props;
return (
<RcSteps {...this.props} direction={direction}>
{
this.props.children.map((item, index) => {
let errorTail = -1;
if (index < this.props.children.length - 1) {
const status = this.props.children[index + 1].props.status;
if (status === 'error') {
errorTail = index;
}
}
const errorTailCls = errorTail > -1 ? 'error-tail' : '';
let iconName;
let className;
if (!!item.props.icon) {
iconName = item.props.icon;
className = '';
if ( index > 0 && index <= current) {
iconName = 'check-circle';
} else if (item.props.status === 'error') {
iconName = 'cross-circle';
} else if(item.props.status === 'process') {
iconName = 'check-circle';
}
} else {
className = index <= current ? null : 'ellipsis-item';
if (index <= current) {
iconName = 'check-circle-o';
} else if (item.props.status === 'error') {
iconName = 'cross-circle-o';
} else {
iconName = 'ellipsis';
}
}
className = `${errorTailCls} ${className}`;
return React.cloneElement(
item, {key: index, icon: iconName, className: className}
);
})
}
</RcSteps>
);
}
}