Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: address book indicator #3790

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading