Skip to content

Commit

Permalink
Implement highlighting matches in account names in search results
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed May 16, 2024
1 parent 1358c4a commit c14df63
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/app/components/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ type AccountProps = {
isLoading: boolean
tokenPrices: AllTokenPrices
showLayer?: boolean
highlightedPartOfName: string | undefined
}

export const Account: FC<AccountProps> = ({ account, token, isLoading, tokenPrices, showLayer }) => {
export const Account: FC<AccountProps> = ({
account,
token,
isLoading,
tokenPrices,
showLayer,
highlightedPartOfName,
}) => {
const { t } = useTranslation()
const { isMobile } = useScreenSize()
const address = account ? account.address_eth ?? account.address : undefined
Expand Down Expand Up @@ -67,7 +75,7 @@ export const Account: FC<AccountProps> = ({ account, token, isLoading, tokenPric
<AccountAvatar account={account} />
</StyledListTitleWithAvatar>
<dd>
<AccountLink scope={account} address={address!} />
<AccountLink scope={account} address={address!} highlightedPartOfName={highlightedPartOfName} />
<CopyToClipboard value={address!} />
</dd>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const DeferredConsensusAccountDetails: FC<{
network: Network
address: string
tokenPrices: AllTokenPrices
highlightedPartOfName: string | undefined
showLayer?: boolean
}> = () =>
// {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type AccountDetailsProps = {
account: RuntimeAccount | undefined
token: EvmToken | undefined
tokenPrices: AllTokenPrices
highlightedPartOfName?: string | undefined
}

export const AccountDetailsCard: FC<AccountDetailsProps> = ({
Expand All @@ -21,6 +22,7 @@ export const AccountDetailsCard: FC<AccountDetailsProps> = ({
account,
token,
tokenPrices,
highlightedPartOfName,
}) => {
const { t } = useTranslation()
return (
Expand All @@ -36,6 +38,7 @@ export const AccountDetailsCard: FC<AccountDetailsProps> = ({
account={account}
token={token}
tokenPrices={tokenPrices}
highlightedPartOfName={highlightedPartOfName}
/>
</SubPageCard>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? (
<CardEmptyState label={t('account.cantLoadDetails')} />
Expand All @@ -23,6 +24,7 @@ export const AccountDetailsView: FC<{
isLoading={isLoading}
tokenPrices={tokenPrices}
showLayer={showLayer}
highlightedPartOfName={highlightedPartOfName}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<AccountDetailsView
Expand All @@ -22,6 +23,7 @@ export const DeferredRuntimeAccountDetails: FC<{
account={data?.data}
tokenPrices={tokenPrices}
showLayer={showLayer}
highlightedPartOfName={highlightedPartOfName}
/>
)
}
3 changes: 2 additions & 1 deletion src/app/pages/RuntimeAccountDetailsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -62,6 +62,7 @@ export const RuntimeAccountDetailsPage: FC = () => {
account={account}
token={token}
tokenPrices={tokenPrices}
highlightedPartOfName={searchTerm}
/>
<DappBanner scope={scope} ethAddress={account?.address_eth} />
<RouterTabs
Expand Down
2 changes: 2 additions & 0 deletions src/app/pages/SearchResultsPage/SearchResultsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const SearchResultsList: FC<{
network={item.network}
address={item.address}
tokenPrices={tokenPrices}
highlightedPartOfName={searchTerm}
showLayer={true}
/>
) : (
Expand All @@ -117,6 +118,7 @@ export const SearchResultsList: FC<{
layer={item.layer}
address={item.address}
tokenPrices={tokenPrices}
highlightedPartOfName={searchTerm}
showLayer={true}
/>
)
Expand Down

0 comments on commit c14df63

Please sign in to comment.