UNPKG

@lad-tech/mobydick-core

Version:

React Native components library focused on usability, accessibility and developer experience

29 lines (24 loc) 737 B
import useTheme from '../../styles/hooks/useTheme'; import { TEXT, TFontColor, TFontSize, TFontWeight, TypographyLegacyProp, } from '../types'; import {fontResolver, getSize} from '../utils'; export const useFont = (font: TypographyLegacyProp = 'Regular-Primary-S') => { const {colors, customFontResolver} = useTheme(); const [weight, color, size] = font.split('-'); const {fontSize, lineHeight} = getSize(size as TFontSize); const fontStyle = { color: colors[`${TEXT}${color as TFontColor}`], fontFamily: customFontResolver ? customFontResolver(weight as TFontWeight) : fontResolver(weight as TFontWeight), fontSize, lineHeight, minHeight: lineHeight, }; return {fontStyle}; };