From c36748d38f06564a29fafce0672d1e5811611ed5 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 27 Jun 2024 11:48:09 -0500 Subject: [PATCH] Add round variant support and other button props --- src/components/ProfileCard.tsx | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/components/ProfileCard.tsx b/src/components/ProfileCard.tsx index 015afb996a..7257064b77 100644 --- a/src/components/ProfileCard.tsx +++ b/src/components/ProfileCard.tsx @@ -18,7 +18,7 @@ import * as Toast from '#/view/com/util/Toast' import {ProfileCardPills} from 'view/com/profile/ProfileCard' import {UserAvatar} from 'view/com/util/UserAvatar' import {atoms as a, useTheme} from '#/alf' -import {Button, ButtonIcon, ButtonText} from '#/components/Button' +import {Button, ButtonIcon, ButtonProps, ButtonText} from '#/components/Button' 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, LinkProps} from '#/components/Link' @@ -162,33 +162,29 @@ export function Description({description}: {description?: string}) { ) } -export function FollowButton({ - profile, - logContext, -}: { +export type FollowButtonProps = { profile: AppBskyActorDefs.ProfileViewBasic logContext: 'ProfileCard' | 'StarterPackProfilesList' -}) { +} & Partial + +export function FollowButton(props: FollowButtonProps) { const {currentAccount, hasSession} = useSession() - const isMe = profile.did === currentAccount?.did - return hasSession && !isMe ? ( - - ) : null + const isMe = props.profile.did === currentAccount?.did + return hasSession && !isMe ? : null } export function FollowButtonInner({ profile: profileUnshadowed, logContext, -}: { - profile: AppBskyActorDefs.ProfileViewBasic - logContext: 'ProfileCard' | 'StarterPackProfilesList' -}) { + ...rest +}: FollowButtonProps) { const {_} = useLingui() const profile = useProfileShadow(profileUnshadowed) const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue( profile, logContext, ) + const isRound = Boolean(rest.shape && rest.shape === 'round') const onPressFollow = async (e: GestureResponderEvent) => { e.preventDefault() @@ -237,9 +233,10 @@ export function FollowButtonInner({ size="small" variant="solid" color="secondary" + {...rest} onPress={onPressUnfollow}> - - {unfollowLabel} + + {isRound ? null : {unfollowLabel}} ) : ( )}