mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +08:00
chore: refactor some code (#33034)
* Refactor some code * Apply suggestions from code review Co-authored-by: afc163 <afc163@gmail.com> * [CodeFactor] Apply fixes [ci skip] [skip ci] * rename abbr to sizeClassNameMap * refactor: Button size class name Co-authored-by: afc163 <afc163@gmail.com> Co-authored-by: codefactor-io <support@codefactor.io>
This commit is contained in:
parent
9b46aa5133
commit
de33041bb0
@ -177,12 +177,8 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
|
||||
};
|
||||
|
||||
// =============== Update Loading ===============
|
||||
let loadingOrDelay: Loading;
|
||||
if (typeof loading === 'object' && loading.delay) {
|
||||
loadingOrDelay = loading.delay || true;
|
||||
} else {
|
||||
loadingOrDelay = !!loading;
|
||||
}
|
||||
const loadingOrDelay: Loading =
|
||||
typeof loading === 'object' && loading.delay ? loading.delay || true : !!loading;
|
||||
|
||||
React.useEffect(() => {
|
||||
clearTimeout(delayTimeoutRef.current);
|
||||
@ -222,19 +218,9 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
|
||||
const prefixCls = getPrefixCls('btn', customizePrefixCls);
|
||||
const autoInsertSpace = autoInsertSpaceInButton !== false;
|
||||
|
||||
// large => lg
|
||||
// small => sm
|
||||
let sizeCls = '';
|
||||
switch (customizeSize || size) {
|
||||
case 'large':
|
||||
sizeCls = 'lg';
|
||||
break;
|
||||
case 'small':
|
||||
sizeCls = 'sm';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
const sizeClassNameMap = { large: 'lg', small: 'sm', middle: undefined };
|
||||
const sizeFullname = customizeSize || size;
|
||||
const sizeCls = sizeFullname ? sizeClassNameMap[sizeFullname] || '' : '';
|
||||
|
||||
const iconType = innerLoading ? 'loading' : icon;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user