mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 07:09:55 +08:00
7a5fc8bb19
* move avatar default props into skeleton * #18237 complete skeleton avatar * update skeleton avatar docs * add more tests for skeleton avatar * refactor class and props name * revert Avatar props name * combine avatar and button demo * update demo and test snapshots * move active props into element
47 lines
1.2 KiB
TypeScript
47 lines
1.2 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;
|
|
}
|
|
|
|
// eslint-disable-next-line react/prefer-stateless-function
|
|
class Element extends React.Component<SkeletonElementProps, any> {
|
|
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 }}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Element;
|