diff --git a/packages/mobile/src/components/user/FollowsYouBadge.tsx b/packages/mobile/src/components/user/FollowsYouBadge.tsx new file mode 100644 index 00000000000..873322f871c --- /dev/null +++ b/packages/mobile/src/components/user/FollowsYouBadge.tsx @@ -0,0 +1,31 @@ +import type { ID } from '@audius/common/models' +import { accountSelectors } from '@audius/common/store' +import { useSelector } from 'react-redux' + +import { MusicBadge } from '@audius/harmony-native' +import { trpc } from 'app/services/trpc-client-mobile' + +const messages = { + followsYou: 'Follows You' +} + +type FollowsYouBadgeProps = { + userId: ID +} + +export const FollowsYouBadge = (props: FollowsYouBadgeProps) => { + const { userId } = props + const currentUserId = useSelector(accountSelectors.getUserId) + const { data } = trpc.me.userRelationship.useQuery( + { + theirId: userId.toString() + }, + { + enabled: !!currentUserId + } + ) + + if (!data?.followsMe) return null + + return {messages.followsYou} +} diff --git a/packages/mobile/src/components/user/FollowsYouChip.tsx b/packages/mobile/src/components/user/FollowsYouChip.tsx deleted file mode 100644 index 1b49760c7a7..00000000000 --- a/packages/mobile/src/components/user/FollowsYouChip.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import type { ID } from '@audius/common/models' -import { accountSelectors } from '@audius/common/store' -import { View } from 'react-native' -import { useSelector } from 'react-redux' - -import { Text } from 'app/components/core' -import { trpc } from 'app/services/trpc-client-mobile' -import { makeStyles } from 'app/styles' - -const messages = { - followsYou: 'Follows You' -} - -const useStyles = makeStyles(({ palette, spacing }) => ({ - followsYou: { - borderRadius: 4, - borderColor: palette.neutralLight4, - borderWidth: 1, - paddingVertical: spacing(1), - paddingHorizontal: spacing(2) - }, - followsYouText: { - textTransform: 'uppercase' - } -})) - -export const FollowsYouChip = ({ userId }: { userId: ID }) => { - const styles = useStyles() - const currentUserId = useSelector(accountSelectors.getUserId) - const { data } = trpc.me.userRelationship.useQuery( - { - theirId: userId.toString() - }, - { - enabled: !!currentUserId - } - ) - if (!data?.followsMe) return null - return ( - - - {messages.followsYou} - - - ) -} diff --git a/packages/mobile/src/components/user/index.ts b/packages/mobile/src/components/user/index.ts index 6d81ea50ef7..c0f200935ae 100644 --- a/packages/mobile/src/components/user/index.ts +++ b/packages/mobile/src/components/user/index.ts @@ -1,2 +1,2 @@ export * from './FollowButton' -export * from './FollowsYouChip' +export * from './FollowsYouBadge' diff --git a/packages/mobile/src/harmony-native/components/MusicBadge/MusicBadge.tsx b/packages/mobile/src/harmony-native/components/MusicBadge/MusicBadge.tsx index 3b035bfde09..f347f25de50 100644 --- a/packages/mobile/src/harmony-native/components/MusicBadge/MusicBadge.tsx +++ b/packages/mobile/src/harmony-native/components/MusicBadge/MusicBadge.tsx @@ -18,6 +18,10 @@ export type MusicBadgeProps = { * The type of the MusicBadge */ variant?: MusicBadgeVariant + /** + * The size of the MusicBadge + */ + size?: 's' | 'm' /** * The icon to display in the left of the MusicBadge */ @@ -29,9 +33,18 @@ export type MusicBadgeProps = { } & ComponentPropsWithoutRef<'div'> export const MusicBadge = (props: MusicBadgeProps) => { - const { variant = 'default', icon: Icon, color: colorProp, children } = props + const { + variant = 'default', + size = 's', + icon: Icon, + color: colorProp, + children + } = props const { color } = useTheme() + const gap = size === 'm' ? 's' : 'xs' + const height = size === 'm' ? '2xl' : 'xl' + const backgroundColor = colorProp ? color.special[colorProp] : variant === 'default' @@ -60,9 +73,9 @@ export const MusicBadge = (props: MusicBadgeProps) => { justifyContent='center' borderRadius='s' border='strong' - gap='xs' - ph='s' - pv='xs' + gap={gap} + h={height} + ph={size} style={css({ backgroundColor: Color(backgroundColor).fade(0.92).toString(), borderColor @@ -71,7 +84,7 @@ export const MusicBadge = (props: MusicBadgeProps) => { {Icon ? : null} ({ - name: { - ...flexRowCentered(), - marginRight: spacing(2), - marginBottom: spacing(1) - }, - username: { - ...typography.h1, - color: palette.neutral, - marginBottom: 0 // Override h1 bottom margin for this layout to work - }, - badges: { - marginTop: 2, - marginLeft: 2, - flexGrow: 1 - }, - handleInfo: { - flexDirection: 'row', - alignItems: 'center', - flexShrink: 1 - }, - handle: { - marginRight: spacing(2), - textAlignVertical: 'bottom' - }, - handleText: { - ...typography.h4, - color: palette.neutralLight4 - }, - followsYou: { - marginTop: -6, - borderRadius: 4, - overflow: 'hidden', - borderColor: palette.neutralLight4, - borderWidth: 1, - paddingVertical: spacing(1), - paddingHorizontal: spacing(2) - }, - info: { - flexDirection: 'column', - justifyContent: 'flex-start', - marginBottom: spacing(2) - }, - text: { - marginTop: spacing(2), - flexShrink: 1 - } -})) - type ProfileInfoProps = { onFollow: () => void } @@ -87,7 +36,6 @@ export const ProfileInfo = (props: ProfileInfoProps) => { const { getIsReachable } = reachabilitySelectors const isReachable = useSelector(getIsReachable) const accountHandle = useSelector(getUserHandle) - const styles = useStyles() const dispatch = useDispatch() const profileUserId = useSelector((state) => @@ -110,13 +58,11 @@ export const ProfileInfo = (props: ProfileInfoProps) => { const profile = useSelectProfile([ 'user_id', - 'name', 'handle', - 'does_current_user_follow', - 'is_verified' + 'does_current_user_follow' ]) - const { user_id, name, handle, does_current_user_follow } = profile + const { user_id, handle, does_current_user_follow } = profile const isOwner = params.handle === 'accountUser' || @@ -147,7 +93,7 @@ export const ProfileInfo = (props: ProfileInfoProps) => { ) return ( - + { > {isReachable ? actionButtons : null} - - - - {name} + + + + + @{handle} - - - - - - @{handle} - - - - - - + + + + ) } diff --git a/packages/mobile/src/screens/user-list-screen/UserListItem.tsx b/packages/mobile/src/screens/user-list-screen/UserListItem.tsx index 33dc2f4143a..13c53520fac 100644 --- a/packages/mobile/src/screens/user-list-screen/UserListItem.tsx +++ b/packages/mobile/src/screens/user-list-screen/UserListItem.tsx @@ -8,7 +8,7 @@ import { useSelector } from 'react-redux' import { IconUser } from '@audius/harmony-native' import { Text, ProfilePicture } from 'app/components/core' -import { FollowButton, FollowsYouChip } from 'app/components/user' +import { FollowButton, FollowsYouBadge } from 'app/components/user' import UserBadges from 'app/components/user-badges' import { useNavigation } from 'app/hooks/useNavigation' import { useColorAnimation } from 'app/hooks/usePressColorAnimation' @@ -108,7 +108,7 @@ export const UserListItem = (props: UserListItemProps) => { {messages.followers(follower_count)} - + {tag === 'SUPPORTING' ? : null} {tag === 'TOP SUPPORTERS' ? : null}