2016-09-21 11:54:53 +08:00
|
|
|
import React from 'react';
|
2016-03-31 17:46:35 +08:00
|
|
|
import classNames from 'classnames';
|
2016-07-09 10:53:40 +08:00
|
|
|
|
|
|
|
export interface TimeLineItemProps {
|
2016-12-19 15:19:15 +08:00
|
|
|
prefixCls?: string;
|
|
|
|
className?: string;
|
2016-07-13 11:14:24 +08:00
|
|
|
color?: string;
|
|
|
|
dot?: React.ReactNode;
|
2016-08-22 17:26:14 +08:00
|
|
|
pending?: boolean;
|
2016-12-19 15:19:15 +08:00
|
|
|
last?: boolean;
|
2016-07-13 11:14:24 +08:00
|
|
|
style?: React.CSSProperties;
|
2016-07-09 10:53:40 +08:00
|
|
|
}
|
2016-07-13 11:14:24 +08:00
|
|
|
|
2016-07-09 10:53:40 +08:00
|
|
|
export default class TimelineItem extends React.Component<TimeLineItemProps, any> {
|
2016-03-31 17:46:35 +08:00
|
|
|
static defaultProps = {
|
|
|
|
prefixCls: 'ant-timeline',
|
|
|
|
color: 'blue',
|
|
|
|
last: false,
|
|
|
|
pending: false,
|
2016-07-13 11:14:24 +08:00
|
|
|
};
|
2016-03-31 17:46:35 +08:00
|
|
|
|
|
|
|
render() {
|
2016-12-19 15:19:15 +08:00
|
|
|
const { prefixCls, className, color = '', last, children, pending, dot, ...restProps } = this.props;
|
2016-05-07 02:13:08 +08:00
|
|
|
|
2016-03-31 17:46:35 +08:00
|
|
|
const itemClassName = classNames({
|
|
|
|
[`${prefixCls}-item`]: true,
|
|
|
|
[`${prefixCls}-item-last`]: last,
|
|
|
|
[`${prefixCls}-item-pending`]: pending,
|
2016-11-30 10:20:23 +08:00
|
|
|
}, className);
|
2016-05-07 02:13:08 +08:00
|
|
|
|
|
|
|
const dotClassName = classNames({
|
|
|
|
[`${prefixCls}-item-head`]: true,
|
|
|
|
[`${prefixCls}-item-head-custom`]: dot,
|
|
|
|
[`${prefixCls}-item-head-${color}`]: true,
|
|
|
|
});
|
|
|
|
|
2016-03-31 17:46:35 +08:00
|
|
|
return (
|
2016-04-18 16:17:16 +08:00
|
|
|
<li {...restProps} className={itemClassName}>
|
2016-03-31 17:46:35 +08:00
|
|
|
<div className={`${prefixCls}-item-tail`} />
|
2016-07-24 16:19:46 +08:00
|
|
|
<div
|
|
|
|
className={dotClassName}
|
|
|
|
style={{ borderColor: /blue|red|green/.test(color) ? null : color }}
|
|
|
|
>
|
2016-05-07 02:13:08 +08:00
|
|
|
{dot}
|
|
|
|
</div>
|
|
|
|
<div className={`${prefixCls}-item-content`}>
|
|
|
|
{children}
|
|
|
|
</div>
|
2016-03-31 17:46:35 +08:00
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|