Browse Source

feat: provide antCls in token (#34889)

pull/34896/head
MadCcc 3 years ago
committed by GitHub
parent
commit
8cb60ad7f1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      components/_util/theme/util/genComponentStyleHook.ts

17
components/_util/theme/util/genComponentStyleHook.ts

@ -15,12 +15,13 @@ export type StyleInfo = {
rootPrefixCls: string;
iconPrefixCls: string;
};
export type TokenWithComponentCls<T> = T & {
export type TokenWithCommonCls<T> = T & {
componentCls: string;
prefixCls: string;
iconCls: string;
antCls: string;
};
export type FullToken<ComponentName extends OverrideComponent> = TokenWithComponentCls<
export type FullToken<ComponentName extends OverrideComponent> = TokenWithCommonCls<
GlobalTokenWithComponent<ComponentName>
>;
@ -34,6 +35,7 @@ function genComponentStyleHook<ComponentName extends OverrideComponent>(
return (prefixCls: string): UseComponentStyleResult => {
const [theme, token, hashId] = useToken();
const { getPrefixCls, iconPrefixCls } = useContext(ConfigContext);
const rootPrefixCls = getPrefixCls();
return [
useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => {
@ -51,17 +53,22 @@ function genComponentStyleHook<ComponentName extends OverrideComponent>(
});
}
const mergedToken = mergeToken<
TokenWithComponentCls<GlobalTokenWithComponent<OverrideComponent>>
TokenWithCommonCls<GlobalTokenWithComponent<OverrideComponent>>
>(
proxyToken,
{ componentCls: `.${prefixCls}`, prefixCls, iconCls: `.${iconPrefixCls}` },
{
componentCls: `.${prefixCls}`,
prefixCls,
iconCls: `.${iconPrefixCls}`,
antCls: `.${rootPrefixCls}`,
},
mergedComponentToken,
);
const styleInterpolation = styleFn(mergedToken as unknown as FullToken<ComponentName>, {
hashId,
prefixCls,
rootPrefixCls: getPrefixCls(),
rootPrefixCls,
iconPrefixCls,
});
flush(component);

Loading…
Cancel
Save