Skip to content

Commit

Permalink
feat(input): add utility functions for font size, weight, and line he…
Browse files Browse the repository at this point in the history
…ight #7
  • Loading branch information
froggy1014 committed Nov 13, 2024
1 parent f01a5bc commit 8114cf2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/Input/utils/typography.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export type FontSize = 12 | 14 | 16 | 18 | 20 | 24 | 28 | 32 | 36 | 48;
export type FontWeight = 'regular' | 'medium' | 'semiBold' | 'bold';
export type LineHeight = 'regular' | 'compact';

const fontWeightMap: Record<FontWeight, number> = {
regular: 400,
medium: 500,
semiBold: 600,
bold: 700,
};

const lineHeightMap: Record<LineHeight, string> = {
regular: '150%',
compact: '130%',
};

export function getTypographyStyles(
fontSize: FontSize = 14,
fontWeight: FontWeight = 'regular',
lineHeight: LineHeight = 'regular'
) {
return {
fontSize: `${fontSize}px`,
fontWeight: fontWeightMap[fontWeight],
lineHeight: lineHeightMap[lineHeight],
};
}

0 comments on commit 8114cf2

Please sign in to comment.