style: remove Space font style (#40326)

* refactor: simplify code

* style: fix Space font style

* demo: fix Select demo
This commit is contained in:
afc163 2023-04-10 10:29:26 +08:00 committed by GitHub
parent 862ce2eba5
commit 9619c8c37e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 9 deletions

View File

@ -38,17 +38,21 @@ const genSpaceStyle: GenerateStyle<SpaceToken> = (token) => {
alignItems: 'baseline',
},
},
[`${componentCls}-item`]: {
'&:empty': {
display: 'none',
},
[`${componentCls}-item:empty`]: {
display: 'none',
},
},
};
};
// ============================== Export ==============================
export default genComponentStyleHook('Space', (token) => [
genSpaceStyle(token),
genSpaceCompactStyle(token),
]);
export default genComponentStyleHook(
'Space',
(token) => [genSpaceStyle(token), genSpaceCompactStyle(token)],
() => ({}),
{
// Space component don't apply extra font style
// https://github.com/ant-design/ant-design/issues/40315
resetStyle: false,
},
);

View File

@ -41,6 +41,9 @@ export default function genComponentStyleHook<ComponentName extends OverrideComp
getDefaultToken?:
| OverrideTokenWithoutDerivative[ComponentName]
| ((token: GlobalToken) => OverrideTokenWithoutDerivative[ComponentName]),
options?: {
resetStyle?: boolean;
},
) {
return (prefixCls: string): UseComponentStyleResult => {
const [theme, token, hashId] = useToken();
@ -93,7 +96,10 @@ export default function genComponentStyleHook<ComponentName extends OverrideComp
overrideComponentToken: token[component],
});
flush(component, mergedComponentToken);
return [genCommonStyle(token, prefixCls), styleInterpolation];
return [
options?.resetStyle === false ? null : genCommonStyle(token, prefixCls),
styleInterpolation,
];
}),
hashId,
];