import * as React from 'react' import { Avatar } from '@dcl/schemas/dist/platform/profile/avatar' import { Logo } from '../Logo/Logo' import { Popup } from '../Popup/Popup' import { AvatarFace } from '../AvatarFace/AvatarFace' import { Blockie } from '../Blockie/Blockie' import './Profile.css' type Props = { address: string avatar?: Avatar | null textOnly?: boolean imageOnly?: boolean hasPopup?: boolean inline?: boolean sliceAddressBy?: number size?: 'normal' | 'large' | 'huge' | 'massive' isDecentraland?: boolean i18n?: { defaultName: string } as?: T } export type ProfileProps = Props & Omit, keyof Props> /** * @deprecated Should start using the same component migrated to UI2. */ export const Profile = function ( props: ProfileProps ) { const { address, avatar, textOnly, imageOnly, hasPopup, inline = true, size = 'normal', sliceAddressBy = 6, isDecentraland, as = React.Fragment, ...rest } = props const sliceLimit = Math.max(Math.min(sliceAddressBy, 42), 6) const name = React.useMemo(() => { if (!avatar || !avatar.name) { return address.slice(0, sliceLimit) } if (avatar.hasClaimedName) { return avatar.name } const lastPart = address ? `#${address.slice(-4)}` : '' return avatar.name.endsWith(lastPart) ? avatar.name : avatar.name + lastPart }, [avatar, address, sliceLimit]) const Wrapper = as if (isDecentraland) { return ( {imageOnly ? null : ( Decentraland )} ) } if (textOnly) { return {name} } else { return ( {imageOnly ? null : ( {name} )} ) : ( {imageOnly ? null : ( {name} )} ) } /> ) } }