2022-12-09 17:52:34 +08:00
|
|
|
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);
|
|
|
|
|
2023-11-09 16:48:45 +08:00
|
|
|
const fontSizeMD = fontSizes[1];
|
|
|
|
const fontSizeSM = fontSizes[0];
|
|
|
|
const fontSizeLG = fontSizes[2];
|
|
|
|
const lineHeight = lineHeights[1];
|
|
|
|
const lineHeightSM = lineHeights[0];
|
|
|
|
const lineHeightLG = lineHeights[2];
|
|
|
|
|
2022-12-09 17:52:34 +08:00
|
|
|
return {
|
2023-11-09 16:48:45 +08:00
|
|
|
fontSizeSM,
|
|
|
|
fontSize: fontSizeMD,
|
|
|
|
fontSizeLG,
|
2022-12-09 17:52:34 +08:00
|
|
|
fontSizeXL: fontSizes[3],
|
|
|
|
|
|
|
|
fontSizeHeading1: fontSizes[6],
|
|
|
|
fontSizeHeading2: fontSizes[5],
|
|
|
|
fontSizeHeading3: fontSizes[4],
|
|
|
|
fontSizeHeading4: fontSizes[3],
|
|
|
|
fontSizeHeading5: fontSizes[2],
|
|
|
|
|
2023-11-09 16:48:45 +08:00
|
|
|
lineHeight,
|
|
|
|
lineHeightLG,
|
|
|
|
lineHeightSM,
|
|
|
|
|
|
|
|
fontHeight: Math.round(lineHeight * fontSizeMD),
|
|
|
|
fontHeightLG: Math.round(lineHeightLG * fontSizeLG),
|
|
|
|
fontHeightSM: Math.round(lineHeightSM * fontSizeSM),
|
2022-12-09 17:52:34 +08:00
|
|
|
|
|
|
|
lineHeightHeading1: lineHeights[6],
|
|
|
|
lineHeightHeading2: lineHeights[5],
|
|
|
|
lineHeightHeading3: lineHeights[4],
|
|
|
|
lineHeightHeading4: lineHeights[3],
|
|
|
|
lineHeightHeading5: lineHeights[2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default genFontMapToken;
|