import React from 'react'; import type { Theme } from '@ant-design/cssinjs'; import { createTheme } from '@ant-design/cssinjs'; import type { AliasToken, MapToken, OverrideToken, SeedToken } from './interface'; import defaultDerivative from './themes/default'; import defaultSeedToken from './themes/seed'; export const defaultTheme = createTheme(defaultDerivative); // ================================ Context ================================= // To ensure snapshot stable. We disable hashed in test env. export const defaultConfig = { token: defaultSeedToken, override: { override: defaultSeedToken }, hashed: true, }; export type ComponentsToken = { [key in keyof OverrideToken]?: OverrideToken[key] & { theme?: Theme; }; }; export interface DesignTokenProviderProps { token: Partial; theme?: Theme; components?: ComponentsToken; /** Just merge `token` & `override` at top to save perf */ override: { override: Partial } & ComponentsToken; hashed?: string | boolean; cssVar?: { prefix?: string; key?: string; }; } export const DesignTokenContext = React.createContext(defaultConfig);