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 LabelMiniProps = Omit & { ref?: Ref; weight?: Extract; } & TypographicStyleAsLinkProps; /** * `LabelMini` typographic style */ export const LabelMini = ({ ref, weight: customWeight, color: customColor, asLink, accessibilityRole = "link", textStyle: customTextStyle, onPress, ...props }: LabelMiniProps) => { const theme = useIOTheme(); const defaultColor = asLink ? theme["interactiveElem-default"] : theme["textBody-tertiary"]; const LabelMiniProps: IOTextProps = { ...props, dynamicTypeRamp: "footnote" /* iOS only */, weight: customWeight || "Semibold", size: 12, lineHeight: 18, color: customColor ?? defaultColor, ...(asLink ? { accessibilityRole, textStyle: customTextStyle ?? { textDecorationLine: "underline" } } : {}) }; if (asLink) { // 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}; };