mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
fix: less var (#46250)
This commit is contained in:
parent
2d6ba24713
commit
7bd08ba257
@ -37,6 +37,7 @@ describe('Theme', () => {
|
||||
expect(result.current!.token).toEqual(
|
||||
expect.objectContaining({
|
||||
colorPrimary: '#1677ff',
|
||||
'blue-6': '#1677ff',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
@ -27,6 +27,7 @@ export type {
|
||||
} from './maps';
|
||||
export { PresetColors } from './presetColors';
|
||||
export type {
|
||||
LegacyColorPalettes,
|
||||
ColorPalettes,
|
||||
PresetColorKey,
|
||||
PresetColorType,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { ColorPalettes } from '../presetColors';
|
||||
import type { ColorPalettes, LegacyColorPalettes } from '../presetColors';
|
||||
import type { SeedToken } from '../seeds';
|
||||
import type { ColorMapToken } from './colors';
|
||||
import type { FontMapToken } from './font';
|
||||
@ -37,6 +37,7 @@ export interface CommonMapToken extends StyleMapToken {
|
||||
export interface MapToken
|
||||
extends SeedToken,
|
||||
ColorPalettes,
|
||||
LegacyColorPalettes,
|
||||
ColorMapToken,
|
||||
SizeMapToken,
|
||||
HeightMapToken,
|
||||
|
@ -14,12 +14,19 @@ export const PresetColors = [
|
||||
'gold',
|
||||
] as const;
|
||||
|
||||
export type PresetColorKey = typeof PresetColors[number];
|
||||
export type PresetColorKey = (typeof PresetColors)[number];
|
||||
|
||||
export type PresetColorType = Record<PresetColorKey, string>;
|
||||
|
||||
type ColorPaletteKeyIndex = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
||||
|
||||
export type LegacyColorPalettes = {
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
[key in `${keyof PresetColorType}-${ColorPaletteKeyIndex}`]: string;
|
||||
};
|
||||
|
||||
export type ColorPalettes = {
|
||||
[key in `${keyof PresetColorType}${ColorPaletteKeyIndex}`]: string;
|
||||
};
|
||||
|
@ -1,6 +1,12 @@
|
||||
import { generate } from '@ant-design/colors';
|
||||
import type { DerivativeFunc } from '@ant-design/cssinjs';
|
||||
import type { ColorPalettes, MapToken, PresetColorType, SeedToken } from '../../interface';
|
||||
import type {
|
||||
ColorPalettes,
|
||||
LegacyColorPalettes,
|
||||
MapToken,
|
||||
PresetColorType,
|
||||
SeedToken,
|
||||
} from '../../interface';
|
||||
import { defaultPresetColors } from '../seed';
|
||||
import genColorMapToken from '../shared/genColorMapToken';
|
||||
import { generateColorPalettes, generateNeutralColorPalettes } from './colors';
|
||||
@ -12,17 +18,21 @@ const derivative: DerivativeFunc<SeedToken, MapToken> = (token, mapToken) => {
|
||||
const colors = generate(token[colorKey], { theme: 'dark' });
|
||||
|
||||
return new Array(10).fill(1).reduce((prev, _, i) => {
|
||||
prev[`${colorKey}-${i + 1}`] = colors[i];
|
||||
prev[`${colorKey}${i + 1}`] = colors[i];
|
||||
return prev;
|
||||
}, {}) as ColorPalettes;
|
||||
}, {}) as ColorPalettes & LegacyColorPalettes;
|
||||
})
|
||||
.reduce((prev, cur) => {
|
||||
prev = {
|
||||
...prev,
|
||||
...cur,
|
||||
};
|
||||
return prev;
|
||||
}, {} as ColorPalettes);
|
||||
.reduce(
|
||||
(prev, cur) => {
|
||||
prev = {
|
||||
...prev,
|
||||
...cur,
|
||||
};
|
||||
return prev;
|
||||
},
|
||||
{} as ColorPalettes & LegacyColorPalettes,
|
||||
);
|
||||
|
||||
const mergedMapToken = mapToken ?? defaultAlgorithm(token);
|
||||
|
||||
|
@ -1,7 +1,13 @@
|
||||
import { generate } from '@ant-design/colors';
|
||||
import genControlHeight from '../shared/genControlHeight';
|
||||
import genSizeMapToken from '../shared/genSizeMapToken';
|
||||
import type { ColorPalettes, MapToken, PresetColorType, SeedToken } from '../../interface';
|
||||
import type {
|
||||
ColorPalettes,
|
||||
LegacyColorPalettes,
|
||||
MapToken,
|
||||
PresetColorType,
|
||||
SeedToken,
|
||||
} from '../../interface';
|
||||
import { defaultPresetColors } from '../seed';
|
||||
import genColorMapToken from '../shared/genColorMapToken';
|
||||
import genCommonMapToken from '../shared/genCommonMapToken';
|
||||
@ -14,17 +20,21 @@ export default function derivative(token: SeedToken): MapToken {
|
||||
const colors = generate(token[colorKey]);
|
||||
|
||||
return new Array(10).fill(1).reduce((prev, _, i) => {
|
||||
prev[`${colorKey}-${i + 1}`] = colors[i];
|
||||
prev[`${colorKey}${i + 1}`] = colors[i];
|
||||
return prev;
|
||||
}, {}) as ColorPalettes;
|
||||
}, {}) as ColorPalettes & LegacyColorPalettes;
|
||||
})
|
||||
.reduce((prev, cur) => {
|
||||
prev = {
|
||||
...prev,
|
||||
...cur,
|
||||
};
|
||||
return prev;
|
||||
}, {} as ColorPalettes);
|
||||
.reduce(
|
||||
(prev, cur) => {
|
||||
prev = {
|
||||
...prev,
|
||||
...cur,
|
||||
};
|
||||
return prev;
|
||||
},
|
||||
{} as ColorPalettes & LegacyColorPalettes,
|
||||
);
|
||||
|
||||
return {
|
||||
...token,
|
||||
|
Loading…
Reference in New Issue
Block a user