ant-design/components/timeline/Timeline.jsx
2016-04-18 16:58:46 +08:00

34 lines
924 B
JavaScript

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>
);
}
}