2021-10-07 01:23:36 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2019-01-12 03:33:27 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2021-10-07 01:23:36 +00:00
|
|
|
import { getPropsSlot } from '../_util/props-util';
|
|
|
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
2018-01-20 06:33:42 +00:00
|
|
|
|
2020-10-12 11:19:10 +00:00
|
|
|
export default defineComponent({
|
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,
|
2021-10-07 01:23:36 +00:00
|
|
|
title: PropTypes.any,
|
|
|
|
description: PropTypes.any,
|
|
|
|
avatar: PropTypes.any,
|
2018-01-20 06:33:42 +00:00
|
|
|
},
|
2021-10-07 01:23:36 +00:00
|
|
|
slots: ['title', 'description', 'avatar'],
|
|
|
|
setup(props, { slots }) {
|
|
|
|
const { prefixCls } = useConfigInject('card', props);
|
|
|
|
return () => {
|
|
|
|
const classString = {
|
|
|
|
[`${prefixCls.value}-meta`]: true,
|
|
|
|
};
|
|
|
|
const avatar = getPropsSlot(slots, props, 'avatar');
|
|
|
|
const title = getPropsSlot(slots, props, 'title');
|
|
|
|
const description = getPropsSlot(slots, props, 'description');
|
2018-01-20 06:33:42 +00:00
|
|
|
|
2021-10-07 01:23:36 +00:00
|
|
|
const avatarDom = avatar ? (
|
|
|
|
<div class={`${prefixCls.value}-meta-avatar`}>{avatar}</div>
|
|
|
|
) : null;
|
|
|
|
const titleDom = title ? <div class={`${prefixCls.value}-meta-title`}>{title}</div> : null;
|
|
|
|
const descriptionDom = description ? (
|
|
|
|
<div class={`${prefixCls.value}-meta-description`}>{description}</div>
|
2019-01-12 03:33:27 +00:00
|
|
|
) : null;
|
2021-10-07 01:23:36 +00:00
|
|
|
const MetaDetail =
|
|
|
|
titleDom || descriptionDom ? (
|
|
|
|
<div class={`${prefixCls.value}-meta-detail`}>
|
|
|
|
{titleDom}
|
|
|
|
{descriptionDom}
|
|
|
|
</div>
|
|
|
|
) : null;
|
|
|
|
return (
|
|
|
|
<div class={classString}>
|
|
|
|
{avatarDom}
|
|
|
|
{MetaDetail}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2018-01-20 06:33:42 +00:00
|
|
|
},
|
2020-10-12 11:19:10 +00:00
|
|
|
});
|