From c14df635b6d46d12a2473bf4d73650f9751ae498 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Fri, 23 Feb 2024 05:06:57 +0100 Subject: [PATCH] Implement highlighting matches in account names in search results --- src/app/components/Account/index.tsx | 12 ++++++++++-- .../DeferredConsensusAccountDetails.tsx | 1 + .../RuntimeAccountDetailsPage/AccountDetailsCard.tsx | 3 +++ .../RuntimeAccountDetailsPage/AccountDetailsView.tsx | 4 +++- .../DeferredRuntimeAccountDetails.tsx | 4 +++- src/app/pages/RuntimeAccountDetailsPage/index.tsx | 3 ++- .../pages/SearchResultsPage/SearchResultsList.tsx | 2 ++ 7 files changed, 24 insertions(+), 5 deletions(-) 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} /> )