mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 01:29:11 +08:00
9f88c1238a
* feat: token update * chore: update test * chore: lint * chore: code clean * test: update test case * feat: radius token update * fix: form size * chore: fix steps style * chore: code clean * chore: update test case
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import type { MapToken } from '../../interface';
|
|
|
|
const genRadius = (
|
|
radiusBase: number,
|
|
): Pick<
|
|
MapToken,
|
|
'borderRadiusXS' | 'borderRadiusSM' | 'borderRadiusLG' | 'borderRadius' | 'borderRadiusOuter'
|
|
> => {
|
|
let radiusLG = radiusBase;
|
|
let radiusSM = radiusBase;
|
|
let radiusXS = radiusBase;
|
|
let radiusOuter = radiusBase;
|
|
|
|
// radiusLG
|
|
if (radiusBase < 6 && radiusBase >= 5) {
|
|
radiusLG = radiusBase + 1;
|
|
} else if (radiusBase < 16 && radiusBase >= 6) {
|
|
radiusLG = radiusBase + 2;
|
|
} else if (radiusBase >= 16) {
|
|
radiusLG = 16;
|
|
}
|
|
|
|
// radiusSM
|
|
if (radiusBase < 7 && radiusBase >= 5) {
|
|
radiusSM = 4;
|
|
} else if (radiusBase < 8 && radiusBase >= 7) {
|
|
radiusSM = 5;
|
|
} else if (radiusBase < 14 && radiusBase >= 8) {
|
|
radiusSM = 6;
|
|
} else if (radiusBase < 16 && radiusBase >= 14) {
|
|
radiusSM = 7;
|
|
} else if (radiusBase >= 16) {
|
|
radiusSM = 8;
|
|
}
|
|
|
|
// radiusXS
|
|
if (radiusBase < 6 && radiusBase >= 2) {
|
|
radiusXS = 1;
|
|
} else if (radiusBase >= 6) {
|
|
radiusXS = 2;
|
|
}
|
|
|
|
// radiusOuter
|
|
if (radiusBase > 4 && radiusBase < 8) {
|
|
radiusOuter = 4;
|
|
} else if (radiusBase >= 8) {
|
|
radiusOuter = 6;
|
|
}
|
|
|
|
return {
|
|
borderRadius: radiusBase > 16 ? 16 : radiusBase,
|
|
borderRadiusXS: radiusXS,
|
|
borderRadiusSM: radiusSM,
|
|
borderRadiusLG: radiusLG,
|
|
borderRadiusOuter: radiusOuter,
|
|
};
|
|
};
|
|
|
|
export default genRadius;
|