mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
chore: simplify style requirement
This commit is contained in:
parent
912ffb15d0
commit
4aac9f7522
@ -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 ==================================
|
||||||
|
@ -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);
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user