Skip to content

Commit

Permalink
chore: update code
Browse files Browse the repository at this point in the history
Co-authored-by: wxh16144 <[email protected]>
  • Loading branch information
2 people authored and committed Jun 19, 2023
1 parent 8c5697f commit 7b1a8e6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions components/button/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ const genSharedButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (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,
},
Expand Down Expand Up @@ -161,6 +165,7 @@ const genGhostButtonStyle = (
boxShadow: 'none',

...genHoverActiveButtonStyle(
btnCls,
{
backgroundColor: 'transparent',
...hoverStyle,
Expand All @@ -180,7 +185,7 @@ const genGhostButtonStyle = (
});

const genSolidDisabledButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) => ({
'&:disabled': {
[`&:disabled, &${token.componentCls}-disabled`]: {
...genDisabledStyle(token),
},
});
Expand All @@ -206,6 +211,7 @@ const genDefaultButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) =>
boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.controlTmpOutline}`,

...genHoverActiveButtonStyle(
token.componentCls,
{
color: token.colorPrimaryHover,
borderColor: token.colorPrimaryHover,
Expand All @@ -229,6 +235,7 @@ const genDefaultButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) =>
borderColor: token.colorError,

...genHoverActiveButtonStyle(
token.componentCls,
{
color: token.colorErrorHover,
borderColor: token.colorErrorBorderHover,
Expand Down Expand Up @@ -260,6 +267,7 @@ const genPrimaryButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) =>
boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.controlOutline}`,

...genHoverActiveButtonStyle(
token.componentCls,
{
color: token.colorTextLightSolid,
backgroundColor: token.colorPrimaryHover,
Expand Down Expand Up @@ -291,6 +299,7 @@ const genPrimaryButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) =>
boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.colorErrorOutline}`,

...genHoverActiveButtonStyle(
token.componentCls,
{
backgroundColor: token.colorErrorHover,
},
Expand Down Expand Up @@ -329,6 +338,7 @@ const genLinkButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) => ({
color: token.colorLink,

...genHoverActiveButtonStyle(
token.componentCls,
{
color: token.colorLinkHover,
},
Expand All @@ -343,6 +353,7 @@ const genLinkButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) => ({
color: token.colorError,

...genHoverActiveButtonStyle(
token.componentCls,
{
color: token.colorErrorHover,
},
Expand All @@ -358,6 +369,7 @@ const genLinkButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) => ({
// Type: Text
const genTextButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) => ({
...genHoverActiveButtonStyle(
token.componentCls,
{
color: token.colorText,
backgroundColor: token.colorBgTextHover,
Expand All @@ -375,6 +387,7 @@ const genTextButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token) => ({

...genPureDisabledButtonStyle(token),
...genHoverActiveButtonStyle(
token.componentCls,
{
color: token.colorErrorHover,
backgroundColor: token.colorErrorBg,
Expand Down

0 comments on commit 7b1a8e6

Please sign in to comment.