ant-design/components/theme/index.tsx

44 lines
1.3 KiB
TypeScript
Raw Normal View History

/* eslint-disable import/prefer-default-export */
import getDesignToken from './getDesignToken';
2023-08-02 10:54:27 +08:00
import type { GlobalToken, MappingAlgorithm } from './interface';
2024-08-22 20:05:45 +08:00
import {
defaultConfig,
DesignTokenContext as InternalDesignTokenContext,
useToken as useInternalToken,
} from './internal';
import compactAlgorithm from './themes/compact';
import darkAlgorithm from './themes/dark';
import defaultAlgorithm from './themes/default';
// ZombieJ: We export as object to user but array in internal.
// This is used to minimize the bundle size for antd package but safe to refactor as object also.
// Please do not export internal `useToken` directly to avoid something export unexpected.
/** Get current context Design Token. Will be different if you are using nest theme config. */
function useToken() {
const [theme, token, hashId] = useInternalToken();
return { theme, token, hashId };
}
2023-08-02 10:54:27 +08:00
export type { GlobalToken, MappingAlgorithm };
2023-01-24 17:42:42 +08:00
export default {
/** Default seedToken */
defaultSeed: defaultConfig.token,
useToken,
defaultAlgorithm,
darkAlgorithm,
compactAlgorithm,
getDesignToken,
2024-08-22 20:05:45 +08:00
/**
2024-08-26 15:46:45 +08:00
* @private Private variable
2024-08-22 20:05:45 +08:00
* @warring 🔥 Do not use in production. 🔥
*/
defaultConfig,
/**
2024-08-26 15:46:45 +08:00
* @private Private variable
2024-08-22 20:05:45 +08:00
* @warring 🔥 Do not use in production. 🔥
*/
_internalContext: InternalDesignTokenContext,
};