mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-15 09:21:25 +08:00
3975cdea78
* feat: update timeline * style: lower import path
62 lines
1.7 KiB
Vue
62 lines
1.7 KiB
Vue
import { inject } from 'vue';
|
|
import classNames from 'classnames';
|
|
import PropTypes from '../_util/vue-types';
|
|
import { getOptionProps, initDefaultProps, getComponent } from '../_util/props-util';
|
|
import { ConfigConsumerProps } from '../config-provider';
|
|
|
|
export const TimeLineItemProps = {
|
|
prefixCls: PropTypes.string,
|
|
color: PropTypes.string,
|
|
dot: PropTypes.any,
|
|
pending: PropTypes.bool,
|
|
position: PropTypes.oneOf(['left', 'right', '']).def(''),
|
|
};
|
|
|
|
export default {
|
|
name: 'ATimelineItem',
|
|
props: initDefaultProps(TimeLineItemProps, {
|
|
color: 'blue',
|
|
pending: false,
|
|
}),
|
|
setup() {
|
|
const configProvider = inject('configProvider', ConfigConsumerProps);
|
|
return {
|
|
configProvider,
|
|
};
|
|
},
|
|
render() {
|
|
const { prefixCls: customizePrefixCls, color = '', pending } = getOptionProps(this);
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
const prefixCls = getPrefixCls('timeline', customizePrefixCls);
|
|
|
|
const dot = getComponent(this, 'dot');
|
|
const itemClassName = classNames({
|
|
[`${prefixCls}-item`]: true,
|
|
[`${prefixCls}-item-pending`]: pending,
|
|
});
|
|
|
|
const dotClassName = classNames({
|
|
[`${prefixCls}-item-head`]: true,
|
|
[`${prefixCls}-item-head-custom`]: dot,
|
|
[`${prefixCls}-item-head-${color}`]: true,
|
|
});
|
|
const liProps = {
|
|
class: itemClassName,
|
|
};
|
|
return (
|
|
<li {...liProps}>
|
|
<div class={`${prefixCls}-item-tail`} />
|
|
<div
|
|
class={dotClassName}
|
|
style={{ borderColor: /blue|red|green|gray/.test(color) ? undefined : color }}
|
|
>
|
|
{dot}
|
|
</div>
|
|
<div class={`${prefixCls}-item-content`}>
|
|
{this.$slots.default && this.$slots.default()}
|
|
</div>
|
|
</li>
|
|
);
|
|
},
|
|
};
|