-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(input): add utility functions for font size, weight, and line he…
…ight #7
- Loading branch information
1 parent
f01a5bc
commit 8114cf2
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
}; | ||
} |