From f46336e34142e7f46bb1395f727e303e37b15d41 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 15 Apr 2025 08:13:20 -0500 Subject: Replace old ProfileCard with new (#8195) * Replace usages of old ProfileCard * Replace Pills with Labels component * Replace impl of ProfileCardWithFollowButton * Remove never-used LikesDialog * Handle missing mod opts * Add missing profile hover * use modern button in listmembers * remove follow button from muted accounts list --------- Co-authored-by: Samuel Newman --- src/components/ProfileCard.tsx | 53 +++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'src/components/ProfileCard.tsx') diff --git a/src/components/ProfileCard.tsx b/src/components/ProfileCard.tsx index beb09cdc7..394ff9946 100644 --- a/src/components/ProfileCard.tsx +++ b/src/components/ProfileCard.tsx @@ -8,15 +8,15 @@ import { import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {getModerationCauseKey} from '#/lib/moderation' import {type LogEvents} from '#/lib/statsig/statsig' import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeHandle} from '#/lib/strings/handles' import {useProfileShadow} from '#/state/cache/profile-shadow' import {useProfileFollowMutationQueue} from '#/state/queries/profile' import {useSession} from '#/state/session' -import {ProfileCardPills} from '#/view/com/profile/ProfileCard' import * as Toast from '#/view/com/util/Toast' -import {UserAvatar} from '#/view/com/util/UserAvatar' +import {PreviewableUserAvatar} from '#/view/com/util/UserAvatar' import {atoms as a, useTheme} from '#/alf' import { Button, @@ -27,6 +27,7 @@ import { import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' import {Link as InternalLink, type LinkProps} from '#/components/Link' +import * as Pills from '#/components/Pills' import {RichText} from '#/components/RichText' import {Text} from '#/components/Typography' import type * as bsky from '#/types/bsky' @@ -35,13 +36,15 @@ export function Default({ profile, moderationOpts, logContext = 'ProfileCard', + testID, }: { profile: bsky.profile.AnyProfileView moderationOpts: ModerationOpts logContext?: 'ProfileCard' | 'StarterPackProfilesList' + testID?: string }) { return ( - +
@@ -74,10 +75,7 @@ export function Card({ />
- + @@ -87,7 +85,7 @@ export function Card({ export function Outer({ children, }: { - children: React.ReactElement | React.ReactElement[] + children: React.ReactNode | React.ReactNode[] }) { return {children} } @@ -95,7 +93,7 @@ export function Outer({ export function Header({ children, }: { - children: React.ReactElement | React.ReactElement[] + children: React.ReactNode | React.ReactNode[] }) { return {children} } @@ -137,10 +135,9 @@ export function Avatar({ const moderation = moderateProfile(profile, moderationOpts) return ( - ) @@ -415,3 +412,31 @@ export function FollowButtonInner({ ) } + +export function Labels({ + profile, + moderationOpts, +}: { + profile: bsky.profile.AnyProfileView + moderationOpts: ModerationOpts +}) { + const moderation = moderateProfile(profile, moderationOpts) + const modui = moderation.ui('profileList') + const followedBy = profile.viewer?.followedBy + + if (!followedBy && !modui.inform && !modui.alert) { + return null + } + + return ( + + {followedBy && } + {modui.alerts.map(alert => ( + + ))} + {modui.informs.map(inform => ( + + ))} + + ) +} -- cgit 1.4.1