2022-03-21 16:48:25 +08:00
|
|
|
import { generate } from '@ant-design/colors';
|
|
|
|
import { TinyColor } from '@ctrl/tinycolor';
|
|
|
|
import type { AliasToken, DerivativeToken, OverrideToken } from '../interface';
|
|
|
|
|
|
|
|
/** Raw merge of `@ant-design/cssinjs` token. Which need additional process */
|
|
|
|
type RawMergedToken = DerivativeToken & OverrideToken;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Seed (designer) > Derivative (designer) > Alias (developer).
|
|
|
|
*
|
|
|
|
* Merge seed & derivative & override token and generate alias token for developer.
|
|
|
|
*/
|
|
|
|
export default function formatToken(derivativeToken: RawMergedToken): AliasToken {
|
|
|
|
const { derivative, ...restToken } = derivativeToken;
|
|
|
|
|
|
|
|
const mergedToken = {
|
|
|
|
...restToken,
|
|
|
|
...derivative,
|
|
|
|
};
|
|
|
|
|
2022-03-22 09:37:37 +08:00
|
|
|
const { fontSizes, lineHeights } = mergedToken;
|
|
|
|
|
2022-03-21 16:48:25 +08:00
|
|
|
// FIXME: tmp
|
|
|
|
const primaryColors = generate(mergedToken.colorPrimary);
|
|
|
|
const infoColors = generate(mergedToken.colorInfo);
|
|
|
|
const successColors = generate(mergedToken.colorSuccess);
|
|
|
|
const warningColors = generate(mergedToken.colorWarning);
|
|
|
|
const errorColors = generate(mergedToken.colorError);
|
2022-03-30 14:13:36 +08:00
|
|
|
const screenXS = 480;
|
|
|
|
const screenSM = 576;
|
|
|
|
const screenMD = 768;
|
|
|
|
const screenLG = 992;
|
|
|
|
const screenXL = 1200;
|
|
|
|
const screenXXL = 1600;
|
2022-03-21 16:48:25 +08:00
|
|
|
|
2022-03-29 15:57:39 +08:00
|
|
|
const fontSizeSM = fontSizes[0];
|
|
|
|
|
2022-03-21 16:48:25 +08:00
|
|
|
// Generate alias token
|
|
|
|
const aliasToken: AliasToken = {
|
|
|
|
...mergedToken,
|
|
|
|
|
|
|
|
// Colors
|
2022-03-22 13:26:29 +08:00
|
|
|
colorTextSecondary: mergedToken.colorTextBelow,
|
|
|
|
colorTextDisabled: mergedToken.colorTextBelow2,
|
2022-03-22 20:02:04 +08:00
|
|
|
colorPlaceholder: mergedToken.colorTextBelow2,
|
|
|
|
colorTextHeading: mergedToken.colorText,
|
|
|
|
|
|
|
|
colorBgContainer: mergedToken.colorBgBelow2,
|
2022-03-29 15:57:39 +08:00
|
|
|
colorBgContainerSecondary: mergedToken.colorBg3,
|
2022-03-22 20:02:04 +08:00
|
|
|
colorBgComponent: mergedToken.colorBg,
|
2022-03-24 14:30:48 +08:00
|
|
|
colorBgComponentSecondary: mergedToken.colorBg2,
|
2022-03-22 20:02:04 +08:00
|
|
|
colorBgComponentDisabled: mergedToken.colorBgBelow2,
|
2022-03-22 13:26:29 +08:00
|
|
|
|
2022-03-24 14:30:48 +08:00
|
|
|
colorLink: mergedToken.colorPrimary,
|
|
|
|
colorLinkHover: primaryColors[4],
|
|
|
|
colorLinkActive: primaryColors[6],
|
|
|
|
|
|
|
|
colorAction: mergedToken.colorTextBelow,
|
|
|
|
colorActionHover: mergedToken.colorText,
|
|
|
|
|
2022-03-22 09:37:37 +08:00
|
|
|
// Font
|
2022-03-29 15:57:39 +08:00
|
|
|
fontSizeSM,
|
2022-03-22 09:37:37 +08:00
|
|
|
fontSize: fontSizes[1],
|
|
|
|
fontSizeLG: fontSizes[2],
|
|
|
|
fontSizeXL: fontSizes[3],
|
|
|
|
fontSizeHeading1: fontSizes[6],
|
|
|
|
fontSizeHeading2: fontSizes[5],
|
|
|
|
fontSizeHeading3: fontSizes[4],
|
|
|
|
fontSizeHeading4: fontSizes[3],
|
|
|
|
fontSizeHeading5: fontSizes[2],
|
2022-03-29 15:57:39 +08:00
|
|
|
fontSizeIcon: fontSizeSM,
|
2022-03-22 09:37:37 +08:00
|
|
|
|
|
|
|
lineHeight: lineHeights[1],
|
|
|
|
lineHeightLG: lineHeights[2],
|
2022-05-20 14:33:33 +08:00
|
|
|
lineHeightSM: lineHeights[0],
|
2022-03-22 09:37:37 +08:00
|
|
|
|
|
|
|
lineHeightHeading1: lineHeights[6],
|
|
|
|
lineHeightHeading2: lineHeights[5],
|
|
|
|
lineHeightHeading3: lineHeights[4],
|
|
|
|
lineHeightHeading4: lineHeights[3],
|
|
|
|
lineHeightHeading5: lineHeights[2],
|
|
|
|
|
2022-03-22 13:26:29 +08:00
|
|
|
// Control
|
|
|
|
controlLineWidth: mergedToken.lineWidth,
|
|
|
|
controlOutlineWidth: mergedToken.lineWidth * 2,
|
2022-03-22 20:02:04 +08:00
|
|
|
controlItemBgHover: mergedToken.colorBgBelow2,
|
2022-03-22 13:26:29 +08:00
|
|
|
|
|
|
|
// 👀👀👀👀👀👀👀👀👀 Not align with Derivative 👀👀👀👀👀👀👀👀👀
|
|
|
|
// FIXME: @arvinxx handle this
|
2022-05-16 17:52:35 +08:00
|
|
|
controlLineType: mergedToken.lineType,
|
2022-03-22 13:26:29 +08:00
|
|
|
controlRadius: mergedToken.radiusBase,
|
|
|
|
colorBorder: new TinyColor({ h: 0, s: 0, v: 85 }).toHexString(),
|
2022-03-25 17:54:57 +08:00
|
|
|
colorSplit: 'rgba(0, 0, 0, 0.06)',
|
2022-03-22 20:02:04 +08:00
|
|
|
controlItemBgActive: primaryColors[0],
|
2022-03-25 17:54:57 +08:00
|
|
|
fontWeightStrong: 600,
|
2022-03-22 13:26:29 +08:00
|
|
|
|
2022-03-21 16:48:25 +08:00
|
|
|
// 🔥🔥🔥🔥🔥🔥🔥🔥🔥 All TMP Token leaves here 🔥🔥🔥🔥🔥🔥🔥🔥🔥
|
|
|
|
// FIXME: Handle this when derivative is ready
|
2022-03-24 14:30:48 +08:00
|
|
|
// primaryColors,
|
|
|
|
// warningColors,
|
|
|
|
// errorColors,
|
|
|
|
|
2022-04-25 10:54:00 +08:00
|
|
|
colorLoadingOpacity: 0.65,
|
|
|
|
|
2022-03-24 14:30:48 +08:00
|
|
|
colorSuccessSecondary: successColors[2],
|
|
|
|
colorWarningSecondary: warningColors[2],
|
|
|
|
colorErrorSecondary: errorColors[2],
|
|
|
|
colorInfoSecondary: infoColors[2],
|
|
|
|
|
2022-03-21 16:48:25 +08:00
|
|
|
linkDecoration: 'none',
|
|
|
|
linkHoverDecoration: 'none',
|
|
|
|
linkFocusDecoration: 'none',
|
|
|
|
|
2022-03-25 17:54:57 +08:00
|
|
|
controlPaddingHorizontal: 12,
|
|
|
|
controlPaddingHorizontalSM: 8,
|
2022-03-21 16:48:25 +08:00
|
|
|
|
|
|
|
padding: 16,
|
|
|
|
margin: 16,
|
|
|
|
|
2022-03-25 17:54:57 +08:00
|
|
|
paddingXXS: 4,
|
|
|
|
paddingXS: 8,
|
|
|
|
paddingSM: 12,
|
|
|
|
paddingLG: 24,
|
2022-05-23 10:58:30 +08:00
|
|
|
paddingXL: 32,
|
2022-03-21 16:48:25 +08:00
|
|
|
|
2022-03-25 17:54:57 +08:00
|
|
|
marginXXS: 4,
|
|
|
|
marginXS: 8,
|
|
|
|
marginSM: 12,
|
|
|
|
marginLG: 24,
|
2022-05-18 15:37:27 +08:00
|
|
|
marginXL: 32,
|
|
|
|
marginXXL: 48,
|
2022-03-21 16:48:25 +08:00
|
|
|
|
2022-03-22 20:02:04 +08:00
|
|
|
boxShadow: `
|
|
|
|
0 3px 6px -4px rgba(0, 0, 0, 0.12),
|
|
|
|
0 6px 16px 0 rgba(0, 0, 0, 0.08),
|
|
|
|
0 9px 28px 8px rgba(0, 0, 0, 0.05)
|
|
|
|
`,
|
2022-03-30 14:13:36 +08:00
|
|
|
|
|
|
|
screenXS,
|
|
|
|
screenXSMin: screenXS,
|
|
|
|
screenXSMax: screenXS - 1,
|
|
|
|
screenSM,
|
|
|
|
screenSMMin: screenSM,
|
|
|
|
screenSMMax: screenSM - 1,
|
|
|
|
screenMD,
|
|
|
|
screenMDMin: screenMD,
|
|
|
|
screenMDMax: screenMD - 1,
|
|
|
|
screenLG,
|
|
|
|
screenLGMin: screenLG,
|
|
|
|
screenLGMax: screenLG - 1,
|
|
|
|
screenXL,
|
|
|
|
screenXLMin: screenXL,
|
|
|
|
screenXLMax: screenXL - 1,
|
|
|
|
screenXXL,
|
|
|
|
screenXXLMin: screenXXL,
|
|
|
|
screenXXLMax: screenXXL - 1,
|
|
|
|
|
|
|
|
motionEaseOut: 'cubic-bezier(0.215, 0.61, 0.355, 1)',
|
2022-05-10 17:30:01 +08:00
|
|
|
|
|
|
|
colorPopupBg: new TinyColor('#000').setAlpha(0.45).toRgbString(),
|
2022-05-13 16:38:33 +08:00
|
|
|
colorBorderSecondary: new TinyColor({ h: 0, s: 0, v: 94 }).toHexString(),
|
2022-03-21 16:48:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return aliasToken;
|
|
|
|
}
|