From 943acd16aac187ed4eb5f9cea67d6c507aab1ab5 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 19 Feb 2024 10:08:21 -0600 Subject: Add `selectable` to new text components (#2899) * Make new text selectable (broken) * Fixes * Fix bad conflict resolution * Remove console --- src/components/Link.tsx | 77 +++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 41 deletions(-) (limited to 'src/components/Link.tsx') diff --git a/src/components/Link.tsx b/src/components/Link.tsx index afd30b5ee..85c13270a 100644 --- a/src/components/Link.tsx +++ b/src/components/Link.tsx @@ -1,9 +1,5 @@ import React from 'react' -import { - GestureResponderEvent, - Linking, - TouchableWithoutFeedback, -} from 'react-native' +import {GestureResponderEvent, Linking} from 'react-native' import { useLinkProps, useNavigation, @@ -23,7 +19,7 @@ import { } from '#/lib/strings/url-helpers' import {useModalControls} from '#/state/modals' import {router} from '#/routes' -import {Text} from '#/components/Typography' +import {Text, TextProps} from '#/components/Typography' /** * Only available within a `Link`, since that inherits from `Button`. @@ -217,7 +213,7 @@ export function Link({ } export type InlineLinkProps = React.PropsWithChildren< - BaseLinkProps & TextStyleProp + BaseLinkProps & TextStyleProp & Pick > export function InlineLink({ @@ -228,6 +224,7 @@ export function InlineLink({ style, onPress: outerOnPress, download, + selectable, ...rest }: InlineLinkProps) { const t = useTheme() @@ -253,43 +250,41 @@ export function InlineLink({ const flattenedStyle = flatten(style) return ( - - - {children} - - + onBlur={onBlur} + onMouseEnter={onHoverIn} + onMouseLeave={onHoverOut} + accessibilityRole="link" + href={href} + {...web({ + hrefAttrs: { + target: download ? undefined : isExternal ? 'blank' : undefined, + rel: isExternal ? 'noopener noreferrer' : undefined, + download, + }, + dataSet: { + // default to no underline, apply this ourselves + noUnderline: '1', + }, + })}> + {children} + ) } -- cgit 1.4.1