2019-11-21 20:23:56 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import omit from 'omit.js';
|
|
|
|
import classNames from 'classnames';
|
2019-12-03 13:33:04 +08:00
|
|
|
import Element, { SkeletonElementProps } from './Element';
|
2019-11-21 20:23:56 +08:00
|
|
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
export interface SkeletonButtonProps extends Omit<SkeletonElementProps, 'size'> {
|
2019-11-21 20:23:56 +08:00
|
|
|
size?: 'large' | 'small' | 'default';
|
|
|
|
}
|
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
const SkeletonButton = (props: SkeletonButtonProps) => {
|
|
|
|
const renderSkeletonButton = ({ getPrefixCls }: ConfigConsumerProps) => {
|
|
|
|
const { prefixCls: customizePrefixCls, className, active } = props;
|
2019-11-21 20:23:56 +08:00
|
|
|
const prefixCls = getPrefixCls('skeleton', customizePrefixCls);
|
2020-04-14 10:30:14 +08:00
|
|
|
const otherProps = omit(props, ['prefixCls']);
|
2019-11-21 20:23:56 +08:00
|
|
|
const cls = classNames(prefixCls, className, `${prefixCls}-element`, {
|
|
|
|
[`${prefixCls}-active`]: active,
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<div className={cls}>
|
2019-12-03 13:33:04 +08:00
|
|
|
<Element prefixCls={`${prefixCls}-button`} {...otherProps} />
|
2019-11-21 20:23:56 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2020-04-14 10:30:14 +08:00
|
|
|
return <ConfigConsumer>{renderSkeletonButton}</ConfigConsumer>;
|
|
|
|
};
|
2019-11-21 20:23:56 +08:00
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
SkeletonButton.defaultProps = {
|
|
|
|
size: 'default',
|
|
|
|
};
|
2019-11-21 20:23:56 +08:00
|
|
|
|
|
|
|
export default SkeletonButton;
|