From ea0276693496bd629774d256e2f65a40b81a6cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?= <7971419+crazyair@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:20:57 +0800 Subject: [PATCH] Fix button size style (#47074) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Button size style * fix: Button size style * feat: default 补充默认样式 * feat: style * feat: style * feat: style --- components/button/style/index.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/components/button/style/index.ts b/components/button/style/index.ts index fa0aea8877..7b4e8664cd 100644 --- a/components/button/style/index.ts +++ b/components/button/style/index.ts @@ -393,7 +393,7 @@ const genTypeButtonStyle: GenerateStyle = (token) => { }; // =============================== Size =============================== -const genSizeButtonStyle = (token: ButtonToken, sizePrefixCls: string = ''): CSSInterpolation => { +const genButtonStyle = (token: ButtonToken, prefixCls: string = ''): CSSInterpolation => { const { componentCls, controlHeight, @@ -408,9 +408,8 @@ const genSizeButtonStyle = (token: ButtonToken, sizePrefixCls: string = ''): CSS const iconOnlyCls = `${componentCls}-icon-only`; return [ - // Size { - [`${componentCls}${sizePrefixCls}`]: { + [`${prefixCls}`]: { fontSize, lineHeight, height: controlHeight, @@ -443,21 +442,21 @@ const genSizeButtonStyle = (token: ButtonToken, sizePrefixCls: string = ''): CSS // Shape - patch prefixCls again to override solid border radius style { - [`${componentCls}${componentCls}-circle${sizePrefixCls}`]: genCircleButtonStyle(token), + [`${componentCls}${componentCls}-circle${prefixCls}`]: genCircleButtonStyle(token), }, { - [`${componentCls}${componentCls}-round${sizePrefixCls}`]: genRoundButtonStyle(token), + [`${componentCls}${componentCls}-round${prefixCls}`]: genRoundButtonStyle(token), }, ]; }; -const genSizeBaseButtonStyle: GenerateStyle = (token) => - genSizeButtonStyle( - mergeToken(token, { - fontSize: token.contentFontSize, - lineHeight: token.contentLineHeight, - }), - ); +const genSizeBaseButtonStyle: GenerateStyle = (token) => { + const baseToken = mergeToken(token, { + fontSize: token.contentFontSize, + lineHeight: token.contentLineHeight, + }); + return genButtonStyle(baseToken, token.componentCls); +}; const genSizeSmallButtonStyle: GenerateStyle = (token) => { const smallToken = mergeToken(token, { @@ -471,7 +470,7 @@ const genSizeSmallButtonStyle: GenerateStyle = (token) => { buttonIconOnlyFontSize: token.onlyIconSizeSM, }); - return genSizeButtonStyle(smallToken, `${token.componentCls}-sm`); + return genButtonStyle(smallToken, `${token.componentCls}-sm`); }; const genSizeLargeButtonStyle: GenerateStyle = (token) => { @@ -485,7 +484,7 @@ const genSizeLargeButtonStyle: GenerateStyle = (token) => { buttonIconOnlyFontSize: token.onlyIconSizeLG, }); - return genSizeButtonStyle(largeToken, `${token.componentCls}-lg`); + return genButtonStyle(largeToken, `${token.componentCls}-lg`); }; const genBlockButtonStyle: GenerateStyle = (token) => { @@ -510,8 +509,8 @@ export default genStyleHooks( genSharedButtonStyle(buttonToken), // Size - genSizeSmallButtonStyle(buttonToken), genSizeBaseButtonStyle(buttonToken), + genSizeSmallButtonStyle(buttonToken), genSizeLargeButtonStyle(buttonToken), // Block