mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-30 12:28:33 +08:00
5f1dd427df
* feat: css variables theme * chore: temp * chore temp * chore: temp * chore: temp * chore: tmp * chore: temp * feat: full css variables * feat: css var * chore: code clean * chore: code clean * chore: bump cssinjs * test: fix lint * feat: better key logic * feat: useStyle add param rootCls for cssVar scope * chore: fix lint * chore: code clean * chore: fix lint * perf: minimize component token size * chore: make useId compatible * chore: code clean * chore: fix lint * chore: code clean * chore: update test case * feat: genCSSVarRegister * feat: RPN Calculator * chore: add test for css var * chore: code clean * test: add test for calc * feat: better calc type * chore: code clean * chore: update size limit * feat: better useCSSVar * chore: better useCSSVar * test: add cov * feat: better calc logic * test: add test case * chore: code clean --------- Signed-off-by: MadCcc <madccc@foxmail.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
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<SeedToken, MapToken>;
|
|
};
|
|
};
|
|
|
|
export interface DesignTokenProviderProps {
|
|
token: Partial<AliasToken>;
|
|
theme?: Theme<SeedToken, MapToken>;
|
|
components?: ComponentsToken;
|
|
/** Just merge `token` & `override` at top to save perf */
|
|
override: { override: Partial<AliasToken> } & ComponentsToken;
|
|
hashed?: string | boolean;
|
|
cssVar?: {
|
|
prefix?: string;
|
|
key?: string;
|
|
};
|
|
}
|
|
|
|
export const DesignTokenContext = React.createContext<DesignTokenProviderProps>(defaultConfig);
|