support other props like style in Spin

This commit is contained in:
afc163 2016-05-20 14:25:02 +08:00
parent 91a8712bfa
commit 800b6801e8

View File

@ -62,20 +62,20 @@ export default class Spin extends React.Component {
} }
render() { render() {
const { className, size, prefixCls, tip } = this.props; const { className, size, prefixCls, tip, ...restProps } = this.props;
const { spinning } = this.state; const { spinning } = this.state;
const spinClassName = classNames({ const spinClassName = classNames({
[prefixCls]: true, [prefixCls]: true,
[`${prefixCls}-sm`]: size === 'small', [`${prefixCls}-sm`]: size === 'small',
[`${prefixCls}-lg`]: size === 'large', [`${prefixCls}-lg`]: size === 'large',
[className]: !!className,
[`${prefixCls}-spinning`]: spinning, [`${prefixCls}-spinning`]: spinning,
[`${prefixCls}-show-text`]: !!this.props.tip, [`${prefixCls}-show-text`]: !!this.props.tip,
[className]: !!className,
}); });
const spinElement = ( const spinElement = (
<div className={spinClassName}> <div {...restProps} className={spinClassName}>
<span className={`${prefixCls}-dot ${prefixCls}-dot-first`} /> <span className={`${prefixCls}-dot ${prefixCls}-dot-first`} />
<span className={`${prefixCls}-dot ${prefixCls}-dot-second`} /> <span className={`${prefixCls}-dot ${prefixCls}-dot-second`} />
<span className={`${prefixCls}-dot ${prefixCls}-dot-third`} /> <span className={`${prefixCls}-dot ${prefixCls}-dot-third`} />
@ -85,7 +85,7 @@ export default class Spin extends React.Component {
if (this.isNestedPattern()) { if (this.isNestedPattern()) {
return ( return (
<div className={spinning ? (`${prefixCls}-nested-loading`) : ''}> <div {...restProps} className={spinning ? (`${prefixCls}-nested-loading`) : ''}>
{spinElement} {spinElement}
<div className={`${prefixCls}-container`}> <div className={`${prefixCls}-container`}>
{this.props.children} {this.props.children}