2020-06-22 15:22:52 +00:00
|
|
|
import { inject } from 'vue';
|
2019-01-12 03:33:27 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2020-06-22 15:22:52 +00:00
|
|
|
import { getComponent } from '../_util/props-util';
|
2019-03-13 13:32:14 +00:00
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
2018-01-20 06:33:42 +00:00
|
|
|
|
|
|
|
export default {
|
2018-04-08 13:17:20 +00:00
|
|
|
name: 'ACardMeta',
|
2018-01-20 06:33:42 +00:00
|
|
|
props: {
|
2019-09-10 10:57:08 +00:00
|
|
|
prefixCls: PropTypes.string,
|
2018-07-27 07:30:24 +00:00
|
|
|
title: PropTypes.any,
|
|
|
|
description: PropTypes.any,
|
2020-06-24 09:25:47 +00:00
|
|
|
avatar: PropTypes.any,
|
2018-01-20 06:33:42 +00:00
|
|
|
},
|
2020-06-22 15:22:52 +00:00
|
|
|
setup() {
|
|
|
|
return {
|
|
|
|
configProvider: inject('configProvider', ConfigConsumerProps),
|
|
|
|
};
|
2019-03-13 13:32:14 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
2019-03-13 13:32:14 +00:00
|
|
|
const { prefixCls: customizePrefixCls } = this.$props;
|
|
|
|
|
2019-09-11 14:35:25 +00:00
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
2019-03-13 13:32:14 +00:00
|
|
|
const prefixCls = getPrefixCls('card', customizePrefixCls);
|
|
|
|
|
2018-01-20 06:33:42 +00:00
|
|
|
const classString = {
|
|
|
|
[`${prefixCls}-meta`]: true,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-01-20 06:33:42 +00:00
|
|
|
|
2020-06-22 15:22:52 +00:00
|
|
|
const avatar = getComponent(this, 'avatar');
|
|
|
|
const title = getComponent(this, 'title');
|
|
|
|
const description = getComponent(this, 'description');
|
2018-07-27 07:30:24 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
const avatarDom = avatar ? <div class={`${prefixCls}-meta-avatar`}>{avatar}</div> : null;
|
|
|
|
const titleDom = title ? <div class={`${prefixCls}-meta-title`}>{title}</div> : null;
|
|
|
|
const descriptionDom = description ? (
|
|
|
|
<div class={`${prefixCls}-meta-description`}>{description}</div>
|
|
|
|
) : null;
|
|
|
|
const MetaDetail =
|
|
|
|
titleDom || descriptionDom ? (
|
|
|
|
<div class={`${prefixCls}-meta-detail`}>
|
|
|
|
{titleDom}
|
|
|
|
{descriptionDom}
|
|
|
|
</div>
|
|
|
|
) : null;
|
2018-01-20 06:33:42 +00:00
|
|
|
return (
|
2020-06-22 15:22:52 +00:00
|
|
|
<div class={classString}>
|
2018-01-20 06:33:42 +00:00
|
|
|
{avatarDom}
|
|
|
|
{MetaDetail}
|
|
|
|
</div>
|
2019-01-12 03:33:27 +00:00
|
|
|
);
|
2018-01-20 06:33:42 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|