Skip to content

Commit

Permalink
fix: has cssVar config (#164)
Browse files Browse the repository at this point in the history
* fix: has cssVar config

* fix: lint
  • Loading branch information
zombieJ authored Oct 23, 2024
1 parent e931a36 commit 0214fc6
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion components/theme/useToken.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createTheme, useCacheToken } from '@ant-design/cssinjs';
import { theme as antdTheme } from 'antd';
import { ignore, unitless } from 'antd/es/theme/useToken';
import formatToken from 'antd/es/theme/util/alias';
import React from 'react';

Expand All @@ -11,6 +12,28 @@ import type { AliasToken, GlobalToken, SeedToken } from './cssinjs-utils';

const defaultTheme: Theme<SeedToken, AliasToken> = createTheme(antdTheme.defaultAlgorithm);

const preserve: {
[key in keyof AliasToken]?: boolean;
} = {
screenXS: true,
screenXSMin: true,
screenXSMax: true,
screenSM: true,
screenSMMin: true,
screenSMMax: true,
screenMD: true,
screenMDMin: true,
screenMDMax: true,
screenLG: true,
screenLGMin: true,
screenLGMax: true,
screenXL: true,
screenXLMin: true,
screenXLMax: true,
screenXXL: true,
screenXXLMin: true,
};

export const getComputedToken = (
originToken: SeedToken,
overrideToken: DesignTokenProviderProps['components'] & {
Expand Down Expand Up @@ -75,7 +98,13 @@ export function useInternalToken(): [
salt: `${version}-${hashed || ''}`,
override,
getComputedToken,
cssVar,
cssVar: cssVar && {
prefix: cssVar.prefix,
key: cssVar.key,
unitless,
ignore,
preserve,
},
},
);
return [theme as Theme<SeedToken, AliasToken>, realToken, hashed ? hashId : '', token, cssVar];
Expand Down

0 comments on commit 0214fc6

Please sign in to comment.