From 086dc93a7a6e69b0df2ed084ee68bb4e26c13f88 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 17 Apr 2024 19:09:10 -0700 Subject: [PATCH] don't underline handle in post meta (#3591) * alignment remove the unnecessary styles now seriously? flex-end everything flex shrink test test rm unneeded flex flex the text don't underline handle in post meta * use `paddingLeft` * use `paddingLeft` but with `4` * Fix overflow color * Use nbsp to make mobile work --------- Co-authored-by: Dan Abramov --- src/view/com/util/Link.tsx | 39 +++++++++++++++++++++------------- src/view/com/util/PostMeta.tsx | 35 ++++++++++++++++-------------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/view/com/util/Link.tsx b/src/view/com/util/Link.tsx index b6c512b09e..d35d0fcc69 100644 --- a/src/view/com/util/Link.tsx +++ b/src/view/com/util/Link.tsx @@ -2,34 +2,35 @@ import React, {ComponentProps, memo, useMemo} from 'react' import { GestureResponderEvent, Platform, + Pressable, StyleProp, - TextStyle, TextProps, + TextStyle, + TouchableOpacity, View, ViewStyle, - Pressable, - TouchableOpacity, } from 'react-native' -import {useLinkProps, StackActions} from '@react-navigation/native' -import {Text} from './text/Text' -import {TypographyVariant} from 'lib/ThemeContext' -import {router} from '../../../routes' -import { - convertBskyAppUrlIfNeeded, - isExternalUrl, - linkRequiresWarning, -} from 'lib/strings/url-helpers' -import {isAndroid, isWeb} from 'platform/detection' import {sanitizeUrl} from '@braintree/sanitize-url' -import {PressableWithHover} from './PressableWithHover' +import {StackActions, useLinkProps} from '@react-navigation/native' + import {useModalControls} from '#/state/modals' import {useOpenLink} from '#/state/preferences/in-app-browser' -import {WebAuxClickWrapper} from 'view/com/util/WebAuxClickWrapper' import { DebouncedNavigationProp, useNavigationDeduped, } from 'lib/hooks/useNavigationDeduped' +import { + convertBskyAppUrlIfNeeded, + isExternalUrl, + linkRequiresWarning, +} from 'lib/strings/url-helpers' +import {TypographyVariant} from 'lib/ThemeContext' +import {isAndroid, isWeb} from 'platform/detection' +import {WebAuxClickWrapper} from 'view/com/util/WebAuxClickWrapper' import {useTheme} from '#/alf' +import {router} from '../../../routes' +import {PressableWithHover} from './PressableWithHover' +import {Text} from './text/Text' type Event = | React.MouseEvent @@ -149,6 +150,7 @@ export const TextLink = memo(function TextLink({ onPress, disableMismatchWarning, navigationAction, + anchorNoUnderline, ...orgProps }: { testID?: string @@ -162,6 +164,7 @@ export const TextLink = memo(function TextLink({ title?: string disableMismatchWarning?: boolean navigationAction?: 'push' | 'replace' | 'navigate' + anchorNoUnderline?: boolean } & TextProps) { const {...props} = useLinkProps({to: sanitizeUrl(href)}) const navigation = useNavigationDeduped() @@ -172,6 +175,11 @@ export const TextLink = memo(function TextLink({ console.error('Unable to detect mismatching label') } + if (anchorNoUnderline) { + dataSet = dataSet ?? {} + dataSet.noUnderline = 1 + } + props.onPress = React.useCallback( (e?: Event) => { const requiresWarning = @@ -267,6 +275,7 @@ interface TextLinkOnWebOnlyProps extends TextProps { navigationAction?: 'push' | 'replace' | 'navigate' disableMismatchWarning?: boolean onPointerEnter?: () => void + anchorNoUnderline?: boolean } export const TextLinkOnWebOnly = memo(function DesktopWebTextLink({ testID, diff --git a/src/view/com/util/PostMeta.tsx b/src/view/com/util/PostMeta.tsx index b37c69448e..a9b9a97cfc 100644 --- a/src/view/com/util/PostMeta.tsx +++ b/src/view/com/util/PostMeta.tsx @@ -35,6 +35,11 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => { const handle = opts.author.handle const prefetchProfileQuery = usePrefetchProfileQuery() + const profileLink = makeProfileLink(opts.author) + const onPointerEnter = isWeb + ? () => prefetchProfileQuery(opts.author.did) + : undefined + return ( {opts.showAvatar && ( @@ -49,11 +54,10 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => { /> )} - + { displayName, opts.moderation?.ui('displayName'), )} -   - - {sanitizeHandle(handle, '@')} - } - href={makeProfileLink(opts.author)} - onPointerEnter={ - isWeb ? () => prefetchProfileQuery(opts.author.did) : undefined - } + href={profileLink} + onPointerEnter={onPointerEnter} + /> + - + {!isAndroid && (