Feat spin wrapper className. (#5425)

This commit is contained in:
Aaron Planell López 2017-03-21 10:12:43 +01:00 committed by 偏右
parent 5d348ec1b2
commit 45b0693bae
3 changed files with 11 additions and 2 deletions

View File

@ -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 | -

View File

@ -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"
>

View File

@ -19,3 +19,4 @@ size | 组件大小,可选值为 `small` `default` `large` | string | 'default
spinning | 是否旋转 | boolean | true
tip | 当作为包裹元素时,可以自定义描述文案 | string | -
delay | 延迟显示加载效果的时间(防止闪烁) | number (毫秒) | -
wrapperClassName | 包装器的类属性 | string | -