Skip to content

Commit c91f709

Browse files
committed
feat: update spin
1 parent e5a8952 commit c91f709

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

build/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
dev: {
3-
componentName: 'form', // dev components
3+
componentName: 'spin', // dev components
44
},
55
};

components/spin/Spin.jsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ function shouldDelay(spinning, delay) {
3030
return !!spinning && !!delay && !isNaN(Number(delay));
3131
}
3232

33-
export function setDefaultIndicator(content) {
33+
export function setDefaultIndicator(Content) {
3434
defaultIndicator =
35-
typeof content.indicator === 'function'
36-
? content.indicator
35+
typeof Content.indicator === 'function'
36+
? Content.indicator
3737
: h => {
38-
return <content.indicator />;
38+
return <Content.indicator />;
3939
};
4040
}
4141

@@ -69,14 +69,13 @@ export default {
6969
});
7070
},
7171
beforeDestroy() {
72-
if (this.updateSpinning && this.updateSpinning.cancel) {
73-
this.updateSpinning.cancel();
74-
}
72+
this.cancelExistingSpin();
7573
},
7674
methods: {
7775
debouncifyUpdateSpinning(props) {
7876
const { delay } = props || this.$props;
7977
if (delay) {
78+
this.cancelExistingSpin();
8079
this.updateSpinning = debounce(this.originalUpdateSpinning, delay);
8180
}
8281
},
@@ -86,6 +85,12 @@ export default {
8685
this.setState({ sSpinning: spinning });
8786
}
8887
},
88+
cancelExistingSpin() {
89+
const { updateSpinning } = this;
90+
if (updateSpinning && updateSpinning.cancel) {
91+
updateSpinning.cancel();
92+
}
93+
},
8994
getChildren() {
9095
if (this.$slots && this.$slots.default) {
9196
return filterEmpty(this.$slots.default);
@@ -96,6 +101,10 @@ export default {
96101
// const h = this.$createElement
97102
const dotClassName = `${prefixCls}-dot`;
98103
let indicator = getComponentFromProp(this, 'indicator');
104+
// should not be render default indicator when indicator value is null
105+
if (indicator === null) {
106+
return null;
107+
}
99108
if (Array.isArray(indicator)) {
100109
indicator = filterEmpty(indicator);
101110
indicator = indicator.length === 1 ? indicator[0] : indicator;
@@ -110,10 +119,10 @@ export default {
110119

111120
return (
112121
<span class={`${dotClassName} ${prefixCls}-dot-spin`}>
113-
<i />
114-
<i />
115-
<i />
116-
<i />
122+
<i class={`${prefixCls}-dot-item`} />
123+
<i class={`${prefixCls}-dot-item`} />
124+
<i class={`${prefixCls}-dot-item`} />
125+
<i class={`${prefixCls}-dot-item`} />
117126
</span>
118127
);
119128
},

components/spin/__tests__/__snapshots__/demo.test.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`renders ./components/spin/demo/basic.md correctly 1`] = `
44
<div>
5-
<div class="ant-spin ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span></div>
5+
<div class="ant-spin ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span></div>
66
</div>
77
`;
88

@@ -33,7 +33,7 @@ exports[`renders ./components/spin/demo/delayAndDebounce.md correctly 1`] = `
3333

3434
exports[`renders ./components/spin/demo/inside.md correctly 1`] = `
3535
<div class="example">
36-
<div class="ant-spin ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span></div>
36+
<div class="ant-spin ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span></div>
3737
</div>
3838
`;
3939

@@ -52,17 +52,17 @@ exports[`renders ./components/spin/demo/nested.md correctly 1`] = `
5252

5353
exports[`renders ./components/spin/demo/size.md correctly 1`] = `
5454
<div>
55-
<div class="ant-spin ant-spin-sm ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span></div>
56-
<div class="ant-spin ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span></div>
57-
<div class="ant-spin ant-spin-lg ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span></div>
55+
<div class="ant-spin ant-spin-sm ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span></div>
56+
<div class="ant-spin ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span></div>
57+
<div class="ant-spin ant-spin-lg ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span></div>
5858
</div>
5959
`;
6060

6161
exports[`renders ./components/spin/demo/tip.md correctly 1`] = `
6262
<div>
6363
<div class="ant-spin-nested-loading">
6464
<div>
65-
<div class="ant-spin ant-spin-spinning ant-spin-show-text"><span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span>
65+
<div class="ant-spin ant-spin-spinning ant-spin-show-text"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span>
6666
<div class="ant-spin-text">Loading...</div>
6767
</div>
6868
</div>

components/spin/__tests__/__snapshots__/index.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`Spin should only affect the spin element when set style to a nested <Spin>xx</Spin> 1`] = `
44
<div class="ant-spin-nested-loading" style="background: red;">
55
<div>
6-
<div class="ant-spin ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span></div>
6+
<div class="ant-spin ant-spin-spinning"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span></div>
77
</div>
88
<div class="ant-spin-container ant-spin-blur">
99
<div>content</div>

0 commit comments

Comments
 (0)