mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
perf: token update (#39428)
* fix: token update * refactor: font map token * chore: code clean * chore: code clean * chore: code clean * chore: update snapshot * chore: menu style
This commit is contained in:
parent
13414cab91
commit
91f9fc2ff9
@ -46,7 +46,7 @@ exports[`renders ./components/input/demo/addon.tsx extend context correctly 1`]
|
|||||||
class="ant-input-group-addon"
|
class="ant-input-group-addon"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="ant-select select-before ant-select-single ant-select-show-arrow"
|
class="ant-select ant-select-single ant-select-show-arrow"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="ant-select-selector"
|
class="ant-select-selector"
|
||||||
@ -196,7 +196,7 @@ exports[`renders ./components/input/demo/addon.tsx extend context correctly 1`]
|
|||||||
class="ant-input-group-addon"
|
class="ant-input-group-addon"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="ant-select select-after ant-select-single ant-select-show-arrow"
|
class="ant-select ant-select-single ant-select-show-arrow"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="ant-select-selector"
|
class="ant-select-selector"
|
||||||
|
@ -46,7 +46,7 @@ exports[`renders ./components/input/demo/addon.tsx correctly 1`] = `
|
|||||||
class="ant-input-group-addon"
|
class="ant-input-group-addon"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="ant-select select-before ant-select-single ant-select-show-arrow"
|
class="ant-select ant-select-single ant-select-show-arrow"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="ant-select-selector"
|
class="ant-select-selector"
|
||||||
@ -114,7 +114,7 @@ exports[`renders ./components/input/demo/addon.tsx correctly 1`] = `
|
|||||||
class="ant-input-group-addon"
|
class="ant-input-group-addon"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="ant-select select-after ant-select-single ant-select-show-arrow"
|
class="ant-select ant-select-single ant-select-show-arrow"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="ant-select-selector"
|
class="ant-select-selector"
|
||||||
|
@ -5,21 +5,3 @@
|
|||||||
## en-US
|
## en-US
|
||||||
|
|
||||||
Using pre & post tabs example.
|
Using pre & post tabs example.
|
||||||
|
|
||||||
```css
|
|
||||||
.select-before {
|
|
||||||
width: 90px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.select-after {
|
|
||||||
width: 80px;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme='compact'] .select-before {
|
|
||||||
width: 71px;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme='compact'] .select-after {
|
|
||||||
width: 65px;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
@ -5,13 +5,13 @@ import { Cascader, Input, Select, Space } from 'antd';
|
|||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
||||||
const selectBefore = (
|
const selectBefore = (
|
||||||
<Select defaultValue="http://" className="select-before">
|
<Select defaultValue="http://">
|
||||||
<Option value="http://">http://</Option>
|
<Option value="http://">http://</Option>
|
||||||
<Option value="https://">https://</Option>
|
<Option value="https://">https://</Option>
|
||||||
</Select>
|
</Select>
|
||||||
);
|
);
|
||||||
const selectAfter = (
|
const selectAfter = (
|
||||||
<Select defaultValue=".com" className="select-after">
|
<Select defaultValue=".com">
|
||||||
<Option value=".com">.com</Option>
|
<Option value=".com">.com</Option>
|
||||||
<Option value=".jp">.jp</Option>
|
<Option value=".jp">.jp</Option>
|
||||||
<Option value=".cn">.cn</Option>
|
<Option value=".cn">.cn</Option>
|
||||||
|
@ -11,6 +11,7 @@ export type InputToken<T extends GlobalToken = FullToken<'Input'>> = T & {
|
|||||||
inputPaddingVerticalLG: number;
|
inputPaddingVerticalLG: number;
|
||||||
inputPaddingVerticalSM: number;
|
inputPaddingVerticalSM: number;
|
||||||
inputPaddingHorizontal: number;
|
inputPaddingHorizontal: number;
|
||||||
|
inputPaddingHorizontalLG: number;
|
||||||
inputPaddingHorizontalSM: number;
|
inputPaddingHorizontalSM: number;
|
||||||
inputBorderHoverColor: string;
|
inputBorderHoverColor: string;
|
||||||
inputBorderActiveColor: string;
|
inputBorderActiveColor: string;
|
||||||
@ -58,14 +59,14 @@ export const genDisabledStyle = (token: InputToken): CSSObject => ({
|
|||||||
const genInputLargeStyle = (token: InputToken): CSSObject => {
|
const genInputLargeStyle = (token: InputToken): CSSObject => {
|
||||||
const {
|
const {
|
||||||
inputPaddingVerticalLG,
|
inputPaddingVerticalLG,
|
||||||
inputPaddingHorizontal,
|
|
||||||
fontSizeLG,
|
fontSizeLG,
|
||||||
lineHeightLG,
|
lineHeightLG,
|
||||||
borderRadiusLG,
|
borderRadiusLG,
|
||||||
|
inputPaddingHorizontalLG,
|
||||||
} = token;
|
} = token;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
padding: `${inputPaddingVerticalLG}px ${inputPaddingHorizontal}px`,
|
padding: `${inputPaddingVerticalLG}px ${inputPaddingHorizontalLG}px`,
|
||||||
fontSize: fontSizeLG,
|
fontSize: fontSizeLG,
|
||||||
lineHeight: lineHeightLG,
|
lineHeight: lineHeightLG,
|
||||||
borderRadius: borderRadiusLG,
|
borderRadius: borderRadiusLG,
|
||||||
@ -860,8 +861,9 @@ export function initInputToken<T extends GlobalToken = GlobalToken>(token: T): I
|
|||||||
token.lineWidth,
|
token.lineWidth,
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
inputPaddingHorizontal: token.controlPaddingHorizontal - token.lineWidth,
|
inputPaddingHorizontal: token.paddingSM - token.lineWidth,
|
||||||
inputPaddingHorizontalSM: token.controlPaddingHorizontalSM - token.lineWidth,
|
inputPaddingHorizontalSM: token.paddingXS - token.lineWidth,
|
||||||
|
inputPaddingHorizontalLG: token.controlPaddingHorizontal - token.lineWidth,
|
||||||
inputBorderHoverColor: token.colorPrimaryHover,
|
inputBorderHoverColor: token.colorPrimaryHover,
|
||||||
inputBorderActiveColor: token.colorPrimaryHover,
|
inputBorderActiveColor: token.colorPrimaryHover,
|
||||||
});
|
});
|
||||||
|
@ -167,7 +167,7 @@ export default genComponentStyleHook(
|
|||||||
const combinedToken = mergeToken<MessageToken>(token, {
|
const combinedToken = mergeToken<MessageToken>(token, {
|
||||||
messageNoticeContentPadding: `${
|
messageNoticeContentPadding: `${
|
||||||
(token.controlHeightLG - token.fontSize * token.lineHeight) / 2
|
(token.controlHeightLG - token.fontSize * token.lineHeight) / 2
|
||||||
}px ${token.paddingContentVertical}px`,
|
}px ${token.paddingSM}px`,
|
||||||
});
|
});
|
||||||
return [genMessageStyle(combinedToken)];
|
return [genMessageStyle(combinedToken)];
|
||||||
},
|
},
|
||||||
|
@ -497,6 +497,7 @@ export default genComponentStyleHook('Radio', (token) => {
|
|||||||
colorPrimary,
|
colorPrimary,
|
||||||
marginXS,
|
marginXS,
|
||||||
controlOutlineWidth,
|
controlOutlineWidth,
|
||||||
|
colorTextLightSolid,
|
||||||
wireframe,
|
wireframe,
|
||||||
} = token;
|
} = token;
|
||||||
|
|
||||||
@ -528,7 +529,7 @@ export default genComponentStyleHook('Radio', (token) => {
|
|||||||
radioDotDisabledSize,
|
radioDotDisabledSize,
|
||||||
radioCheckedColor,
|
radioCheckedColor,
|
||||||
radioDotDisabledColor: colorTextDisabled,
|
radioDotDisabledColor: colorTextDisabled,
|
||||||
radioSolidCheckedColor: colorBgContainer,
|
radioSolidCheckedColor: colorTextLightSolid,
|
||||||
radioButtonBg: colorBgContainer,
|
radioButtonBg: colorBgContainer,
|
||||||
radioButtonCheckedBg: colorBgContainer,
|
radioButtonCheckedBg: colorBgContainer,
|
||||||
radioButtonColor,
|
radioButtonColor,
|
||||||
|
@ -329,7 +329,7 @@ export default genComponentStyleHook(
|
|||||||
(token, { rootPrefixCls }) => {
|
(token, { rootPrefixCls }) => {
|
||||||
const selectToken: SelectToken = mergeToken<SelectToken>(token, {
|
const selectToken: SelectToken = mergeToken<SelectToken>(token, {
|
||||||
rootPrefixCls,
|
rootPrefixCls,
|
||||||
inputPaddingHorizontalBase: token.controlPaddingHorizontal - 1,
|
inputPaddingHorizontalBase: token.paddingSM - 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
return [genSelectStyle(selectToken)];
|
return [genSelectStyle(selectToken)];
|
||||||
|
@ -111,7 +111,7 @@ const genBaseStyle: GenerateStyle<SliderToken> = (token) => {
|
|||||||
insetInlineStart: 0,
|
insetInlineStart: 0,
|
||||||
width: token.handleSize,
|
width: token.handleSize,
|
||||||
height: token.handleSize,
|
height: token.handleSize,
|
||||||
backgroundColor: token.colorBgContainer,
|
backgroundColor: token.colorBgElevated,
|
||||||
boxShadow: `0 0 0 ${token.handleLineWidth}px ${token.colorPrimaryBorder}`,
|
boxShadow: `0 0 0 ${token.handleLineWidth}px ${token.colorPrimaryBorder}`,
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
@ -177,8 +177,8 @@ const genBaseStyle: GenerateStyle<SliderToken> = (token) => {
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
width: dotSize,
|
width: dotSize,
|
||||||
height: dotSize,
|
height: dotSize,
|
||||||
backgroundColor: token.colorBgContainer,
|
backgroundColor: token.colorBgElevated,
|
||||||
border: `${token.handleLineWidth}px solid ${token.colorSplit}`,
|
border: `${token.handleLineWidth}px solid ${token.colorBorderSecondary}`,
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
transition: `border-color ${token.motionDurationSlow}`,
|
transition: `border-color ${token.motionDurationSlow}`,
|
||||||
@ -202,14 +202,14 @@ const genBaseStyle: GenerateStyle<SliderToken> = (token) => {
|
|||||||
[`
|
[`
|
||||||
${componentCls}-dot
|
${componentCls}-dot
|
||||||
`]: {
|
`]: {
|
||||||
backgroundColor: token.colorBgContainer,
|
backgroundColor: token.colorBgElevated,
|
||||||
borderColor: token.colorTextDisabled,
|
borderColor: token.colorTextDisabled,
|
||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
cursor: 'not-allowed',
|
cursor: 'not-allowed',
|
||||||
},
|
},
|
||||||
|
|
||||||
[`${componentCls}-handle::after`]: {
|
[`${componentCls}-handle::after`]: {
|
||||||
backgroundColor: token.colorBgContainer,
|
backgroundColor: token.colorBgElevated,
|
||||||
cursor: 'not-allowed',
|
cursor: 'not-allowed',
|
||||||
width: token.handleSize,
|
width: token.handleSize,
|
||||||
height: token.handleSize,
|
height: token.handleSize,
|
||||||
@ -335,7 +335,7 @@ export default genComponentStyleHook(
|
|||||||
railSize: 4,
|
railSize: 4,
|
||||||
handleSize: controlSize,
|
handleSize: controlSize,
|
||||||
handleSizeHover: controlSizeHover,
|
handleSizeHover: controlSizeHover,
|
||||||
dotSize: (controlSize / 3) * 2,
|
dotSize: 8,
|
||||||
handleLineWidth,
|
handleLineWidth,
|
||||||
handleLineWidthHover,
|
handleLineWidthHover,
|
||||||
};
|
};
|
||||||
|
@ -48,58 +48,12 @@ export interface AliasToken extends MapToken {
|
|||||||
colorErrorOutline: string;
|
colorErrorOutline: string;
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
fontSizeSM: number;
|
|
||||||
fontSize: number;
|
|
||||||
fontSizeLG: number;
|
|
||||||
fontSizeXL: number;
|
|
||||||
/** Operation icon in Select, Cascader, etc. icon fontSize. Normal is same as fontSizeSM */
|
/** Operation icon in Select, Cascader, etc. icon fontSize. Normal is same as fontSizeSM */
|
||||||
fontSizeIcon: number;
|
fontSizeIcon: number;
|
||||||
|
|
||||||
/**
|
|
||||||
* @nameZH 一级标题字号
|
|
||||||
* @desc H1 标签所使用的字号
|
|
||||||
* @default 38
|
|
||||||
*/
|
|
||||||
fontSizeHeading1: number;
|
|
||||||
/**
|
|
||||||
* @nameZH 二级标题字号
|
|
||||||
* @desc h2 标签所使用的字号
|
|
||||||
* @default 30
|
|
||||||
*/
|
|
||||||
fontSizeHeading2: number;
|
|
||||||
/**
|
|
||||||
* @nameZH 三级标题字号
|
|
||||||
* @desc h3 标签使用的字号
|
|
||||||
* @default 24
|
|
||||||
*/
|
|
||||||
fontSizeHeading3: number;
|
|
||||||
/**
|
|
||||||
* @nameZH 四级标题字号
|
|
||||||
* @desc h4 标签使用的字号
|
|
||||||
* @default 20
|
|
||||||
*/
|
|
||||||
fontSizeHeading4: number;
|
|
||||||
/**
|
|
||||||
* @nameZH 五级标题字号
|
|
||||||
* @desc h5 标签使用的字号
|
|
||||||
* @default 16
|
|
||||||
*/
|
|
||||||
fontSizeHeading5: number;
|
|
||||||
|
|
||||||
/** For heading like h1, h2, h3 or option selected item */
|
/** For heading like h1, h2, h3 or option selected item */
|
||||||
fontWeightStrong: number;
|
fontWeightStrong: number;
|
||||||
|
|
||||||
// LineHeight
|
|
||||||
lineHeight: number;
|
|
||||||
lineHeightLG: number;
|
|
||||||
lineHeightSM: number;
|
|
||||||
|
|
||||||
lineHeightHeading1: number;
|
|
||||||
lineHeightHeading2: number;
|
|
||||||
lineHeightHeading3: number;
|
|
||||||
lineHeightHeading4: number;
|
|
||||||
lineHeightHeading5: number;
|
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
controlOutlineWidth: number;
|
controlOutlineWidth: number;
|
||||||
controlItemBgHover: string; // Note. It also is a color
|
controlItemBgHover: string; // Note. It also is a color
|
||||||
|
@ -18,7 +18,7 @@ export type {
|
|||||||
CommonMapToken,
|
CommonMapToken,
|
||||||
HeightMapToken,
|
HeightMapToken,
|
||||||
SizeMapToken,
|
SizeMapToken,
|
||||||
FontSizeMapToken,
|
FontMapToken,
|
||||||
StyleMapToken,
|
StyleMapToken,
|
||||||
} from './maps';
|
} from './maps';
|
||||||
export type { AliasToken } from './alias';
|
export type { AliasToken } from './alias';
|
||||||
|
49
components/theme/interface/maps/font.ts
Normal file
49
components/theme/interface/maps/font.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
export interface FontMapToken {
|
||||||
|
// Font Size
|
||||||
|
fontSizeSM: number;
|
||||||
|
fontSize: number;
|
||||||
|
fontSizeLG: number;
|
||||||
|
fontSizeXL: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @nameZH 一级标题字号
|
||||||
|
* @desc H1 标签所使用的字号
|
||||||
|
* @default 38
|
||||||
|
*/
|
||||||
|
fontSizeHeading1: number;
|
||||||
|
/**
|
||||||
|
* @nameZH 二级标题字号
|
||||||
|
* @desc h2 标签所使用的字号
|
||||||
|
* @default 30
|
||||||
|
*/
|
||||||
|
fontSizeHeading2: number;
|
||||||
|
/**
|
||||||
|
* @nameZH 三级标题字号
|
||||||
|
* @desc h3 标签使用的字号
|
||||||
|
* @default 24
|
||||||
|
*/
|
||||||
|
fontSizeHeading3: number;
|
||||||
|
/**
|
||||||
|
* @nameZH 四级标题字号
|
||||||
|
* @desc h4 标签使用的字号
|
||||||
|
* @default 20
|
||||||
|
*/
|
||||||
|
fontSizeHeading4: number;
|
||||||
|
/**
|
||||||
|
* @nameZH 五级标题字号
|
||||||
|
* @desc h5 标签使用的字号
|
||||||
|
* @default 16
|
||||||
|
*/
|
||||||
|
fontSizeHeading5: number;
|
||||||
|
|
||||||
|
// LineHeight
|
||||||
|
lineHeight: number;
|
||||||
|
lineHeightLG: number;
|
||||||
|
lineHeightSM: number;
|
||||||
|
|
||||||
|
lineHeightHeading1: number;
|
||||||
|
lineHeightHeading2: number;
|
||||||
|
lineHeightHeading3: number;
|
||||||
|
lineHeightHeading4: number;
|
||||||
|
lineHeightHeading5: number;
|
||||||
|
}
|
@ -1,14 +1,16 @@
|
|||||||
import type { ColorPalettes } from '../presetColors';
|
import type { ColorPalettes } from '../presetColors';
|
||||||
import type { SeedToken } from '../seeds';
|
import type { SeedToken } from '../seeds';
|
||||||
import type { SizeMapToken, HeightMapToken, FontSizeMapToken } from './size';
|
import type { SizeMapToken, HeightMapToken } from './size';
|
||||||
import type { ColorMapToken } from './colors';
|
import type { ColorMapToken } from './colors';
|
||||||
import type { StyleMapToken } from './style';
|
import type { StyleMapToken } from './style';
|
||||||
|
import type { FontMapToken } from './font';
|
||||||
|
|
||||||
export * from './colors';
|
export * from './colors';
|
||||||
export * from './style';
|
export * from './style';
|
||||||
export * from './size';
|
export * from './size';
|
||||||
|
export * from './font';
|
||||||
|
|
||||||
export interface CommonMapToken extends FontSizeMapToken, StyleMapToken {
|
export interface CommonMapToken extends StyleMapToken {
|
||||||
// Motion
|
// Motion
|
||||||
motionDurationFast: string;
|
motionDurationFast: string;
|
||||||
motionDurationMid: string;
|
motionDurationMid: string;
|
||||||
@ -27,4 +29,5 @@ export interface MapToken
|
|||||||
SizeMapToken,
|
SizeMapToken,
|
||||||
HeightMapToken,
|
HeightMapToken,
|
||||||
StyleMapToken,
|
StyleMapToken,
|
||||||
|
FontMapToken,
|
||||||
CommonMapToken {}
|
CommonMapToken {}
|
||||||
|
@ -53,15 +53,3 @@ export interface HeightMapToken {
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
controlHeightLG: number;
|
controlHeightLG: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font
|
|
||||||
export interface FontSizeMapToken {
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
fontSizes: number[];
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
lineHeights: number[];
|
|
||||||
}
|
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
import type { DerivativeFunc } from '@ant-design/cssinjs';
|
import type { DerivativeFunc } from '@ant-design/cssinjs';
|
||||||
import genControlHeight from '../shared/genControlHeight';
|
import genControlHeight from '../shared/genControlHeight';
|
||||||
import type { SeedToken, MapToken } from '../../interface';
|
import type { MapToken, SeedToken } from '../../interface';
|
||||||
import defaultAlgorithm from '../default';
|
import defaultAlgorithm from '../default';
|
||||||
import genCompactSizeMapToken from './genCompactSizeMapToken';
|
import genCompactSizeMapToken from './genCompactSizeMapToken';
|
||||||
import getFontSizes from '../shared/genFontSizes';
|
import genFontMapToken from '../shared/genFontMapToken';
|
||||||
|
|
||||||
const derivative: DerivativeFunc<SeedToken, MapToken> = (token, mapToken) => {
|
const derivative: DerivativeFunc<SeedToken, MapToken> = (token, mapToken) => {
|
||||||
const mergedMapToken = mapToken ?? defaultAlgorithm(token);
|
const mergedMapToken = mapToken ?? defaultAlgorithm(token);
|
||||||
|
|
||||||
const fontSize = mergedMapToken.fontSizes[0]; // Smaller size font-size as base
|
const fontSize = mergedMapToken.fontSizeSM; // Smaller size font-size as base
|
||||||
const fontSizes = getFontSizes(fontSize);
|
|
||||||
const controlHeight = mergedMapToken.controlHeight - 4;
|
const controlHeight = mergedMapToken.controlHeight - 4;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -17,8 +16,7 @@ const derivative: DerivativeFunc<SeedToken, MapToken> = (token, mapToken) => {
|
|||||||
...genCompactSizeMapToken(mapToken ?? token),
|
...genCompactSizeMapToken(mapToken ?? token),
|
||||||
|
|
||||||
// font
|
// font
|
||||||
fontSizes: fontSizes.map((fs) => fs.size),
|
...genFontMapToken(fontSize),
|
||||||
lineHeights: fontSizes.map((fs) => fs.lineHeight),
|
|
||||||
|
|
||||||
// controlHeight
|
// controlHeight
|
||||||
controlHeight,
|
controlHeight,
|
||||||
|
@ -6,6 +6,7 @@ import { defaultPresetColors } from '../seed';
|
|||||||
import genColorMapToken from '../shared/genColorMapToken';
|
import genColorMapToken from '../shared/genColorMapToken';
|
||||||
import genCommonMapToken from '../shared/genCommonMapToken';
|
import genCommonMapToken from '../shared/genCommonMapToken';
|
||||||
import { generateColorPalettes, generateNeutralColorPalettes } from './colors';
|
import { generateColorPalettes, generateNeutralColorPalettes } from './colors';
|
||||||
|
import genFontMapToken from '../shared/genFontMapToken';
|
||||||
|
|
||||||
export default function derivative(token: SeedToken): MapToken {
|
export default function derivative(token: SeedToken): MapToken {
|
||||||
const colorPalettes = Object.keys(defaultPresetColors)
|
const colorPalettes = Object.keys(defaultPresetColors)
|
||||||
@ -33,6 +34,8 @@ export default function derivative(token: SeedToken): MapToken {
|
|||||||
generateColorPalettes,
|
generateColorPalettes,
|
||||||
generateNeutralColorPalettes,
|
generateNeutralColorPalettes,
|
||||||
}),
|
}),
|
||||||
|
// Font
|
||||||
|
...genFontMapToken(token.fontSize),
|
||||||
// Size
|
// Size
|
||||||
...genSizeMapToken(token),
|
...genSizeMapToken(token),
|
||||||
// Height
|
// Height
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
import type { CommonMapToken, SeedToken } from '../../interface';
|
import type { CommonMapToken, SeedToken } from '../../interface';
|
||||||
import genFontSizes from './genFontSizes';
|
|
||||||
import genRadius from './genRadius';
|
import genRadius from './genRadius';
|
||||||
|
|
||||||
export default function genCommonMapToken(token: SeedToken): CommonMapToken {
|
export default function genCommonMapToken(token: SeedToken): CommonMapToken {
|
||||||
const { motionUnit, motionBase, fontSize, borderRadius, lineWidth } = token;
|
const { motionUnit, motionBase, borderRadius, lineWidth } = token;
|
||||||
|
|
||||||
const fontSizes = genFontSizes(fontSize);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// motion
|
// motion
|
||||||
@ -13,10 +10,6 @@ export default function genCommonMapToken(token: SeedToken): CommonMapToken {
|
|||||||
motionDurationMid: `${(motionBase + motionUnit * 2).toFixed(1)}s`,
|
motionDurationMid: `${(motionBase + motionUnit * 2).toFixed(1)}s`,
|
||||||
motionDurationSlow: `${(motionBase + motionUnit * 3).toFixed(1)}s`,
|
motionDurationSlow: `${(motionBase + motionUnit * 3).toFixed(1)}s`,
|
||||||
|
|
||||||
// font
|
|
||||||
fontSizes: fontSizes.map((fs) => fs.size),
|
|
||||||
lineHeights: fontSizes.map((fs) => fs.lineHeight),
|
|
||||||
|
|
||||||
// line
|
// line
|
||||||
lineWidthBold: lineWidth + 1,
|
lineWidthBold: lineWidth + 1,
|
||||||
|
|
||||||
|
33
components/theme/themes/shared/genFontMapToken.ts
Normal file
33
components/theme/themes/shared/genFontMapToken.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import type { FontMapToken } from '../../interface';
|
||||||
|
import genFontSizes from './genFontSizes';
|
||||||
|
|
||||||
|
const genFontMapToken = (fontSize: number): FontMapToken => {
|
||||||
|
const fontSizePairs = genFontSizes(fontSize);
|
||||||
|
const fontSizes = fontSizePairs.map((pair) => pair.size);
|
||||||
|
const lineHeights = fontSizePairs.map((pair) => pair.lineHeight);
|
||||||
|
|
||||||
|
return {
|
||||||
|
fontSizeSM: fontSizes[0],
|
||||||
|
fontSize: fontSizes[1],
|
||||||
|
fontSizeLG: fontSizes[2],
|
||||||
|
fontSizeXL: fontSizes[3],
|
||||||
|
|
||||||
|
fontSizeHeading1: fontSizes[6],
|
||||||
|
fontSizeHeading2: fontSizes[5],
|
||||||
|
fontSizeHeading3: fontSizes[4],
|
||||||
|
fontSizeHeading4: fontSizes[3],
|
||||||
|
fontSizeHeading5: fontSizes[2],
|
||||||
|
|
||||||
|
lineHeight: lineHeights[1],
|
||||||
|
lineHeightLG: lineHeights[2],
|
||||||
|
lineHeightSM: lineHeights[0],
|
||||||
|
|
||||||
|
lineHeightHeading1: lineHeights[6],
|
||||||
|
lineHeightHeading2: lineHeights[5],
|
||||||
|
lineHeightHeading3: lineHeights[4],
|
||||||
|
lineHeightHeading4: lineHeights[3],
|
||||||
|
lineHeightHeading5: lineHeights[2],
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default genFontMapToken;
|
@ -24,7 +24,6 @@ export default function formatToken(derivativeToken: RawMergedToken): AliasToken
|
|||||||
...overrideTokens,
|
...overrideTokens,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { fontSizes, lineHeights } = mergedToken;
|
|
||||||
const screenXS = 480;
|
const screenXS = 480;
|
||||||
const screenSM = 576;
|
const screenSM = 576;
|
||||||
const screenMD = 768;
|
const screenMD = 768;
|
||||||
@ -32,8 +31,6 @@ export default function formatToken(derivativeToken: RawMergedToken): AliasToken
|
|||||||
const screenXL = 1200;
|
const screenXL = 1200;
|
||||||
const screenXXL = 1600;
|
const screenXXL = 1600;
|
||||||
|
|
||||||
const fontSizeSM = fontSizes[0];
|
|
||||||
|
|
||||||
// Generate alias token
|
// Generate alias token
|
||||||
const aliasToken: AliasToken = {
|
const aliasToken: AliasToken = {
|
||||||
...mergedToken,
|
...mergedToken,
|
||||||
@ -70,26 +67,7 @@ export default function formatToken(derivativeToken: RawMergedToken): AliasToken
|
|||||||
colorWarningOutline: getAlphaColor(mergedToken.colorWarningBg, mergedToken.colorBgContainer),
|
colorWarningOutline: getAlphaColor(mergedToken.colorWarningBg, mergedToken.colorBgContainer),
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
fontSizeSM,
|
fontSizeIcon: mergedToken.fontSizeSM,
|
||||||
fontSize: fontSizes[1],
|
|
||||||
fontSizeLG: fontSizes[2],
|
|
||||||
fontSizeXL: fontSizes[3],
|
|
||||||
fontSizeHeading1: fontSizes[6],
|
|
||||||
fontSizeHeading2: fontSizes[5],
|
|
||||||
fontSizeHeading3: fontSizes[4],
|
|
||||||
fontSizeHeading4: fontSizes[3],
|
|
||||||
fontSizeHeading5: fontSizes[2],
|
|
||||||
fontSizeIcon: fontSizeSM,
|
|
||||||
|
|
||||||
lineHeight: lineHeights[1],
|
|
||||||
lineHeightLG: lineHeights[2],
|
|
||||||
lineHeightSM: lineHeights[0],
|
|
||||||
|
|
||||||
lineHeightHeading1: lineHeights[6],
|
|
||||||
lineHeightHeading2: lineHeights[5],
|
|
||||||
lineHeightHeading3: lineHeights[4],
|
|
||||||
lineHeightHeading4: lineHeights[3],
|
|
||||||
lineHeightHeading5: lineHeights[2],
|
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
lineWidth: mergedToken.lineWidth,
|
lineWidth: mergedToken.lineWidth,
|
||||||
|
Loading…
Reference in New Issue
Block a user