diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/Post/PostRepliedTo.tsx | 63 | ||||
-rw-r--r-- | src/components/icons/ArrowCornerDownRight.tsx | 7 |
2 files changed, 70 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> + ) +} diff --git a/src/components/icons/ArrowCornerDownRight.tsx b/src/components/icons/ArrowCornerDownRight.tsx new file mode 100644 index 000000000..86dde7015 --- /dev/null +++ b/src/components/icons/ArrowCornerDownRight.tsx @@ -0,0 +1,7 @@ +import {createSinglePathSVG} from './TEMPLATE' + +export const ArrowCornerDownRight_Stroke2_Corner2_Rounded = createSinglePathSVG( + { + path: 'M15.793 10.293a1 1 0 0 1 1.338-.068l.076.068 3.293 3.293a2 2 0 0 1 .138 2.677l-.138.151-3.293 3.293a1 1 0 1 1-1.414-1.414L18.086 16H8a5 5 0 0 1-5-5V5a1 1 0 0 1 2 0v6a3 3 0 0 0 3 3h10.086l-2.293-2.293-.068-.076a1 1 0 0 1 .068-1.338Z', + }, +) |