2015-09-01 11:47:12 +08:00
|
|
|
import React from 'react';
|
|
|
|
|
2015-09-01 21:15:31 +08:00
|
|
|
let Timeline = React.createClass({
|
2015-09-01 11:47:12 +08:00
|
|
|
getDefaultProps() {
|
|
|
|
return {
|
|
|
|
prefixCls: 'ant-timeline'
|
|
|
|
};
|
|
|
|
},
|
|
|
|
render() {
|
2015-09-01 21:15:31 +08:00
|
|
|
let children = this.props.children;
|
2015-09-01 11:47:12 +08:00
|
|
|
return (
|
|
|
|
<ul className={this.props.prefixCls}>
|
2015-09-01 21:15:31 +08:00
|
|
|
{React.Children.map(children, function (ele, idx) {
|
|
|
|
let np = {
|
2015-09-07 15:13:59 +08:00
|
|
|
timelineLast: idx === children.length - 1,
|
2015-09-07 15:26:42 +08:00
|
|
|
pending: this.props.pending
|
2015-09-01 21:15:31 +08:00
|
|
|
};
|
|
|
|
return React.cloneElement(ele, np);
|
|
|
|
}, this)}
|
2015-09-01 11:47:12 +08:00
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-09-01 21:15:31 +08:00
|
|
|
Timeline.Item = React.createClass({
|
2015-09-01 11:47:12 +08:00
|
|
|
getDefaultProps() {
|
|
|
|
return {
|
|
|
|
prefixCls: 'ant-timeline',
|
|
|
|
color: 'blue',
|
2015-09-07 15:26:42 +08:00
|
|
|
pending: false
|
2015-09-01 11:47:12 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
render() {
|
2015-09-01 21:15:31 +08:00
|
|
|
let props = this.props;
|
|
|
|
let prefixCls = props.prefixCls;
|
|
|
|
let color = props.color;
|
2015-09-07 15:26:42 +08:00
|
|
|
let pending = props.pending;
|
2015-09-07 15:13:59 +08:00
|
|
|
let timelineLast = props.timelineLast;
|
2015-09-07 15:26:42 +08:00
|
|
|
let endCls = pending && timelineLast ? prefixCls + '-item-last' : '';
|
|
|
|
let last = pending && timelineLast ? <div className={prefixCls + '-item-head ' + prefixCls + '-item-head-end'}></div> : null;
|
|
|
|
let lastTailShow = (timelineLast && !pending) ? 'none' : 'block';
|
2015-09-01 21:39:29 +08:00
|
|
|
|
2015-09-01 11:47:12 +08:00
|
|
|
return (
|
2015-09-02 12:12:11 +08:00
|
|
|
<li className={prefixCls + '-item ' + endCls}>
|
2016-01-07 14:21:29 +08:00
|
|
|
<div style={{display: lastTailShow}} className={prefixCls + '-item-tail'}></div>
|
2015-09-01 21:39:29 +08:00
|
|
|
<div className={prefixCls + '-item-head ' + prefixCls + '-item-head-' + color}></div>
|
2015-09-01 21:15:31 +08:00
|
|
|
<div className={prefixCls + '-item-content'}>{props.children}</div>
|
|
|
|
{last}
|
2015-09-01 11:47:12 +08:00
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-09-01 21:15:31 +08:00
|
|
|
export default Timeline;
|