fix: Input.Search large size button style (#48527)

* fix: Input.Search large size button style

* chore: adjust logic

* chore: rename
This commit is contained in:
二货爱吃白萝卜 2024-04-18 16:06:35 +08:00 committed by GitHub
parent 5fbca4afa9
commit f77302553d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 17 deletions

View File

@ -881,4 +881,7 @@ export default genStyleHooks(
];
},
initComponentToken,
{
resetFont: false,
},
);

View File

@ -107,29 +107,34 @@ export const genCommonStyle = (
token: DerivativeToken,
componentPrefixCls: string,
rootCls?: string,
resetFont?: boolean,
): CSSObject => {
const { fontFamily, fontSize } = token;
const prefixSelector = `[class^="${componentPrefixCls}"], [class*=" ${componentPrefixCls}"]`;
const rootPrefixSelector = rootCls ? `.${rootCls}` : prefixSelector;
const resetStyle: CSSObject = {
boxSizing: 'border-box',
'&::before, &::after': {
boxSizing: 'border-box',
},
};
let resetFontStyle: CSSObject = {};
if (resetFont !== false) {
resetFontStyle = {
fontFamily: token.fontFamily,
fontSize: token.fontSize,
};
}
return {
[rootPrefixSelector]: {
fontFamily,
fontSize,
boxSizing: 'border-box',
...resetFontStyle,
...resetStyle,
'&::before, &::after': {
boxSizing: 'border-box',
},
[prefixSelector]: {
boxSizing: 'border-box',
'&::before, &::after': {
boxSizing: 'border-box',
},
},
[prefixSelector]: resetStyle,
},
};
};

View File

@ -133,6 +133,7 @@ export default function genComponentStyleHook<C extends OverrideComponent>(
getDefaultToken?: GetDefaultToken<C>,
options: {
resetStyle?: boolean;
resetFont?: boolean;
// Deprecated token key map [["oldTokenKey", "newTokenKey"], ["oldTokenKey", "newTokenKey"]]
deprecatedTokens?: [ComponentTokenKey<C>, ComponentTokenKey<C>][];
/**
@ -243,7 +244,9 @@ export default function genComponentStyleHook<C extends OverrideComponent>(
});
flush(component, componentToken);
return [
options.resetStyle === false ? null : genCommonStyle(mergedToken, prefixCls, rootCls),
options.resetStyle === false
? null
: genCommonStyle(mergedToken, prefixCls, rootCls, options.resetFont),
styleInterpolation,
];
},
@ -378,6 +381,7 @@ export const genStyleHooks = <C extends OverrideComponent>(
getDefaultToken?: GetDefaultToken<C>,
options?: {
resetStyle?: boolean;
resetFont?: boolean;
deprecatedTokens?: [ComponentTokenKey<C>, ComponentTokenKey<C>][];
/**
* Component tokens that do not need unit.