ant-design/components/skeleton/Element.tsx
二货爱吃白萝卜 1fc374495f
chore: patch for missing rootClassName (#40217)
* chore: init test

* test: rootClassName inject

* test: part of test

* chore: patch qrcode rootCls

* chore: part rootClassName

* chore: part rootClassName

* test: more test

* test: more test

* test: more test

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* test: more test

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: fix lint

* chore: fix lint

* chore: ignore part of lint

* test: update snapshot

* test: fix test case

* chore: fix node test

* chore: adjust render logic

* fix: test

* test: update snapshot

* test: update

* refactor

* chore: fix require module logic
2023-01-20 11:03:50 +08:00

49 lines
1.2 KiB
TypeScript

import classNames from 'classnames';
import * as React from 'react';
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;