diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-08-14 13:14:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-14 03:14:18 -0700 |
commit | 221623f55aa6c1bbe699c8d409832da110923c76 (patch) | |
tree | 7fca1fc109adf99ad3f92fb2e2b10d964c35a929 /src/components/Post/PostRepliedTo.tsx | |
parent | f4dca5d230fabf6f1f4f82617964f46e07b8a5be (diff) | |
download | voidsky-221623f55aa6c1bbe699c8d409832da110923c76.tar.zst |
Improve "replied to a post" component (#8602)
* unify component * change bottom padding from 2px to 4px
Diffstat (limited to 'src/components/Post/PostRepliedTo.tsx')
-rw-r--r-- | src/components/Post/PostRepliedTo.tsx | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/components/Post/PostRepliedTo.tsx b/src/components/Post/PostRepliedTo.tsx new file mode 100644 index 000000000..3085826c2 --- /dev/null +++ b/src/components/Post/PostRepliedTo.tsx @@ -0,0 +1,63 @@ +import {View} from 'react-native' +import {Trans} from '@lingui/macro' + +import {useSession} from '#/state/session' +import {UserInfoText} from '#/view/com/util/UserInfoText' +import {atoms as a, useTheme} from '#/alf' +import {ArrowCornerDownRight_Stroke2_Corner2_Rounded as ArrowCornerDownRightIcon} from '#/components/icons/ArrowCornerDownRight' +import {ProfileHoverCard} from '#/components/ProfileHoverCard' +import {Text} from '#/components/Typography' +import type * as bsky from '#/types/bsky' + +export function PostRepliedTo({ + parentAuthor, + isParentBlocked, + isParentNotFound, +}: { + parentAuthor: string | bsky.profile.AnyProfileView | undefined + isParentBlocked?: boolean + isParentNotFound?: boolean +}) { + const t = useTheme() + const {currentAccount} = useSession() + + const textStyle = [a.text_sm, t.atoms.text_contrast_medium, a.leading_snug] + + let label + if (isParentBlocked) { + label = <Trans context="description">Replied to a blocked post</Trans> + } else if (isParentNotFound) { + label = <Trans context="description">Replied to a post</Trans> + } else if (parentAuthor) { + const did = + typeof parentAuthor === 'string' ? parentAuthor : parentAuthor.did + const isMe = currentAccount?.did === did + if (isMe) { + label = <Trans context="description">Replied to you</Trans> + } else { + label = ( + <Trans context="description"> + Replied to{' '} + <ProfileHoverCard did={did}> + <UserInfoText did={did} attr="displayName" style={textStyle} /> + </ProfileHoverCard> + </Trans> + ) + } + } + + if (!label) { + // Should not happen. + return null + } + + return ( + <View style={[a.flex_row, a.align_center, a.pb_xs, a.gap_xs]}> + <ArrowCornerDownRightIcon + size="xs" + style={[t.atoms.text_contrast_medium, {top: -1}]} + /> + <Text style={textStyle}>{label}</Text> + </View> + ) +} |