You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
5 years ago
|
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';
|
||
5 years ago
|
active?: boolean;
|
||
5 years ago
|
}
|
||
|
|
||
|
// eslint-disable-next-line react/prefer-stateless-function
|
||
5 years ago
|
class Element extends React.Component<SkeletonElementProps, any> {
|
||
5 years ago
|
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',
|
||
|
[`${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 }}
|
||
|
/>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
export default Element;
|