forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Timeline.jsx
33 lines (31 loc) · 924 Bytes
/
Timeline.jsx
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
import React from 'react';
import classNames from 'classnames';
import TimelineItem from './TimelineItem';
export default class Timeline extends React.Component {
static defaultProps = {
prefixCls: 'ant-timeline',
}
render() {
const { prefixCls, children, pending, className, ...restProps } = this.props;
const pendingNode = typeof pending === 'boolean' ? null : pending;
const classString = classNames({
[prefixCls]: true,
[`${prefixCls}-pending`]: !!pending,
[className]: className,
});
return (
<ul {...restProps} className={classString}>
{
React.Children.map(children, (ele, idx) =>
React.cloneElement(ele, {
last: idx === children.length - 1,
})
)
}
{(!!pending)
? <TimelineItem pending={!!pending}>{pendingNode}</TimelineItem>
: null}
</ul>
);
}
}