Skip to content

Commit

Permalink
Feat: address book indicator (#3790)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh authored Jun 4, 2024
1 parent 59b891d commit 37ea273
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/common/EthHashInfo/SrcEthHashInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import classnames from 'classnames'
import type { ReactNode, ReactElement, SyntheticEvent } from 'react'
import { isAddress } from 'ethers'
import { useTheme } from '@mui/material/styles'
import Box from '@mui/material/Box'
import { Box, SvgIcon, Tooltip } from '@mui/material'
import AddressBookIcon from '@/public/images/sidebar/address-book.svg'
import useMediaQuery from '@mui/material/useMediaQuery'
import Identicon from '../../Identicon'
import CopyAddressButton from '../../CopyAddressButton'
Expand All @@ -29,6 +30,7 @@ export type EthHashInfoProps = {
children?: ReactNode
trusted?: boolean
ExplorerButtonProps?: ExplorerButtonProps
isAddressBookName?: boolean
}

const stopPropagation = (e: SyntheticEvent) => e.stopPropagation()
Expand All @@ -50,6 +52,7 @@ const SrcEthHashInfo = ({
ExplorerButtonProps,
children,
trusted = true,
isAddressBookName = false,
}: EthHashInfoProps): ReactElement => {
const shouldPrefix = isAddress(address)
const theme = useTheme()
Expand Down Expand Up @@ -81,8 +84,16 @@ const SrcEthHashInfo = ({

<Box overflow="hidden" className={onlyName ? css.inline : undefined}>
{name && (
<Box textOverflow="ellipsis" overflow="hidden" title={name}>
<Box textOverflow="ellipsis" overflow="hidden" title={name} display="flex" alignItems="center" gap={0.5}>
{name}

{isAddressBookName && (
<Tooltip title="From your address book" placement="top">
<span style={{ lineHeight: 0 }}>
<SvgIcon component={AddressBookIcon} inheritViewBox color="border" fontSize="small" />
</span>
</Tooltip>
)}
</Box>
)}

Expand Down
1 change: 1 addition & 0 deletions src/components/common/EthHashInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const EthHashInfo = ({
copyPrefix={settings.shortName.copy}
{...props}
name={name}
isAddressBookName={!!addressBookName}
customAvatar={props.customAvatar}
ExplorerButtonProps={{ title: link?.title || '', href: link?.href || '' }}
avatarSize={avatarSize}
Expand Down

0 comments on commit 37ea273

Please sign in to comment.