ant-design-vue/components/skeleton/Avatar.tsx

41 lines
1.2 KiB
Vue
Raw Normal View History

2021-05-28 05:16:59 +00:00
import { computed, defineComponent } from 'vue';
2020-08-31 08:53:19 +00:00
import classNames from '../_util/classNames';
2019-01-12 03:33:27 +00:00
import PropTypes from '../_util/vue-types';
2020-10-18 14:03:57 +00:00
import { tuple } from '../_util/type';
import initDefaultProps from '../_util/props-util/initDefaultProps';
2021-05-28 05:16:59 +00:00
import useConfigInject from '../_util/hooks/useConfigInject';
import Element, { skeletonElementProps, SkeletonElementProps } from './Element';
2018-12-10 03:34:51 +00:00
2021-05-28 05:16:59 +00:00
export interface AvatarProps extends Omit<SkeletonElementProps, 'shape'> {
shape?: 'circle' | 'square';
}
2018-12-10 03:34:51 +00:00
2021-05-28 05:16:59 +00:00
export const avatarProps = initDefaultProps(
{ ...skeletonElementProps(), shape: PropTypes.oneOf(tuple('circle', 'square')) },
{
2018-12-10 03:34:51 +00:00
size: 'large',
2021-05-28 05:16:59 +00:00
},
);
const SkeletonAvatar = defineComponent({
name: 'ASkeletonAvatar',
props: avatarProps,
setup(props) {
const { prefixCls } = useConfigInject('skeleton', props);
const cls = computed(() =>
classNames(prefixCls.value, `${prefixCls.value}-element`, {
[`${prefixCls.value}-active`]: props.active,
}),
);
return () => {
return (
<div class={cls.value}>
<Element {...props} prefixCls={`${prefixCls.value}-avatar`} />
</div>
);
};
2018-12-10 03:34:51 +00:00
},
2020-10-18 14:03:57 +00:00
});
2018-12-10 03:34:51 +00:00
2021-05-28 05:16:59 +00:00
export default SkeletonAvatar;