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 {
|
2022-06-09 10:42:22 +08:00
|
|
|
const { derivative, alias, ...restToken } = derivativeToken;
|
2022-03-21 16:48:25 +08:00
|
|
|
|
|
|
|
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-06-17 18:47:47 +08:00
|
|
|
colorTextPlaceholder: mergedToken.colorTextBelow2,
|
2022-03-22 20:02:04 +08:00
|
|
|
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-06-17 18:47:47 +08:00
|
|
|
colorBgElevated: mergedToken.colorBg,
|
|
|
|
colorBgComponentTmp: 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-06-17 18:47:47 +08:00
|
|
|
colorActionTmp: mergedToken.colorTextBelow2,
|
2022-03-24 14:30:48 +08:00
|
|
|
|
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-05-31 10:10:35 +08:00
|
|
|
// Checkbox size and expand icon size
|
|
|
|
controlInteractiveSize: mergedToken.controlHeight / 2,
|
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-06-02 16:17:40 +08:00
|
|
|
controlItemBgActiveHover: new TinyColor(primaryColors[0]).darken(2).toRgbString(),
|
2022-06-02 19:27:31 +08:00
|
|
|
controlItemBgActiveDisabled: new TinyColor('#000').tint(90).toRgbString(),
|
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-06-17 18:47:47 +08:00
|
|
|
opacityLoading: 0.65,
|
2022-04-25 10:54:00 +08:00
|
|
|
|
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
|
|
|
|
2022-06-17 18:47:47 +08:00
|
|
|
controlMaskBg: 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-06-09 10:42:22 +08:00
|
|
|
|
2022-06-24 10:45:29 +08:00
|
|
|
// FIXME: component box-shadow, should be removed
|
|
|
|
boxShadowPopoverArrow: `3px 3px 7px rgba(0, 0, 0, 0.1)`,
|
|
|
|
boxShadowPopoverArrowBottom: `2px 2px 5px rgba(0, 0, 0, 0.1)`,
|
|
|
|
boxShadowSegmentedSelectedItem: [
|
|
|
|
`0 2px 8px -2px ${new TinyColor('#000').setAlpha(0.05).toRgbString()}`,
|
|
|
|
`0 1px 4px -1px ${new TinyColor('#000').setAlpha(0.07).toRgbString()}`,
|
|
|
|
`0 0 1px 0 ${new TinyColor('#000').setAlpha(0.08).toRgbString()}`,
|
|
|
|
].join(','),
|
|
|
|
boxShadowCard: `
|
|
|
|
0 1px 2px -2px ${new TinyColor('rgba(0, 0, 0, 0.16)').toRgbString()},
|
|
|
|
0 3px 6px 0 ${new TinyColor('rgba(0, 0, 0, 0.12)').toRgbString()},
|
|
|
|
0 5px 12px 4px ${new TinyColor('rgba(0, 0, 0, 0.09)').toRgbString()}
|
|
|
|
`,
|
|
|
|
boxShadowDrawerRight:
|
|
|
|
'6px 0 16px -8px rgba(0, 0, 0, 0.08), 9px 0 28px 0 rgba(0, 0, 0, 0.05),12px 0 48px 16px rgba(0, 0, 0, 0.03)',
|
|
|
|
boxShadowDrawerLeft:
|
|
|
|
'-6px 0 16px -8px rgba(0, 0, 0, 0.08), -9px 0 28px 0 rgba(0, 0, 0, 0.05), -12px 0 48px 16px rgba(0, 0, 0, 0.03)',
|
|
|
|
boxShadowDrawerUp:
|
|
|
|
'0 -6px 16px -8px rgba(0, 0, 0, 0.32), 0 -9px 28px 0 rgba(0, 0, 0, 0.2),0 -12px 48px 16px rgba(0, 0, 0, 0.12)',
|
|
|
|
boxShadowDrawerDown:
|
|
|
|
'0 6px 16px -8px rgba(0, 0, 0, 0.32), 0 9px 28px 0 rgba(0, 0, 0, 0.2), 0 12px 48px 16px rgba(0, 0, 0, 0.12)',
|
|
|
|
boxShadowTabsOverflowLeft: `inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)`,
|
|
|
|
boxShadowTabsOverflowRight: `inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)`,
|
|
|
|
boxShadowTabsOverflowTop: `inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)`,
|
|
|
|
boxShadowTabsOverflowBottom: `inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)`,
|
|
|
|
|
2022-06-09 10:42:22 +08:00
|
|
|
// Override AliasToken
|
|
|
|
...alias,
|
2022-03-21 16:48:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return aliasToken;
|
|
|
|
}
|