Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031import {type TextStyle} from 'react-native'
import {isWeb} from '../platform'import * as tokens from '../tokens'
/** * Util to calculate lineHeight from a text size atom and a leading atom (which * are unitless). On native, this will evaluate to a rounded pixel value. On * web, it will be a unitless string. * * Example: * `leading({ * fontSize: 15, * lineHeight: 1.2 * })` // => { lineHeight: 17 } */export function leading(textStyle: TextStyle): Pick<TextStyle, 'lineHeight'> { const lineHeight = textStyle?.lineHeight || tokens.lineHeight.snug
if (isWeb) { return { lineHeight: String(lineHeight) as unknown as TextStyle['lineHeight'], } } else { const size = textStyle?.fontSize || tokens.fontSize.sm return { lineHeight: Math.round(size * lineHeight), } }}