Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat spin wrapper className. #5425

Merged
merged 1 commit into from
Mar 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Feat spin wrapper className.
  • Loading branch information
aaronplanell committed Mar 21, 2017
commit 564d903a5f3d07ca7313c9cc75ea139a3178724a
1 change: 1 addition & 0 deletions components/spin/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | -
11 changes: 9 additions & 2 deletions components/spin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ export interface SpinProps {
size?: 'small' | 'default' | 'large';
tip?: string;
delay?: number;
wrapperClassName?: string;
}

export default class Spin extends React.Component<SpinProps, any> {
static defaultProps = {
prefixCls: 'ant-spin',
spinning: true,
size: 'default',
wrapperClassName: '',
};

static propTypes = {
prefixCls: PropTypes.string,
className: PropTypes.string,
spinning: PropTypes.bool,
size: PropTypes.oneOf(['small', 'default', 'large']),
wrapperClassName: PropTypes.string,
};

debounceTimeout: number;
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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,
Expand All @@ -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"
>
Expand Down
1 change: 1 addition & 0 deletions components/spin/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ size | 组件大小,可选值为 `small` `default` `large` | string | 'default
spinning | 是否旋转 | boolean | true
tip | 当作为包裹元素时,可以自定义描述文案 | string | -
delay | 延迟显示加载效果的时间(防止闪烁) | number (毫秒) | -
wrapperClassName | 包装器的类属性 | string | -