import { Ref } from "react"; import { Pressable, View } from "react-native"; import { useIOTheme } from "../../context"; import { IOFontWeight } from "../../utils/fonts"; import { IOText, IOTextProps, TypographicStyleAsLinkProps, TypographicStyleProps } from "./IOText"; type BodyStyleProps = Omit & { ref?: Ref; weight?: Extract; } & TypographicStyleAsLinkProps; export const bodyFontSize = 16; export const bodyLineHeight = 24; /** * `Body` typographic style */ export const Body = ({ ref, weight: customWeight, color: customColor, asLink, avoidPressable, accessibilityRole = "link", textStyle: customTextStyle, onPress, ...props }: BodyStyleProps) => { const theme = useIOTheme(); const defaultColor = asLink ? theme["interactiveElem-default"] : theme["textBody-tertiary"]; const BodyProps: IOTextProps = { ...props, dynamicTypeRamp: "body", // iOS only weight: customWeight || "Regular", size: bodyFontSize, lineHeight: bodyLineHeight, color: customColor ?? defaultColor, ...(asLink ? { accessibilityRole, textStyle: customTextStyle ?? { textDecorationLine: "underline" } } : {}) }; if (asLink && !avoidPressable) { // TODO: If Pressable is replaced with `onPress` on IOText, ref would // always point to a Text node and the Ref override in the prop // type can be removed entirely. return ( {props.children} ); } return ( {props.children} ); };