2018-04-03 15:51:44 +08:00
|
|
|
import classNames from 'classnames'
|
|
|
|
import PropTypes from '../_util/vue-types'
|
|
|
|
import { getOptionProps, initDefaultProps, getComponentFromProp } from '../_util/props-util'
|
|
|
|
|
|
|
|
export const TimeLineItemProps = {
|
|
|
|
prefixCls: PropTypes.string,
|
|
|
|
color: PropTypes.string,
|
|
|
|
dot: PropTypes.any,
|
|
|
|
pending: PropTypes.bool,
|
|
|
|
last: PropTypes.bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'TimelineItem',
|
|
|
|
props: initDefaultProps(TimeLineItemProps, {
|
|
|
|
prefixCls: 'ant-timeline',
|
|
|
|
color: 'blue',
|
|
|
|
last: false,
|
|
|
|
pending: false,
|
|
|
|
}),
|
|
|
|
render () {
|
2018-04-03 21:01:05 +08:00
|
|
|
const { prefixCls, color = '', last, pending } = getOptionProps(this)
|
2018-04-03 15:51:44 +08:00
|
|
|
const dot = getComponentFromProp(this, 'dot')
|
|
|
|
const itemClassName = classNames({
|
|
|
|
[`${prefixCls}-item`]: true,
|
|
|
|
[`${prefixCls}-item-last`]: last,
|
|
|
|
[`${prefixCls}-item-pending`]: pending,
|
|
|
|
})
|
|
|
|
|
|
|
|
const dotClassName = classNames({
|
|
|
|
[`${prefixCls}-item-head`]: true,
|
|
|
|
[`${prefixCls}-item-head-custom`]: dot,
|
|
|
|
[`${prefixCls}-item-head-${color}`]: true,
|
|
|
|
})
|
2018-04-03 21:01:05 +08:00
|
|
|
const liProps = {
|
|
|
|
class: itemClassName,
|
|
|
|
on: this.$listeners,
|
|
|
|
}
|
2018-04-03 15:51:44 +08:00
|
|
|
return (
|
2018-04-03 21:01:05 +08:00
|
|
|
<li {...liProps}>
|
2018-04-03 15:51:44 +08:00
|
|
|
<div class={`${prefixCls}-item-tail`} />
|
|
|
|
<div
|
|
|
|
class={dotClassName}
|
|
|
|
style={{ borderColor: /blue|red|green/.test(color) ? null : color }}
|
|
|
|
>
|
|
|
|
{dot}
|
|
|
|
</div>
|
|
|
|
<div class={`${prefixCls}-item-content`}>
|
|
|
|
{this.$slots.default}
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}
|