Browse Source

style: remove Space font style (#40326)

* refactor: simplify code

* style: fix Space font style

* demo: fix Select demo
pull/41723/head
afc163 2 years ago
committed by GitHub
parent
commit
9619c8c37e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      components/space/style/index.tsx
  2. 8
      components/theme/util/genComponentStyleHook.ts

20
components/space/style/index.tsx

@ -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,
},
);

8
components/theme/util/genComponentStyleHook.ts

@ -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,
];

Loading…
Cancel
Save