Skip to content

Commit

Permalink
Merge pull request #19 from JeroenRoodIHS/main
Browse files Browse the repository at this point in the history
Update textStylesToTokens.ts
  • Loading branch information
PavelLaptev authored Mar 3, 2024
2 parents ed35c82 + 9c62bfe commit ba1a624
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/utils/styles/textStylesToTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export const textStylesToTokens = async (
fontSize: `${style.fontSize}px`,
lineHeight: getLineHeight(style.lineHeight),
letterSpacing: getLetterSpacing(style.letterSpacing),
textDecoration: style.textDecoration,
textCase: style.textCase
},
[keyNames.description]: style.description,
$extensions: {
Expand Down
33 changes: 12 additions & 21 deletions src/utils/text/getFontWeight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@ export const getFontWeight = (fontWeight: string) => {
const inputFontWeight = fontWeight.toLowerCase();

const weights = {
thin: 100,
hairline: 100,
"extra-light": 200,
"ultra-light": 200,
light: 300,
normal: 400,
regular: 400,
book: 400,
medium: 500,
"semi-bold": 600,
"demi-bold": 600,
bold: 700,
"extra-bold": 800,
"ultra-bold": 800,
black: 900,
heavy: 900,
"extra-black": 950,
"ultra-black": 950,
};

return weights[inputFontWeight] || 400;
100 : ["thin", "hairline", "100"],
200 : ["extra-light", "extraLight", "ultra-light", "ultraLight", "200"],
300 : ["light", "300"],
400 : ["normal", "regular", "book", "400"],
500 : ["medium", "500"],
600 : ["semi-bold", "semiBold", "demi-bold", "demiBold", "600"],
700 : ["bold", "700"],
800 : ["ultra-bold", "ultraBold", "extra-bold", "extraBold", "800"],
900 : ["black", "heavy", "900"],
950 : ["extra-black", "ultra-black", "extraBlack", "ultraBlack", "950"]
}
return Object.keys(weights).find(weight => weights[weight].includes(inputFontWeight)) || 400;
};

0 comments on commit ba1a624

Please sign in to comment.