2019-11-21 20:23:56 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
export interface SkeletonElementProps {
|
|
|
|
prefixCls?: string;
|
|
|
|
className?: string;
|
|
|
|
style?: object;
|
|
|
|
size?: 'large' | 'small' | 'default' | number;
|
|
|
|
shape?: 'circle' | 'square' | 'round';
|
2019-12-03 13:33:04 +08:00
|
|
|
active?: boolean;
|
2019-11-21 20:23:56 +08:00
|
|
|
}
|
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
const Element = (props: SkeletonElementProps) => {
|
|
|
|
const { prefixCls, className, style, size, shape } = props;
|
2019-11-21 20:23:56 +08:00
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
const sizeCls = classNames({
|
|
|
|
[`${prefixCls}-lg`]: size === 'large',
|
|
|
|
[`${prefixCls}-sm`]: size === 'small',
|
|
|
|
});
|
2019-11-21 20:23:56 +08:00
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
const shapeCls = classNames({
|
|
|
|
[`${prefixCls}-circle`]: shape === 'circle',
|
|
|
|
[`${prefixCls}-square`]: shape === 'square',
|
|
|
|
[`${prefixCls}-round`]: shape === 'round',
|
|
|
|
});
|
|
|
|
|
|
|
|
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 }}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2019-11-21 20:23:56 +08:00
|
|
|
|
|
|
|
|
2019-12-03 13:33:04 +08:00
|
|
|
export default Element;
|