Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix button size style #47074

Merged
merged 9 commits into from
Jan 23, 2024
29 changes: 14 additions & 15 deletions components/button/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ const genTypeButtonStyle: GenerateStyle<ButtonToken> = (token) => {
};

// =============================== Size ===============================
const genSizeButtonStyle = (token: ButtonToken, sizePrefixCls: string = ''): CSSInterpolation => {
const genButtonStyle = (token: ButtonToken, prefixCls: string = ''): CSSInterpolation => {
const {
componentCls,
controlHeight,
Expand All @@ -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,
Expand Down Expand Up @@ -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<ButtonToken> = (token) =>
genSizeButtonStyle(
mergeToken<ButtonToken>(token, {
fontSize: token.contentFontSize,
lineHeight: token.contentLineHeight,
}),
);
const genSizeBaseButtonStyle: GenerateStyle<ButtonToken> = (token) => {
const baseToken = mergeToken<ButtonToken>(token, {
fontSize: token.contentFontSize,
lineHeight: token.contentLineHeight,
});
return genButtonStyle(baseToken, token.componentCls);
};

const genSizeSmallButtonStyle: GenerateStyle<ButtonToken> = (token) => {
const smallToken = mergeToken<ButtonToken>(token, {
Expand All @@ -471,7 +470,7 @@ const genSizeSmallButtonStyle: GenerateStyle<ButtonToken> = (token) => {
buttonIconOnlyFontSize: token.onlyIconSizeSM,
});

return genSizeButtonStyle(smallToken, `${token.componentCls}-sm`);
return genButtonStyle(smallToken, `${token.componentCls}-sm`);
};

const genSizeLargeButtonStyle: GenerateStyle<ButtonToken> = (token) => {
Expand All @@ -485,7 +484,7 @@ const genSizeLargeButtonStyle: GenerateStyle<ButtonToken> = (token) => {
buttonIconOnlyFontSize: token.onlyIconSizeLG,
});

return genSizeButtonStyle(largeToken, `${token.componentCls}-lg`);
return genButtonStyle(largeToken, `${token.componentCls}-lg`);
};

const genBlockButtonStyle: GenerateStyle<ButtonToken> = (token) => {
Expand All @@ -510,8 +509,8 @@ export default genStyleHooks(
genSharedButtonStyle(buttonToken),

// Size
genSizeSmallButtonStyle(buttonToken),
genSizeBaseButtonStyle(buttonToken),
genSizeSmallButtonStyle(buttonToken),
genSizeLargeButtonStyle(buttonToken),

// Block
Expand Down