mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
feat: App support cssVar (#45806)
* feat: App support cssVar * fix: fix * fix: fix * Apply suggestions from code review Signed-off-by: MadCcc <1075746765@qq.com> * Update components/app/style/index.ts Signed-off-by: MadCcc <1075746765@qq.com> --------- Signed-off-by: MadCcc <1075746765@qq.com> Co-authored-by: MadCcc <madccc@foxmail.com>
This commit is contained in:
parent
a53041f079
commit
684bb15258
@ -11,6 +11,7 @@ import useNotification from '../notification/useNotification';
|
||||
import type { AppConfig, useAppProps } from './context';
|
||||
import AppContext, { AppConfigContext } from './context';
|
||||
import useStyle from './style';
|
||||
import useCSSVar from './style/cssVar';
|
||||
|
||||
export interface AppProps<P = AnyObject> extends AppConfig {
|
||||
style?: React.CSSProperties;
|
||||
@ -36,7 +37,8 @@ const App: React.FC<AppProps> & { useApp: () => useAppProps } = (props) => {
|
||||
} = props;
|
||||
const { getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext);
|
||||
const prefixCls = getPrefixCls('app', customizePrefixCls);
|
||||
const [wrapSSR, hashId] = useStyle(prefixCls);
|
||||
const [, hashId] = useStyle(prefixCls);
|
||||
const wrapCSSVar = useCSSVar(prefixCls);
|
||||
const customClassName = classNames(hashId, prefixCls, className, rootClassName);
|
||||
|
||||
const appConfig = useContext<AppConfig>(AppConfigContext);
|
||||
@ -71,7 +73,7 @@ const App: React.FC<AppProps> & { useApp: () => useAppProps } = (props) => {
|
||||
style,
|
||||
};
|
||||
|
||||
return wrapSSR(
|
||||
return wrapCSSVar(
|
||||
<AppContext.Provider value={memoizedContextValue}>
|
||||
<AppConfigContext.Provider value={mergedAppConfig}>
|
||||
<Component {...(component === false ? undefined : rootProps)}>
|
||||
|
4
components/app/style/cssVar.ts
Normal file
4
components/app/style/cssVar.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { prepareComponentToken } from '.';
|
||||
import { genCSSVarRegister } from '../../theme/internal';
|
||||
|
||||
export default genCSSVarRegister<'App'>('App', prepareComponentToken);
|
@ -1,4 +1,4 @@
|
||||
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
||||
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
|
||||
import { genComponentStyleHook } from '../../theme/internal';
|
||||
|
||||
export type ComponentToken = {};
|
||||
@ -18,5 +18,7 @@ const genBaseStyle: GenerateStyle<AppToken> = (token) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const prepareComponentToken: GetDefaultToken<'App'> = () => ({});
|
||||
|
||||
// ============================== Export ==============================
|
||||
export default genComponentStyleHook('App', (token) => [genBaseStyle(token)]);
|
||||
export default genComponentStyleHook<'App'>('App', genBaseStyle, prepareComponentToken);
|
||||
|
Loading…
Reference in New Issue
Block a user