From 8cb60ad7f1e30f0c201d8a2cd68fce3f913e4521 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Thu, 7 Apr 2022 00:19:37 +0800 Subject: [PATCH] feat: provide antCls in token (#34889) --- .../_util/theme/util/genComponentStyleHook.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/components/_util/theme/util/genComponentStyleHook.ts b/components/_util/theme/util/genComponentStyleHook.ts index 40090059c3..8c5fd760b4 100644 --- a/components/_util/theme/util/genComponentStyleHook.ts +++ b/components/_util/theme/util/genComponentStyleHook.ts @@ -15,12 +15,13 @@ export type StyleInfo = { rootPrefixCls: string; iconPrefixCls: string; }; -export type TokenWithComponentCls = T & { +export type TokenWithCommonCls = T & { componentCls: string; prefixCls: string; iconCls: string; + antCls: string; }; -export type FullToken = TokenWithComponentCls< +export type FullToken = TokenWithCommonCls< GlobalTokenWithComponent >; @@ -34,6 +35,7 @@ function genComponentStyleHook( 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( }); } const mergedToken = mergeToken< - TokenWithComponentCls> + TokenWithCommonCls> >( proxyToken, - { componentCls: `.${prefixCls}`, prefixCls, iconCls: `.${iconPrefixCls}` }, + { + componentCls: `.${prefixCls}`, + prefixCls, + iconCls: `.${iconPrefixCls}`, + antCls: `.${rootPrefixCls}`, + }, mergedComponentToken, ); const styleInterpolation = styleFn(mergedToken as unknown as FullToken, { hashId, prefixCls, - rootPrefixCls: getPrefixCls(), + rootPrefixCls, iconPrefixCls, }); flush(component);