diff --git a/.changelog/1246.feature.md b/.changelog/1246.feature.md new file mode 100644 index 0000000000..fba6defd8d --- /dev/null +++ b/.changelog/1246.feature.md @@ -0,0 +1 @@ +Initial support for displaying account names diff --git a/src/app/components/Account/AccountLink.tsx b/src/app/components/Account/AccountLink.tsx index 39ba6708a0..a81e3b65ac 100644 --- a/src/app/components/Account/AccountLink.tsx +++ b/src/app/components/Account/AccountLink.tsx @@ -10,6 +10,8 @@ import { useAccountName } from '../../hooks/useAccountName' import { trimLongString } from '../../utils/trimLongString' import { MaybeWithTooltip } from '../AdaptiveTrimmer/MaybeWithTooltip' import Box from '@mui/material/Box' +import { HighlightedText } from '../HighlightedText' +import { AdaptiveHighlightedText } from '../HighlightedText/AdaptiveHighlightedText' import { AdaptiveTrimmer } from '../AdaptiveTrimmer/AdaptiveTrimmer' const WithTypographyAndLink: FC<{ @@ -46,6 +48,11 @@ interface Props { */ alwaysTrim?: boolean + /** + * What part of the name should be highlighted (if any) + */ + highlightedPartOfName?: string | undefined + /** * Any extra tooltips to display * @@ -54,7 +61,13 @@ interface Props { extraTooltip?: ReactNode } -export const AccountLink: FC = ({ scope, address, alwaysTrim, extraTooltip }) => { +export const AccountLink: FC = ({ + scope, + address, + alwaysTrim, + highlightedPartOfName, + extraTooltip, +}) => { const { isTablet } = useScreenSize() const { name: accountName } = useAccountName(scope, address) const to = RouteUtils.getAccountRoute(scope, address) @@ -100,7 +113,7 @@ export const AccountLink: FC = ({ scope, address, alwaysTrim, extraToolti {accountName ? ( - {accountName} ({address}) + ({address}) ) : ( address @@ -116,7 +129,11 @@ export const AccountLink: FC = ({ scope, address, alwaysTrim, extraToolti return ( <> - + diff --git a/src/app/components/Account/index.tsx b/src/app/components/Account/index.tsx index 3ab89c2ba6..bc275873ea 100644 --- a/src/app/components/Account/index.tsx +++ b/src/app/components/Account/index.tsx @@ -30,9 +30,17 @@ type AccountProps = { isLoading: boolean tokenPrices: AllTokenPrices showLayer?: boolean + highlightedPartOfName: string | undefined } -export const Account: FC = ({ account, token, isLoading, tokenPrices, showLayer }) => { +export const Account: FC = ({ + account, + token, + isLoading, + tokenPrices, + showLayer, + highlightedPartOfName, +}) => { const { t } = useTranslation() const { isMobile } = useScreenSize() const address = account ? account.address_eth ?? account.address : undefined @@ -67,7 +75,7 @@ export const Account: FC = ({ account, token, isLoading, tokenPric
- +
diff --git a/src/app/pages/ConsensusAccountDetailsPage/DeferredConsensusAccountDetails.tsx b/src/app/pages/ConsensusAccountDetailsPage/DeferredConsensusAccountDetails.tsx index b3e3ee690d..5720b4ecd7 100644 --- a/src/app/pages/ConsensusAccountDetailsPage/DeferredConsensusAccountDetails.tsx +++ b/src/app/pages/ConsensusAccountDetailsPage/DeferredConsensusAccountDetails.tsx @@ -9,6 +9,7 @@ export const DeferredConsensusAccountDetails: FC<{ network: Network address: string tokenPrices: AllTokenPrices + highlightedPartOfName: string | undefined showLayer?: boolean }> = () => // { diff --git a/src/app/pages/RuntimeAccountDetailsPage/AccountDetailsCard.tsx b/src/app/pages/RuntimeAccountDetailsPage/AccountDetailsCard.tsx index 18c57866db..ca4f98625e 100644 --- a/src/app/pages/RuntimeAccountDetailsPage/AccountDetailsCard.tsx +++ b/src/app/pages/RuntimeAccountDetailsPage/AccountDetailsCard.tsx @@ -12,6 +12,7 @@ type AccountDetailsProps = { account: RuntimeAccount | undefined token: EvmToken | undefined tokenPrices: AllTokenPrices + highlightedPartOfName?: string | undefined } export const AccountDetailsCard: FC = ({ @@ -21,6 +22,7 @@ export const AccountDetailsCard: FC = ({ account, token, tokenPrices, + highlightedPartOfName, }) => { const { t } = useTranslation() return ( @@ -36,6 +38,7 @@ export const AccountDetailsCard: FC = ({ account={account} token={token} tokenPrices={tokenPrices} + highlightedPartOfName={highlightedPartOfName} /> ) diff --git a/src/app/pages/RuntimeAccountDetailsPage/AccountDetailsView.tsx b/src/app/pages/RuntimeAccountDetailsPage/AccountDetailsView.tsx index 0c9f702259..4e94e2a4d0 100644 --- a/src/app/pages/RuntimeAccountDetailsPage/AccountDetailsView.tsx +++ b/src/app/pages/RuntimeAccountDetailsPage/AccountDetailsView.tsx @@ -12,7 +12,8 @@ export const AccountDetailsView: FC<{ token?: EvmToken tokenPrices: AllTokenPrices showLayer?: boolean -}> = ({ isLoading, isError, account, token, tokenPrices, showLayer }) => { + highlightedPartOfName?: string | undefined +}> = ({ isLoading, isError, account, token, tokenPrices, showLayer, highlightedPartOfName }) => { const { t } = useTranslation() return isError ? ( @@ -23,6 +24,7 @@ export const AccountDetailsView: FC<{ isLoading={isLoading} tokenPrices={tokenPrices} showLayer={showLayer} + highlightedPartOfName={highlightedPartOfName} /> ) } diff --git a/src/app/pages/RuntimeAccountDetailsPage/DeferredRuntimeAccountDetails.tsx b/src/app/pages/RuntimeAccountDetailsPage/DeferredRuntimeAccountDetails.tsx index e00cdd468d..882f742cc0 100644 --- a/src/app/pages/RuntimeAccountDetailsPage/DeferredRuntimeAccountDetails.tsx +++ b/src/app/pages/RuntimeAccountDetailsPage/DeferredRuntimeAccountDetails.tsx @@ -12,8 +12,9 @@ export const DeferredRuntimeAccountDetails: FC<{ layer: Runtime address: string tokenPrices: AllTokenPrices + highlightedPartOfName: string | undefined showLayer?: boolean -}> = ({ network, layer, address, tokenPrices, showLayer }) => { +}> = ({ network, layer, address, tokenPrices, highlightedPartOfName, showLayer }) => { const { data, isLoading, isError } = useGetRuntimeAccountsAddress(network, layer, address) return ( ) } diff --git a/src/app/pages/RuntimeAccountDetailsPage/index.tsx b/src/app/pages/RuntimeAccountDetailsPage/index.tsx index b6c50e28d7..8d57ecd013 100644 --- a/src/app/pages/RuntimeAccountDetailsPage/index.tsx +++ b/src/app/pages/RuntimeAccountDetailsPage/index.tsx @@ -32,7 +32,7 @@ export const RuntimeAccountDetailsPage: FC = () => { const { t } = useTranslation() const scope = useRequiredScopeParam() - const { address } = useLoaderData() as AddressLoaderData + const { address, searchTerm } = useLoaderData() as AddressLoaderData const { account, isLoading: isAccountLoading, isError } = useAccount(scope, address) const isContract = !!account?.evm_contract const { token, isLoading: isTokenLoading } = useTokenInfo(scope, address, isContract) @@ -62,6 +62,7 @@ export const RuntimeAccountDetailsPage: FC = () => { account={account} token={token} tokenPrices={tokenPrices} + highlightedPartOfName={searchTerm} /> ) : ( @@ -117,6 +118,7 @@ export const SearchResultsList: FC<{ layer={item.layer} address={item.address} tokenPrices={tokenPrices} + highlightedPartOfName={searchTerm} showLayer={true} /> )