2018-08-22 23:34:36 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
export interface SkeletonAvatarProps {
|
|
|
|
prefixCls?: string;
|
|
|
|
className?: string;
|
|
|
|
style?: object;
|
|
|
|
size?: 'large' | 'small' | 'default';
|
2018-12-07 20:02:01 +08:00
|
|
|
shape?: 'circle' | 'square';
|
2018-08-22 23:34:36 +08:00
|
|
|
}
|
|
|
|
|
2019-04-09 13:42:34 +08:00
|
|
|
class SkeletonAvatar extends React.Component<SkeletonAvatarProps, any> {
|
2018-08-22 23:34:36 +08:00
|
|
|
static defaultProps: Partial<SkeletonAvatarProps> = {
|
|
|
|
size: 'large',
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { prefixCls, className, style, size, shape } = this.props;
|
|
|
|
|
|
|
|
const sizeCls = classNames({
|
|
|
|
[`${prefixCls}-lg`]: size === 'large',
|
|
|
|
[`${prefixCls}-sm`]: size === 'small',
|
|
|
|
});
|
|
|
|
|
|
|
|
const shapeCls = classNames({
|
|
|
|
[`${prefixCls}-circle`]: shape === 'circle',
|
|
|
|
[`${prefixCls}-square`]: shape === 'square',
|
|
|
|
});
|
|
|
|
|
2019-05-06 12:04:39 +08:00
|
|
|
const sizeStyle: React.CSSProperties =
|
|
|
|
typeof size === 'number'
|
|
|
|
? {
|
|
|
|
width: size,
|
|
|
|
height: size,
|
|
|
|
lineHeight: `${size}px`,
|
|
|
|
}
|
|
|
|
: {};
|
|
|
|
return (
|
|
|
|
<span
|
|
|
|
className={classNames(prefixCls, className, sizeCls, shapeCls)}
|
|
|
|
style={{ ...sizeStyle, ...style }}
|
|
|
|
/>
|
|
|
|
);
|
2018-08-22 23:34:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-09 13:42:34 +08:00
|
|
|
export default SkeletonAvatar;
|