2019-12-03 13:33:04 +08:00
|
|
|
import classNames from 'classnames';
|
2022-06-22 14:57:09 +08:00
|
|
|
import omit from 'rc-util/lib/omit';
|
|
|
|
import * as React from 'react';
|
2022-03-25 20:11:33 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { SkeletonElementProps } from './Element';
|
|
|
|
import Element from './Element';
|
2018-08-22 23:34:36 +08:00
|
|
|
|
2019-11-21 20:23:56 +08:00
|
|
|
export interface AvatarProps extends Omit<SkeletonElementProps, 'shape'> {
|
2018-12-07 20:02:01 +08:00
|
|
|
shape?: 'circle' | 'square';
|
2018-08-22 23:34:36 +08:00
|
|
|
}
|
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
const SkeletonAvatar = (props: AvatarProps) => {
|
2022-03-25 20:11:33 +08:00
|
|
|
const { prefixCls: customizePrefixCls, className, active } = props;
|
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const prefixCls = getPrefixCls('skeleton', customizePrefixCls);
|
|
|
|
|
|
|
|
const otherProps = omit(props, ['prefixCls', 'className']);
|
|
|
|
const cls = classNames(
|
|
|
|
prefixCls,
|
|
|
|
`${prefixCls}-element`,
|
|
|
|
{
|
|
|
|
[`${prefixCls}-active`]: active,
|
|
|
|
},
|
|
|
|
className,
|
|
|
|
);
|
|
|
|
return (
|
|
|
|
<div className={cls}>
|
|
|
|
<Element prefixCls={`${prefixCls}-avatar`} {...otherProps} />
|
|
|
|
</div>
|
|
|
|
);
|
2020-06-28 22:41:59 +08:00
|
|
|
};
|
2018-08-22 23:34:36 +08:00
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
SkeletonAvatar.defaultProps = {
|
|
|
|
size: 'default',
|
|
|
|
shape: 'circle',
|
|
|
|
};
|
|
|
|
|
2019-04-09 13:42:34 +08:00
|
|
|
export default SkeletonAvatar;
|