mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-02 15:59:38 +08:00
abebd55f0e
* feat: add Skeleton-Image * feat: add docs * fix: adjust skeleton * feat: adjust Image Component * feat: rebase * feat: adjust style * fix: lint * feat: remove size * feat: delete md * feat: fix style
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import * as React from 'react';
|
|
import omit from 'omit.js';
|
|
import classNames from 'classnames';
|
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
|
import Element, { SkeletonElementProps } from './Element';
|
|
|
|
export interface AvatarProps extends Omit<SkeletonElementProps, 'shape'> {
|
|
shape?: 'circle' | 'square';
|
|
}
|
|
|
|
const SkeletonAvatar = (props: AvatarProps) => {
|
|
const renderSkeletonAvatar = ({ getPrefixCls }: ConfigConsumerProps) => {
|
|
const { prefixCls: customizePrefixCls, className, active } = props;
|
|
const prefixCls = getPrefixCls('skeleton', customizePrefixCls);
|
|
const otherProps = omit(props, ['prefixCls']);
|
|
const cls = classNames(prefixCls, className, `${prefixCls}-element`, {
|
|
[`${prefixCls}-active`]: active,
|
|
});
|
|
return (
|
|
<div className={cls}>
|
|
<Element prefixCls={`${prefixCls}-avatar`} {...otherProps} />
|
|
</div>
|
|
);
|
|
};
|
|
return <ConfigConsumer>{renderSkeletonAvatar}</ConfigConsumer>;
|
|
};
|
|
|
|
SkeletonAvatar.defaultProps = {
|
|
size: 'default',
|
|
shape: 'circle',
|
|
};
|
|
|
|
export default SkeletonAvatar;
|