2023-06-05 17:45:33 +08:00
|
|
|
import { createTheme, getComputedToken } from '@ant-design/cssinjs';
|
2024-04-01 15:49:45 +08:00
|
|
|
|
2023-06-05 17:45:33 +08:00
|
|
|
import type { ThemeConfig } from '../config-provider/context';
|
|
|
|
import type { AliasToken } from './interface';
|
|
|
|
import defaultDerivative from './themes/default';
|
|
|
|
import seedToken from './themes/seed';
|
|
|
|
import formatToken from './util/alias';
|
|
|
|
|
|
|
|
const getDesignToken = (config?: ThemeConfig): AliasToken => {
|
|
|
|
const theme = config?.algorithm ? createTheme(config.algorithm) : createTheme(defaultDerivative);
|
|
|
|
const mergedToken = {
|
|
|
|
...seedToken,
|
|
|
|
...config?.token,
|
|
|
|
};
|
2024-04-01 15:49:45 +08:00
|
|
|
return getComputedToken(mergedToken as any, { override: config?.token }, theme, formatToken);
|
2023-06-05 17:45:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default getDesignToken;
|