mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
Merge branch 'master' into copilot/fix-ci-issues
Signed-off-by: afc163 <afc163@gmail.com>
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
const { moduleNameMapper, transformIgnorePatterns } = require('./.jest');
|
||||
|
||||
// jest config for image snapshots
|
||||
module.exports = {
|
||||
setupFiles: ['./tests/setup.ts'],
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'md'],
|
||||
moduleNameMapper,
|
||||
transform: {
|
||||
'\\.tsx?$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'\\.js$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'^.+\\.(ts|tsx|js|mjs)$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'\\.md$': './node_modules/@ant-design/tools/lib/jest/demoPreprocessor',
|
||||
'\\.(jpg|png|gif|svg)$': './node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
||||
},
|
||||
|
||||
3
.jest.js
3
.jest.js
@@ -12,6 +12,7 @@ const compileModules = [
|
||||
'parse5',
|
||||
'@exodus',
|
||||
'jsdom',
|
||||
'@csstools',
|
||||
];
|
||||
|
||||
// cnpm use `_` as prefix
|
||||
@@ -63,7 +64,7 @@ module.exports = {
|
||||
],
|
||||
transform: {
|
||||
'\\.tsx?$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'\\.(m?)js$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'\\.(m?)js(m)?$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'\\.md$': './node_modules/@ant-design/tools/lib/jest/demoPreprocessor',
|
||||
'\\.(jpg|png|gif|svg)$': './node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
||||
},
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
const { moduleNameMapper, transformIgnorePatterns } = require('./.jest');
|
||||
|
||||
// jest config for server render environment
|
||||
module.exports = {
|
||||
setupFiles: ['./tests/setup.ts'],
|
||||
setupFilesAfterEnv: ['./tests/setupAfterEnv.ts'],
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'mjs', 'md'],
|
||||
moduleNameMapper,
|
||||
transform: {
|
||||
'\\.tsx?$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'\\.mjs$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'\\.js$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'^.+\\.(ts|tsx|js|mjs)$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
||||
'\\.md$': './node_modules/@ant-design/tools/lib/jest/demoPreprocessor',
|
||||
'\\.(jpg|png|gif|svg)$': './node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
||||
},
|
||||
|
||||
@@ -4,9 +4,9 @@ import { unit } from '@ant-design/cssinjs';
|
||||
|
||||
import { AggregationColor } from '../../color-picker/color';
|
||||
import { isBright } from '../../color-picker/components/ColorPresets';
|
||||
import { PresetColors } from '../../theme/interface';
|
||||
import type { FullToken, GenStyleFn, GetDefaultToken, PresetColorKey } from '../../theme/internal';
|
||||
import { getLineHeight, mergeToken } from '../../theme/internal';
|
||||
import { PresetColors } from '../../theme/interface';
|
||||
import getAlphaColor from '../../theme/util/getAlphaColor';
|
||||
|
||||
/** Component only token. Which will handle additional calculation of alias token */
|
||||
@@ -247,6 +247,10 @@ type ShadowColorMap = {
|
||||
[Key in `${PresetColorKey}ShadowColor`]: string;
|
||||
};
|
||||
|
||||
type PresetColorHoverActiveMap = {
|
||||
[Key in `${PresetColorKey}Hover` | `${PresetColorKey}Active`]: string;
|
||||
};
|
||||
|
||||
type GroupToken = {
|
||||
/**
|
||||
* @desc 按钮组边框颜色
|
||||
@@ -257,7 +261,11 @@ type GroupToken = {
|
||||
groupBorderColor: string;
|
||||
};
|
||||
|
||||
export interface ButtonToken extends FullToken<'Button'>, ShadowColorMap, GroupToken {
|
||||
export interface ButtonToken
|
||||
extends FullToken<'Button'>,
|
||||
ShadowColorMap,
|
||||
PresetColorHoverActiveMap,
|
||||
GroupToken {
|
||||
/**
|
||||
* @desc 按钮横向内边距
|
||||
* @descEN Horizontal padding of button
|
||||
|
||||
@@ -268,10 +268,10 @@ const genVariantStyle: GenerateStyle<ButtonToken> = (token) => {
|
||||
PresetColors.map((colorKey) => {
|
||||
const darkColor = token[`${colorKey}6`];
|
||||
const lightColor = token[`${colorKey}1`];
|
||||
const hoverColor = token[`${colorKey}5`];
|
||||
const hoverColor = token[`${colorKey}Hover`];
|
||||
const lightHoverColor = token[`${colorKey}2`];
|
||||
const lightActiveColor = token[`${colorKey}3`];
|
||||
const activeColor = token[`${colorKey}7`];
|
||||
const activeColor = token[`${colorKey}Active`];
|
||||
|
||||
const shadowColor = token[`${colorKey}ShadowColor`];
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { generate } from '@ant-design/colors';
|
||||
import type { DerivativeFunc } from '@ant-design/cssinjs';
|
||||
|
||||
import type { MapToken, PresetColorType, SeedToken } from '../../interface';
|
||||
import { PresetColors } from '../../interface/presetColors';
|
||||
import defaultAlgorithm from '../default';
|
||||
import { defaultPresetColors } from '../seed';
|
||||
import genColorMapToken from '../shared/genColorMapToken';
|
||||
@@ -29,6 +30,19 @@ const derivative: DerivativeFunc<SeedToken, MapToken> = (token, mapToken) => {
|
||||
generateNeutralColorPalettes,
|
||||
});
|
||||
|
||||
const presetColorHoverActiveTokens = PresetColors.reduce<Record<string, string>>(
|
||||
(prev, colorKey) => {
|
||||
const colorBase = token[colorKey as keyof PresetColorType];
|
||||
if (colorBase) {
|
||||
const colorPalette = generateColorPalettes(colorBase);
|
||||
prev[`${colorKey}Hover`] = colorPalette[7];
|
||||
prev[`${colorKey}Active`] = colorPalette[5];
|
||||
}
|
||||
return prev;
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
return {
|
||||
...mergedMapToken,
|
||||
|
||||
@@ -38,6 +52,8 @@ const derivative: DerivativeFunc<SeedToken, MapToken> = (token, mapToken) => {
|
||||
// Colors
|
||||
...colorMapToken,
|
||||
|
||||
...presetColorHoverActiveTokens,
|
||||
|
||||
// Customize selected item background color
|
||||
// https://github.com/ant-design/ant-design/issues/30524#issuecomment-871961867
|
||||
colorPrimaryBg: colorMapToken.colorPrimaryBorder,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { FastColor } from '@ant-design/fast-color';
|
||||
|
||||
import type { ColorMapToken, SeedToken } from '../../interface';
|
||||
import { PresetColors } from '../../interface/presetColors';
|
||||
import type { GenerateColorMap, GenerateNeutralColorMap } from '../ColorMap';
|
||||
|
||||
interface PaletteGenerators {
|
||||
@@ -37,6 +38,16 @@ export default function genColorMapToken(
|
||||
.mix(new FastColor(errorColors[3]), 50)
|
||||
.toHexString();
|
||||
|
||||
const presetColorTokens: Record<string, string> = {};
|
||||
PresetColors.forEach((colorKey) => {
|
||||
const colorBase = seed[colorKey];
|
||||
if (colorBase) {
|
||||
const colorPalette = generateColorPalettes(colorBase);
|
||||
presetColorTokens[`${colorKey}Hover`] = colorPalette[5];
|
||||
presetColorTokens[`${colorKey}Active`] = colorPalette[7];
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
...neutralColors,
|
||||
|
||||
@@ -101,6 +112,8 @@ export default function genColorMapToken(
|
||||
colorLink: linkColors[6],
|
||||
colorLinkActive: linkColors[7],
|
||||
|
||||
...presetColorTokens,
|
||||
|
||||
colorBgMask: new FastColor('#000').setA(0.45).toRgbString(),
|
||||
colorWhite: '#fff',
|
||||
};
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
"@rc-component/checkbox": "~1.0.1",
|
||||
"@rc-component/collapse": "~1.2.0",
|
||||
"@rc-component/color-picker": "~3.0.3",
|
||||
"@rc-component/dialog": "~1.8.2",
|
||||
"@rc-component/dialog": "~1.8.3",
|
||||
"@rc-component/drawer": "~1.4.1",
|
||||
"@rc-component/dropdown": "~1.0.2",
|
||||
"@rc-component/form": "~1.6.2",
|
||||
@@ -151,7 +151,7 @@
|
||||
"@rc-component/tree-select": "~1.6.0",
|
||||
"@rc-component/trigger": "^3.9.0",
|
||||
"@rc-component/upload": "~1.1.0",
|
||||
"@rc-component/util": "^1.8.1",
|
||||
"@rc-component/util": "^1.8.2",
|
||||
"clsx": "^2.1.1",
|
||||
"dayjs": "^1.11.11",
|
||||
"scroll-into-view-if-needed": "^3.1.0",
|
||||
|
||||
Reference in New Issue
Block a user