Skip to content

Commit da10933

Browse files
committed
fix: add button loading animation
1 parent aa05d36 commit da10933

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ exports[`Button renders Chinese characters correctly 3`] = `
3636
</button>
3737
`;
3838

39-
exports[`Button renders Chinese characters correctly 4`] = `<button class="ant-btn ant-btn-loading" type="button"><span class="ant-btn-loading-icon"><span role="img" aria-label="loading" class="anticon anticon-loading"><svg focusable="false" class="anticon-spin" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="0 0 1024 1024"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span></span><span>按 钮</span></button>`;
39+
exports[`Button renders Chinese characters correctly 4`] = `<button class="ant-btn ant-btn-loading" type="button"><span role="img" aria-label="loading" class="anticon anticon-loading"><svg focusable="false" class="anticon-spin" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="0 0 1024 1024"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span><span>按 钮</span></button>`;
4040

41-
exports[`Button renders Chinese characters correctly 5`] = `<button class="ant-btn ant-btn-loading" type="button"><span class="ant-btn-loading-icon"><span role="img" aria-label="loading" class="anticon anticon-loading"><svg focusable="false" class="anticon-spin" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="0 0 1024 1024"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span></span><span>按 钮</span></button>`;
41+
exports[`Button renders Chinese characters correctly 5`] = `<button class="ant-btn ant-btn-loading" type="button"><span role="img" aria-label="loading" class="anticon anticon-loading"><svg focusable="false" class="anticon-spin" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="0 0 1024 1024"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span><span>按 钮</span></button>`;
4242

4343
exports[`Button renders Chinese characters correctly 6`] = `
4444
<button class="ant-btn ant-btn-two-chinese-chars" type="button">

components/button/button.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,7 @@ export default defineComponent({
176176
onClick: handleClick,
177177
};
178178

179-
const iconNode = innerLoading.value ? (
180-
<span class={`${prefixCls.value}-loading-icon`}>
181-
<LoadingOutlined />
182-
</span>
183-
) : (
184-
icon
185-
);
179+
const iconNode = innerLoading.value ? <LoadingOutlined /> : icon;
186180

187181
const kids = children.map(child =>
188182
insertSpace(child, isNeedInserted && autoInsertSpace.value),

components/button/style/index.less

+28-14
Original file line numberDiff line numberDiff line change
@@ -155,25 +155,39 @@
155155
}
156156
}
157157

158-
& > &-loading-icon {
159-
transition: all 0.3s @ease-in-out;
160-
161-
.@{iconfont-css-prefix} {
162-
padding-right: @padding-xs;
163-
animation: none;
164-
// for smooth button padding transition
165-
svg {
166-
animation: loadingCircle 1s infinite linear;
167-
}
158+
&&-loading:not(&-circle):not(&-circle-outline):not(&-icon-only) {
159+
padding-left: 29px;
160+
.@{iconfont-css-prefix}:not(:last-child) {
161+
margin-left: -14px;
168162
}
163+
}
169164

170-
&:only-child {
171-
.@{iconfont-css-prefix} {
172-
padding-right: 0;
173-
}
165+
&-sm&-loading:not(&-circle):not(&-circle-outline):not(&-icon-only) {
166+
padding-left: 24px;
167+
.@{iconfont-css-prefix} {
168+
margin-left: -17px;
174169
}
175170
}
176171

172+
// & > &-loading-icon {
173+
// transition: all 0.3s @ease-in-out;
174+
175+
// .@{iconfont-css-prefix} {
176+
// padding-right: @padding-xs;
177+
// animation: none;
178+
// // for smooth button padding transition
179+
// svg {
180+
// animation: loadingCircle 1s infinite linear;
181+
// }
182+
// }
183+
184+
// &:only-child {
185+
// .@{iconfont-css-prefix} {
186+
// padding-right: 0;
187+
// }
188+
// }
189+
// }
190+
177191
&-group {
178192
.btn-group(@btn-prefix-cls);
179193
}

0 commit comments

Comments
 (0)