mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
94b3d03765
* feat: component theme * feat: component token support algorith, * docs: fix form * chore: add test * chore: fix test case * chore: code clean * chore: code clean * chore: code clean * docs: update toc * chore: update cssinjs * chore
29 lines
955 B
TypeScript
29 lines
955 B
TypeScript
import type { Theme } from '@ant-design/cssinjs';
|
|
import { createTheme } from '@ant-design/cssinjs';
|
|
import React from 'react';
|
|
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,
|
|
hashed: true,
|
|
};
|
|
|
|
export interface DesignTokenProviderProps {
|
|
token: Partial<AliasToken>;
|
|
theme?: Theme<SeedToken, MapToken>;
|
|
components?: {
|
|
[key in keyof OverrideToken]?: OverrideToken[key] & {
|
|
theme?: Theme<SeedToken, MapToken>;
|
|
};
|
|
};
|
|
hashed?: string | boolean;
|
|
}
|
|
|
|
export const DesignTokenContext = React.createContext<DesignTokenProviderProps>(defaultConfig);
|