chore: simplify style requirement

This commit is contained in:
zombiej 2022-02-27 22:17:17 +08:00
parent 912ffb15d0
commit 4aac9f7522
4 changed files with 7 additions and 7 deletions

View File

@ -86,7 +86,6 @@ export const DesignTokenContext = React.createContext<{
// ================================== Hook ================================== // ================================== Hook ==================================
export function useToken() { export function useToken() {
const { iconPrefixCls } = React.useContext(ConfigContext);
const { token: rootDesignToken, hashed } = React.useContext(DesignTokenContext); const { token: rootDesignToken, hashed } = React.useContext(DesignTokenContext);
const theme = React.useContext(ThemeContext); const theme = React.useContext(ThemeContext);
@ -95,7 +94,7 @@ export function useToken() {
const [token, hashId] = useCacheToken(theme, [defaultDesignToken, rootDesignToken], { const [token, hashId] = useCacheToken(theme, [defaultDesignToken, rootDesignToken], {
salt, salt,
}); });
return [theme, token, iconPrefixCls, hashed ? hashId : '']; return [theme, token, hashed ? hashId : ''];
} }
// ================================== Util ================================== // ================================== Util ==================================

View File

@ -154,11 +154,12 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
...rest ...rest
} = props; } = props;
const { getPrefixCls, autoInsertSpaceInButton, direction } = React.useContext(ConfigContext); const { getPrefixCls, autoInsertSpaceInButton, direction, iconPrefixCls } =
React.useContext(ConfigContext);
const prefixCls = getPrefixCls('btn', customizePrefixCls); const prefixCls = getPrefixCls('btn', customizePrefixCls);
// Style // Style
const wrapSSR = useStyle(prefixCls); const wrapSSR = useStyle(prefixCls, iconPrefixCls);
const size = React.useContext(SizeContext); const size = React.useContext(SizeContext);
const [innerLoading, setLoading] = React.useState<Loading>(!!loading); const [innerLoading, setLoading] = React.useState<Loading>(!!loading);

View File

@ -373,8 +373,8 @@ const genSizeLargeButtonStyle = (
}; };
// ============================== Export ============================== // ============================== Export ==============================
export default function useStyle(prefixCls: string) { export default function useStyle(prefixCls: string, iconPrefixCls: string) {
const [theme, token, iconPrefixCls, hashId] = useToken(); const [theme, token, hashId] = useToken();
return useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => [ return useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => [
// Shared // Shared

View File

@ -25,7 +25,7 @@ export interface ConfigConsumerProps {
getTargetContainer?: () => HTMLElement; getTargetContainer?: () => HTMLElement;
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement; getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
rootPrefixCls?: string; rootPrefixCls?: string;
iconPrefixCls?: string; iconPrefixCls: string;
getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => string; getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => string;
renderEmpty: RenderEmptyHandler; renderEmpty: RenderEmptyHandler;
csp?: CSPConfig; csp?: CSPConfig;