mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 06:09:34 +08:00
13fda44fb1
* refactor(skeleton): rewrite with hook * fix(skeleton): refine lint and compile issues * fix(skeleton): refine compile issues * chore: ignore eslint warning
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
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';
|
|
active?: boolean;
|
|
}
|
|
|
|
const Element = (props: SkeletonElementProps) => {
|
|
const { prefixCls, className, style, size, shape } = props;
|
|
|
|
const sizeCls = classNames({
|
|
[`${prefixCls}-lg`]: size === 'large',
|
|
[`${prefixCls}-sm`]: size === 'small',
|
|
});
|
|
|
|
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 }}
|
|
/>
|
|
);
|
|
};
|
|
|
|
|
|
export default Element;
|