From c028cd184efd3b2788d8f46134eecf521e5d7b07 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 21 Aug 2023 10:40:12 -0500 Subject: [PATCH] add title attr to text text links --- src/view/com/util/Link.tsx | 10 ++++++++++ src/view/com/util/PostMeta.tsx | 1 + src/view/com/util/text/Text.tsx | 31 +++++++++++++++---------------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/view/com/util/Link.tsx b/src/view/com/util/Link.tsx index e428960fe5..6724164146 100644 --- a/src/view/com/util/Link.tsx +++ b/src/view/com/util/Link.tsx @@ -135,6 +135,7 @@ export const TextLink = observer(function TextLink({ numberOfLines, lineHeight, dataSet, + title, }: { testID?: string type?: TypographyVariant @@ -144,10 +145,12 @@ export const TextLink = observer(function TextLink({ numberOfLines?: number lineHeight?: number dataSet?: any + title?: string } & TextProps) { const {...props} = useLinkProps({to: sanitizeUrl(href)}) const store = useStores() const navigation = useNavigation() + const anchorRef = React.useRef(null) props.onPress = React.useCallback( (e?: Event) => { @@ -166,8 +169,14 @@ export const TextLink = observer(function TextLink({ return {} }, [href]) + React.useEffect(() => { + // @ts-expect-error web only, shows date on hover -esb + anchorRef.current?.setNativeProps?.({title}) + }, [title]) + return ( diff --git a/src/view/com/util/text/Text.tsx b/src/view/com/util/text/Text.tsx index 2825390cb5..98520a52c4 100644 --- a/src/view/com/util/text/Text.tsx +++ b/src/view/com/util/text/Text.tsx @@ -8,19 +8,18 @@ export type CustomTextProps = TextProps & { lineHeight?: number } -export function Text({ - type = 'md', - children, - lineHeight, - style, - ...props -}: React.PropsWithChildren) { - const theme = useTheme() - const typography = theme.typography[type] - const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined - return ( - - {children} - - ) -} +export const Text = React.forwardRef( + ({type = 'md', children, lineHeight, style, ...props}, ref) => { + const theme = useTheme() + const typography = theme.typography[type] + const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined + return ( + + {children} + + ) + }, +)