-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathTokenLinkWithIcon.tsx
More file actions
61 lines (58 loc) · 1.84 KB
/
TokenLinkWithIcon.tsx
File metadata and controls
61 lines (58 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { FC } from 'react'
import { SearchScope } from '../../../types/searchScope'
import { TokenLink } from './TokenLink'
import { useAccountMetadata } from '../../hooks/useAccountMetadata'
import { InitialsAvatar } from '../AccountAvatar/InitialsAvatar'
import Tooltip from '@mui/material/Tooltip'
import { Trans, useTranslation } from 'react-i18next'
export const TokenLinkWithIcon: FC<{
scope: SearchScope
address: string
name: string | undefined
alwaysTrim?: boolean
}> = ({ scope, address, name, alwaysTrim }) => {
const { t } = useTranslation()
const { metadata } = useAccountMetadata(scope, address)
return (
<div className="flex items-center gap-2">
<Tooltip
placement="top"
arrow
slotProps={{ tooltip: { sx: { fontWeight: 'normal' } } }}
title={
metadata?.origin && (
<Trans
t={t}
i18nKey="tokens.originTooltip"
values={{
origin: metadata.origin,
}}
/>
)
}
>
<div className="leading-none">
{metadata?.icon ? (
<img src={metadata.icon} alt="" width={42} style={{ maxHeight: 32, margin: '-4px 0' }} />
) : (
<InitialsAvatar
name={metadata?.name || name || address.slice(2, 4)}
width={42}
style={{ maxHeight: 32, margin: '-4px 0' }}
/>
)}
</div>
</Tooltip>
<span
style={
alwaysTrim
? { whiteSpace: 'nowrap', maxWidth: '25vw', overflow: 'hidden', textOverflow: 'ellipsis' }
: {}
}
>
<TokenLink scope={scope} address={address} name={metadata?.name || name} />
<span className="text-muted-foreground">{metadata?.origin && ` (${metadata.origin})`}</span>
</span>
</div>
)
}