From 7b1a8e629d714aeb4d3200f72e93b4c7b5ebe228 Mon Sep 17 00:00:00 2001 From: wuxh Date: Thu, 15 Jun 2023 13:35:10 +0800 Subject: [PATCH] chore: update code Co-authored-by: wxh16144 --- components/button/style/index.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/components/button/style/index.ts b/components/button/style/index.ts index 68179dac8525..55368b76ff31 100644 --- a/components/button/style/index.ts +++ b/components/button/style/index.ts @@ -115,8 +115,12 @@ const genSharedButtonStyle: GenerateStyle = (token): CSS }; }; -const genHoverActiveButtonStyle = (hoverStyle: CSSObject, activeStyle: CSSObject): CSSObject => ({ - '&:not(:disabled)': { +const genHoverActiveButtonStyle = ( + btnCls: string, + hoverStyle: CSSObject, + activeStyle: CSSObject, +): CSSObject => ({ + [`&:not(:disabled, ${btnCls}-disabled)`]: { '&:hover': hoverStyle, '&:active': activeStyle, }, @@ -161,6 +165,7 @@ const genGhostButtonStyle = ( boxShadow: 'none', ...genHoverActiveButtonStyle( + btnCls, { backgroundColor: 'transparent', ...hoverStyle, @@ -180,7 +185,7 @@ const genGhostButtonStyle = ( }); const genSolidDisabledButtonStyle: GenerateStyle = (token) => ({ - '&:disabled': { + [`&:disabled, &${token.componentCls}-disabled`]: { ...genDisabledStyle(token), }, }); @@ -206,6 +211,7 @@ const genDefaultButtonStyle: GenerateStyle = (token) => boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.controlTmpOutline}`, ...genHoverActiveButtonStyle( + token.componentCls, { color: token.colorPrimaryHover, borderColor: token.colorPrimaryHover, @@ -229,6 +235,7 @@ const genDefaultButtonStyle: GenerateStyle = (token) => borderColor: token.colorError, ...genHoverActiveButtonStyle( + token.componentCls, { color: token.colorErrorHover, borderColor: token.colorErrorBorderHover, @@ -260,6 +267,7 @@ const genPrimaryButtonStyle: GenerateStyle = (token) => boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.controlOutline}`, ...genHoverActiveButtonStyle( + token.componentCls, { color: token.colorTextLightSolid, backgroundColor: token.colorPrimaryHover, @@ -291,6 +299,7 @@ const genPrimaryButtonStyle: GenerateStyle = (token) => boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.colorErrorOutline}`, ...genHoverActiveButtonStyle( + token.componentCls, { backgroundColor: token.colorErrorHover, }, @@ -329,6 +338,7 @@ const genLinkButtonStyle: GenerateStyle = (token) => ({ color: token.colorLink, ...genHoverActiveButtonStyle( + token.componentCls, { color: token.colorLinkHover, }, @@ -343,6 +353,7 @@ const genLinkButtonStyle: GenerateStyle = (token) => ({ color: token.colorError, ...genHoverActiveButtonStyle( + token.componentCls, { color: token.colorErrorHover, }, @@ -358,6 +369,7 @@ const genLinkButtonStyle: GenerateStyle = (token) => ({ // Type: Text const genTextButtonStyle: GenerateStyle = (token) => ({ ...genHoverActiveButtonStyle( + token.componentCls, { color: token.colorText, backgroundColor: token.colorBgTextHover, @@ -375,6 +387,7 @@ const genTextButtonStyle: GenerateStyle = (token) => ({ ...genPureDisabledButtonStyle(token), ...genHoverActiveButtonStyle( + token.componentCls, { color: token.colorErrorHover, backgroundColor: token.colorErrorBg,