ant-design/components/skeleton/Element.tsx
Rustin 7a5fc8bb19 feat: add skeleton avatar (#19898)
* 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
2019-12-03 13:33:04 +08:00

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;