mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 02:59:04 +08:00
Feat spin wrapper className. (#5425)
This commit is contained in:
parent
5d348ec1b2
commit
45b0693bae
@ -18,3 +18,4 @@ size | size of spin, available in `small`, `default` and `large` | string | 'def
|
||||
spinning | whether Spin is spinning | boolean | true
|
||||
tip | customize description content when spin has children | string | -
|
||||
delay | specifies a delay millisecond for loading state (prevent flush) | number (millisecond) | -
|
||||
wrapperClassName | className of wrapper when Spin has children | string | -
|
||||
|
@ -13,6 +13,7 @@ export interface SpinProps {
|
||||
size?: 'small' | 'default' | 'large';
|
||||
tip?: string;
|
||||
delay?: number;
|
||||
wrapperClassName?: string;
|
||||
}
|
||||
|
||||
export default class Spin extends React.Component<SpinProps, any> {
|
||||
@ -20,6 +21,7 @@ export default class Spin extends React.Component<SpinProps, any> {
|
||||
prefixCls: 'ant-spin',
|
||||
spinning: true,
|
||||
size: 'default',
|
||||
wrapperClassName: '',
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
@ -27,6 +29,7 @@ export default class Spin extends React.Component<SpinProps, any> {
|
||||
className: PropTypes.string,
|
||||
spinning: PropTypes.bool,
|
||||
size: PropTypes.oneOf(['small', 'default', 'large']),
|
||||
wrapperClassName: PropTypes.string,
|
||||
};
|
||||
|
||||
debounceTimeout: number;
|
||||
@ -82,7 +85,7 @@ export default class Spin extends React.Component<SpinProps, any> {
|
||||
}
|
||||
}
|
||||
render() {
|
||||
const { className, size, prefixCls, tip, ...restProps } = this.props;
|
||||
const { className, size, prefixCls, tip, wrapperClassName, ...restProps } = this.props;
|
||||
const { spinning } = this.state;
|
||||
|
||||
const spinClassName = classNames(prefixCls, {
|
||||
@ -110,6 +113,10 @@ export default class Spin extends React.Component<SpinProps, any> {
|
||||
</div>
|
||||
);
|
||||
if (this.isNestedPattern()) {
|
||||
let animateClassName = prefixCls + '-nested-loading';
|
||||
if (wrapperClassName) {
|
||||
animateClassName += ' ' + wrapperClassName;
|
||||
}
|
||||
const containerClassName = classNames({
|
||||
[`${prefixCls}-container`]: true,
|
||||
[`${prefixCls}-blur`]: spinning,
|
||||
@ -118,7 +125,7 @@ export default class Spin extends React.Component<SpinProps, any> {
|
||||
<Animate
|
||||
{...divProps}
|
||||
component="div"
|
||||
className={`${prefixCls}-nested-loading`}
|
||||
className={animateClassName}
|
||||
style={null}
|
||||
transitionName="fade"
|
||||
>
|
||||
|
@ -19,3 +19,4 @@ size | 组件大小,可选值为 `small` `default` `large` | string | 'default
|
||||
spinning | 是否旋转 | boolean | true
|
||||
tip | 当作为包裹元素时,可以自定义描述文案 | string | -
|
||||
delay | 延迟显示加载效果的时间(防止闪烁) | number (毫秒) | -
|
||||
wrapperClassName | 包装器的类属性 | string | -
|
||||
|
Loading…
Reference in New Issue
Block a user