ant-design/components/timeline/TimelineItem.tsx

44 lines
1.2 KiB
TypeScript
Raw Normal View History

2016-03-31 17:46:35 +08:00
import React from 'react';
import classNames from 'classnames';
2016-06-22 13:18:43 +08:00
import splitObject from '../_util/splitObject';
2016-03-31 17:46:35 +08:00
export default class TimelineItem extends React.Component {
static defaultProps = {
prefixCls: 'ant-timeline',
color: 'blue',
last: false,
pending: false,
}
render() {
2016-06-22 13:18:43 +08:00
const [{
prefixCls, color, last, children, pending, className, dot
},restProps] = splitObject(this.props,
['prefixCls', 'color', 'last','children','pending','className','dot']);
2016-03-31 17:46:35 +08:00
const itemClassName = classNames({
[`${prefixCls}-item`]: true,
[`${prefixCls}-item-last`]: last,
[`${prefixCls}-item-pending`]: pending,
2016-04-18 16:17:16 +08:00
[className]: className,
2016-03-31 17:46:35 +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`} />
<div className={dotClassName} style={{ color: /blue|red|green/.test(color) ? null : color }}>
{dot}
</div>
<div className={`${prefixCls}-item-content`}>
{children}
</div>
2016-03-31 17:46:35 +08:00
</li>
);
}
}