Steps.js
1.8 KB
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
import React,{PropTypes} from 'react';
import ReactDOM from 'react-dom';
import cx from 'classnames';
import s from './breadline.scss';
class Steps extends React.Component {
constructor(props) {
super(props);
}
static propTypes = {
title:PropTypes.string,
close:PropTypes.func,
style:PropTypes.object,
width:PropTypes.number,
steps:PropTypes.array,
curentStep:PropTypes.number
}
static defaultProps={
curentStep:1,
width:830,
steps:['上传文件','字段映射设置','完成'],
close:()=>{
}
}
componentDidMount(){
}
componentWillReceiveProps(nextProps){
}
componentDidUpdate(prevProps,prevState){
}
componentWillUnmount() {
}
render(){
const {width,curentStep,steps}=this.props;
const maxWidth=`${width}px`;
let setpNum=steps.length;
return (
<div className={cx(s.steps)} style={{width:maxWidth}}>
{steps.map((step,i)=>{
let percent=100/(setpNum-1)*i;
let activate=true;
if(curentStep<i+1){
activate=false;
}
return (
<div key={i} className={cx(s.step,activate?s.activate:s.unActive)} style={{marginLeft:percent+'%'}}>
{activate&&<i className={cx('kr_icon')}></i>}
{!activate&&<div>{i+1}</div>}
<div className={cx(s.step_title,activate?s.bold:s.unBold)}>{step}</div>
</div>
)
})}
<div className={cx(s.setp_line)}>
</div>
</div>
)
}
}
export default Steps;