mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-30 04:18:28 +08:00
502dac12aa
* docs: fix code * feat: lint * feat: prettier * feat: test * feat: review * feat: format html * feat: format html
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
|
|
export interface SkeletonElementProps {
|
|
prefixCls?: string;
|
|
className?: string;
|
|
rootClassName?: string;
|
|
style?: React.CSSProperties;
|
|
size?: 'large' | 'small' | 'default' | number;
|
|
shape?: 'circle' | 'square' | 'round' | 'default';
|
|
active?: boolean;
|
|
}
|
|
|
|
const Element: React.FC<SkeletonElementProps> = (props) => {
|
|
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.useMemo<React.CSSProperties>(
|
|
() =>
|
|
typeof size === 'number'
|
|
? {
|
|
width: size,
|
|
height: size,
|
|
lineHeight: `${size}px`,
|
|
}
|
|
: {},
|
|
[size],
|
|
);
|
|
|
|
return (
|
|
<span
|
|
className={classNames(prefixCls, sizeCls, shapeCls, className)}
|
|
style={{ ...sizeStyle, ...style }}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default Element;
|