Commit c2d56a21 authored by isstuev's avatar isstuev

review-fixes

parent 64b466b6
...@@ -72,15 +72,13 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => { ...@@ -72,15 +72,13 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
case 'address': { case 'address': {
const shouldHighlightHash = data.address.toLowerCase() === searchTerm.toLowerCase(); const shouldHighlightHash = data.address.toLowerCase() === searchTerm.toLowerCase();
return ( return (
<Flex alignItems="center" overflow="hidden">
<Address> <Address>
<AddressIcon address={{ hash: data.address, is_contract: data.type === 'contract', implementation_name: null }} mr={ 2 } flexShrink={ 0 }/> <AddressIcon address={{ hash: data.address, is_contract: data.type === 'contract', implementation_name: null }} mr={ 2 } flexShrink={ 0 }/>
<Box as={ shouldHighlightHash ? 'mark' : 'span' } display="block" whiteSpace="nowrap" overflow="hidden"> <Box as={ shouldHighlightHash ? 'mark' : 'span' } display="block" whiteSpace="nowrap" overflow="hidden">
<AddressLink type="address" hash={ data.address } fontWeight={ 700 } display="block" w="100%" onClick={ handleLinkClick }/> <AddressLink type="address" hash={ data.address } fontWeight={ 700 } display="block" w="100%" onClick={ handleLinkClick }/>
</Box> </Box>
</Address>
{ data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> } { data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> }
</Flex> </Address>
); );
} }
......
...@@ -119,15 +119,13 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => { ...@@ -119,15 +119,13 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
return ( return (
<Td colSpan={ 3 } fontSize="sm"> <Td colSpan={ 3 } fontSize="sm">
<Flex alignItems="center" overflow="hidden">
<Address> <Address>
<AddressIcon address={{ hash: data.address, is_contract: data.type === 'contract', implementation_name: null }} mr={ 2 } flexShrink={ 0 }/> <AddressIcon address={{ hash: data.address, is_contract: data.type === 'contract', implementation_name: null }} mr={ 2 } flexShrink={ 0 }/>
<mark> <mark>
<AddressLink hash={ data.address } type="address" fontWeight={ 700 } onClick={ handleLinkClick }/> <AddressLink hash={ data.address } type="address" fontWeight={ 700 } onClick={ handleLinkClick }/>
</mark> </mark>
</Address>
{ data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> } { data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> }
</Flex> </Address>
</Td> </Td>
); );
} }
......
...@@ -128,7 +128,7 @@ const SearchBar = ({ isHomepage }: Props) => { ...@@ -128,7 +128,7 @@ const SearchBar = ({ isHomepage }: Props) => {
w={ `${ menuWidth.current }px` } w={ `${ menuWidth.current }px` }
ref={ menuRef } ref={ menuRef }
> >
<PopoverBody py={ 0 } color="chakra-body-text"> <PopoverBody p={ 0 } color="chakra-body-text">
<Box <Box
maxH="50vh" maxH="50vh"
overflowY="scroll" overflowY="scroll"
...@@ -136,6 +136,7 @@ const SearchBar = ({ isHomepage }: Props) => { ...@@ -136,6 +136,7 @@ const SearchBar = ({ isHomepage }: Props) => {
ref={ scrollRef } ref={ scrollRef }
as={ Element } as={ Element }
sx={ isHomepage ? { mark: { bgColor: 'green.100' } } : {} } sx={ isHomepage ? { mark: { bgColor: 'green.100' } } : {} }
px={ 4 }
> >
{ searchTerm.trim().length === 0 && recentSearchKeywords.length > 0 && ( { searchTerm.trim().length === 0 && recentSearchKeywords.length > 0 && (
<SearchBarRecentKeywords onClick={ handleSearchTermChange } onClear={ onClose }/> <SearchBarRecentKeywords onClick={ handleSearchTermChange } onClear={ onClose }/>
......
...@@ -78,7 +78,7 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props ...@@ -78,7 +78,7 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
return map; return map;
}, [ query.data?.items ]); }, [ query.data?.items ]);
const scrollToCategory = React.useCallback((index: number) => { const scrollToCategory = React.useCallback((index: number) => () => {
setTabIndex(index); setTabIndex(index);
scroller.scrollTo(`cat_${ index }`, { scroller.scrollTo(`cat_${ index }`, {
duration: 250, duration: 250,
...@@ -99,22 +99,26 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props ...@@ -99,22 +99,26 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
return <Text>Something went wrong. Try refreshing the page or come back later.</Text>; return <Text>Something went wrong. Try refreshing the page or come back later.</Text>;
} }
if (!query.data.items || query.data.items.length === 0) {
return <Text>No results found.</Text>;
}
const resultCategories = searchCategories.filter(cat => itemsGroups[cat.id]); const resultCategories = searchCategories.filter(cat => itemsGroups[cat.id]);
return ( return (
<> <>
{ resultCategories.length > 1 && ( { resultCategories.length > 1 && (
<Box position="sticky" top="0" width="100%" background={ bgColor } py={ 5 } my={ -5 } ref={ tabsRef }> <Box position="sticky" top="0" width="100%" background={ bgColor } py={ 5 } my={ -5 } ref={ tabsRef }>
<Tabs variant="outline" colorScheme="gray" size="sm" onChange={ scrollToCategory } index={ tabIndex }> <Tabs variant="outline" colorScheme="gray" size="sm" index={ tabIndex }>
<TabList columnGap={ 3 } rowGap={ 2 } flexWrap="wrap"> <TabList columnGap={ 3 } rowGap={ 2 } flexWrap="wrap">
{ resultCategories.map(cat => <Tab key={ cat.id }>{ cat.title }</Tab>) } { resultCategories.map((cat, index) => <Tab key={ cat.id } onClick={ scrollToCategory(index) }>{ cat.title }</Tab>) }
</TabList> </TabList>
</Tabs> </Tabs>
</Box> </Box>
) } ) }
{ resultCategories.map((cat, indx) => { { resultCategories.map((cat, indx) => {
return ( return (
<Element name={ `cat_${ indx }` } key={ indx }> <Element name={ `cat_${ indx }` } key={ cat.id }>
<Text <Text
fontSize="sm" fontSize="sm"
fontWeight={ 600 } fontWeight={ 600 }
......
...@@ -16,17 +16,25 @@ interface Props { ...@@ -16,17 +16,25 @@ interface Props {
const SearchBarSuggestAddress = ({ data, isMobile, searchTerm }: Props) => { const SearchBarSuggestAddress = ({ data, isMobile, searchTerm }: Props) => {
const shouldHighlightHash = data.address.toLowerCase() === searchTerm.toLowerCase(); const shouldHighlightHash = data.address.toLowerCase() === searchTerm.toLowerCase();
const icon = <AddressIcon address={{ hash: data.address, is_contract: data.type === 'contract', implementation_name: null }} flexShrink={ 0 }/>;
const name = data.name && (
<Text
variant="secondary"
overflow="hidden"
whiteSpace="nowrap"
textOverflow="ellipsis"
>
<span dangerouslySetInnerHTML={{ __html: highlightText(data.name, searchTerm) }}/>
</Text>
);
const isContractVerified = data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500"/>;
const address = <HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>;
if (isMobile) { if (isMobile) {
return ( return (
<> <>
<Flex alignItems="center" justifyContent="space-between"> <Flex alignItems="center" justifyContent="space-between" gap={ 2 }>
<AddressIcon { icon }
address={{ hash: data.address, is_contract: data.type === 'contract', implementation_name: null }}
mr={ 2 }
flexShrink={ 0 }
/>
<Box <Box
as={ shouldHighlightHash ? 'mark' : 'span' } as={ shouldHighlightHash ? 'mark' : 'span' }
display="block" display="block"
...@@ -36,34 +44,19 @@ const SearchBarSuggestAddress = ({ data, isMobile, searchTerm }: Props) => { ...@@ -36,34 +44,19 @@ const SearchBarSuggestAddress = ({ data, isMobile, searchTerm }: Props) => {
flexGrow={ 1 } flexGrow={ 1 }
> >
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/> { address }
</Box> </Box>
{ data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> } { isContractVerified }
</Flex> </Flex>
{ data.name && ( { name }
<Text
variant="secondary"
overflow="hidden"
whiteSpace="nowrap"
textOverflow="ellipsis"
flexGrow={ 1 }
>
<span dangerouslySetInnerHTML={{ __html: highlightText(data.name, searchTerm) }}/>
</Text>
) }
</> </>
); );
} }
return ( return (
<Flex alignItems="center"> <Flex alignItems="center" gap={ 2 }>
<AddressIcon { icon }
address={{ hash: data.address, is_contract: data.type === 'contract', implementation_name: null }} <Flex alignItems="center" w="450px" gap={ 2 }>
mr={ 2 }
flexShrink={ 0 }
/>
<Flex alignItems="center" w="420px">
<Box <Box
as={ shouldHighlightHash ? 'mark' : 'span' } as={ shouldHighlightHash ? 'mark' : 'span' }
display="block" display="block"
...@@ -71,22 +64,11 @@ const SearchBarSuggestAddress = ({ data, isMobile, searchTerm }: Props) => { ...@@ -71,22 +64,11 @@ const SearchBarSuggestAddress = ({ data, isMobile, searchTerm }: Props) => {
whiteSpace="nowrap" whiteSpace="nowrap"
fontWeight={ 700 } fontWeight={ 700 }
> >
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/> { address }
</Box> </Box>
{ data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> } { isContractVerified }
</Flex> </Flex>
{ data.name && ( { name }
<Text
variant="secondary"
overflow="hidden"
whiteSpace="nowrap"
textOverflow="ellipsis"
flexGrow={ 0 }
ml={ 6 }
>
<span dangerouslySetInnerHTML={{ __html: highlightText(data.name, searchTerm) }}/>
</Text>
) }
</Flex> </Flex>
); );
}; };
......
...@@ -15,13 +15,9 @@ interface Props { ...@@ -15,13 +15,9 @@ interface Props {
} }
const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: Props) => { const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: Props) => {
const icon = <Icon as={ blockIcon } boxSize={ 6 } color="gray.500"/>;
const shouldHighlightHash = data.block_hash.toLowerCase() === searchTerm.toLowerCase(); const shouldHighlightHash = data.block_hash.toLowerCase() === searchTerm.toLowerCase();
const blockNumber = (
if (isMobile) {
return (
<>
<Flex alignItems="center">
<Icon as={ blockIcon } boxSize={ 6 } mr={ 2 } color="gray.500"/>
<Text <Text
fontWeight={ 700 } fontWeight={ 700 }
overflow="hidden" overflow="hidden"
...@@ -30,27 +26,8 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: Props) => { ...@@ -30,27 +26,8 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: Props) => {
> >
<span dangerouslySetInnerHTML={{ __html: highlightText(data.block_number.toString(), searchTerm) }}/> <span dangerouslySetInnerHTML={{ __html: highlightText(data.block_number.toString(), searchTerm) }}/>
</Text> </Text>
</Flex>
<Text variant="secondary" overflow="hidden" whiteSpace="nowrap" as={ shouldHighlightHash ? 'mark' : 'span' } display="block">
<HashStringShortenDynamic hash={ data.block_hash } isTooltipDisabled/>
</Text>
<Text variant="secondary">{ dayjs(data.timestamp).format('llll') }</Text>
</>
); );
} const hash = (
return (
<Grid templateColumns="24px auto minmax(auto, max-content) auto" gap={ 2 }>
<Icon as={ blockIcon } boxSize={ 6 } color="gray.500"/>
<Text
fontWeight={ 700 }
overflow="hidden"
whiteSpace="nowrap"
textOverflow="ellipsis"
w="200px"
>
<span dangerouslySetInnerHTML={{ __html: highlightText(data.block_number.toString(), searchTerm) }}/>
</Text>
<Text <Text
variant="secondary" variant="secondary"
overflow="hidden" overflow="hidden"
...@@ -60,7 +37,28 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: Props) => { ...@@ -60,7 +37,28 @@ const SearchBarSuggestBlock = ({ data, isMobile, searchTerm }: Props) => {
> >
<HashStringShortenDynamic hash={ data.block_hash } isTooltipDisabled/> <HashStringShortenDynamic hash={ data.block_hash } isTooltipDisabled/>
</Text> </Text>
<Text variant="secondary" textAlign="end">{ dayjs(data.timestamp).format('llll') }</Text> );
const date = dayjs(data.timestamp).format('llll');
if (isMobile) {
return (
<>
<Flex alignItems="center" gap={ 2 }>
{ icon }
{ blockNumber }
</Flex>
{ hash }
<Text variant="secondary">{ date }</Text>
</>
);
}
return (
<Grid templateColumns="24px 200px minmax(auto, max-content) auto" gap={ 2 }>
{ icon }
{ blockNumber }
{ hash }
<Text variant="secondary" textAlign="end">{ date }</Text>
</Grid> </Grid>
); );
}; };
......
import { Text, Flex, Icon } from '@chakra-ui/react'; import { Grid, Text, Flex, Icon } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { SearchResultLabel } from 'types/api/search'; import type { SearchResultLabel } from 'types/api/search';
...@@ -15,54 +15,53 @@ interface Props { ...@@ -15,54 +15,53 @@ interface Props {
} }
const SearchBarSuggestLabel = ({ data, isMobile, searchTerm }: Props) => { const SearchBarSuggestLabel = ({ data, isMobile, searchTerm }: Props) => {
if (isMobile) { const icon = <Icon as={ labelIcon } boxSize={ 6 } color="gray.500"/>;
return (
<> const name = (
<Flex alignItems="center" overflow="hidden">
<Icon as={ labelIcon } boxSize={ 6 } mr={ 2 } color="gray.500"/>
<Text <Text
fontWeight={ 700 } fontWeight={ 700 }
overflow="hidden" overflow="hidden"
whiteSpace="nowrap" whiteSpace="nowrap"
textOverflow="ellipsis" textOverflow="ellipsis"
flexGrow={ 1 }
> >
<span dangerouslySetInnerHTML={{ __html: highlightText(data.name, searchTerm) }}/> <span dangerouslySetInnerHTML={{ __html: highlightText(data.name, searchTerm) }}/>
</Text> </Text>
</Flex>
<Flex alignItems="center" justifyContent="space-between" overflow="hidden">
<Text overflow="hidden" whiteSpace="nowrap" variant="secondary">
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>
</Text>
{ data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> }
</Flex>
</>
); );
}
return ( const address = (
<Flex alignItems="center">
<Icon as={ labelIcon } boxSize={ 6 } mr={ 2 } color="gray.500"/>
<Text
fontWeight={ 700 }
overflow="hidden"
whiteSpace="nowrap"
textOverflow="ellipsis"
flexGrow={ 0 }
w="200px"
>
<span dangerouslySetInnerHTML={{ __html: highlightText(data.name, searchTerm) }}/>
</Text>
<Text <Text
overflow="hidden" overflow="hidden"
whiteSpace="nowrap" whiteSpace="nowrap"
variant="secondary" variant="secondary"
ml={ 2 }
> >
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/> <HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>
</Text> </Text>
{ data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> } );
const isContractVerified = data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500"/>;
if (isMobile) {
return (
<>
<Flex alignItems="center" overflow="hidden" gap={ 2 }>
{ icon }
{ name }
</Flex>
<Flex alignItems="center" justifyContent="space-between" overflow="hidden" gap={ 2 }>
{ address }
{ isContractVerified }
</Flex> </Flex>
</>
);
}
return (
<Grid alignItems="center" gridTemplateColumns="24px 200px max-content 24px" gap={ 2 }>
{ icon }
{ name }
{ address }
{ isContractVerified }
</Grid>
); );
}; };
......
...@@ -15,61 +15,61 @@ interface Props { ...@@ -15,61 +15,61 @@ interface Props {
} }
const SearchBarSuggestToken = ({ data, isMobile, searchTerm }: Props) => { const SearchBarSuggestToken = ({ data, isMobile, searchTerm }: Props) => {
const name = data.name + (data.symbol ? ` (${ data.symbol })` : ''); const icon = <TokenLogo boxSize={ 6 } data={ data }/>;
const name = (
if (isMobile) {
return (
<>
<Flex alignItems="center" justifyContent="space-between">
<TokenLogo boxSize={ 6 } data={ data } flexShrink={ 0 }/>
<Text <Text
fontWeight={ 700 } fontWeight={ 700 }
overflow="hidden" overflow="hidden"
whiteSpace="nowrap" whiteSpace="nowrap"
textOverflow="ellipsis" textOverflow="ellipsis"
ml={ 2 }
flexGrow={ 1 }
> >
<span dangerouslySetInnerHTML={{ __html: highlightText(name, searchTerm) }}/> <span dangerouslySetInnerHTML={{ __html: highlightText(data.name + (data.symbol ? ` (${ data.symbol })` : ''), searchTerm) }}/>
</Text> </Text>
</Flex> );
<Grid templateColumns="1fr auto auto" alignItems="center">
const address = (
<Text variant="secondary" whiteSpace="nowrap" overflow="hidden"> <Text variant="secondary" whiteSpace="nowrap" overflow="hidden">
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/> <HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>
</Text> </Text>
{ data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> } );
<Text overflow="hidden" whiteSpace="nowrap" textOverflow="ellipsis"ml={ 2 } fontWeight={ 700 } maxW="200px">
const contractVerifiedIcon = data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500"/>;
const additionalInfo = (
<Text overflow="hidden" whiteSpace="nowrap" fontWeight={ 700 }>
{ data.token_type === 'ERC-20' && data.exchange_rate && `$${ Number(data.exchange_rate).toLocaleString() }` } { data.token_type === 'ERC-20' && data.exchange_rate && `$${ Number(data.exchange_rate).toLocaleString() }` }
{ data.token_type !== 'ERC-20' && data.total_supply && `Items ${ Number(data.total_supply).toLocaleString() }` } { data.token_type !== 'ERC-20' && data.total_supply && `Items ${ Number(data.total_supply).toLocaleString() }` }
</Text> </Text>
);
if (isMobile) {
const templateCols = `1fr
${ data.is_smart_contract_verified ? ' auto' : '' }
${ (data.token_type === 'ERC-20' && data.exchange_rate) || (data.token_type !== 'ERC-20' && data.total_supply) ? ' auto' : '' }`;
return (
<>
<Flex alignItems="center" gap={ 2 }>
{ icon }
{ name }
</Flex>
<Grid templateColumns={ templateCols } alignItems="center" gap={ 2 }>
{ address }
{ contractVerifiedIcon }
{ additionalInfo }
</Grid> </Grid>
</> </>
); );
} }
return ( return (
<Grid templateColumns="24px 200px 1fr auto"> <Grid templateColumns="24px 200px 1fr auto" gap={ 2 }>
<TokenLogo boxSize={ 6 } data={ data }/> { icon }
<Text { name }
fontWeight={ 700 } <Flex alignItems="center" gap={ 2 }>
overflow="hidden" { address }
whiteSpace="nowrap" { contractVerifiedIcon }
textOverflow="ellipsis"
ml={ 2 }
flexGrow={ 0 }
>
<span dangerouslySetInnerHTML={{ __html: highlightText(name, searchTerm) }}/>
</Text>
<Flex alignItems="center">
<Text overflow="hidden" whiteSpace="nowrap" ml={ 2 } variant="secondary">
<HashStringShortenDynamic hash={ data.address } isTooltipDisabled/>
</Text>
{ data.is_smart_contract_verified && <Icon as={ iconSuccess } color="green.500" ml={ 2 }/> }
</Flex> </Flex>
<Text overflow="hidden" whiteSpace="nowrap" ml={ 2 } fontWeight={ 700 }> { additionalInfo }
{ data.token_type === 'ERC-20' && data.exchange_rate && `$${ Number(data.exchange_rate).toLocaleString() }` }
{ data.token_type !== 'ERC-20' && data.total_supply && `Items ${ Number(data.total_supply).toLocaleString() }` }
</Text>
</Grid> </Grid>
); );
}; };
......
...@@ -14,28 +14,31 @@ interface Props { ...@@ -14,28 +14,31 @@ interface Props {
} }
const SearchBarSuggestTx = ({ data, isMobile }: Props) => { const SearchBarSuggestTx = ({ data, isMobile }: Props) => {
if (isMobile) { const icon = <Icon as={ txIcon } boxSize={ 6 } color="gray.500"/>;
return ( const hash = (
<>
<Flex alignItems="center" justifyContent="space-between">
<Icon as={ txIcon } boxSize={ 6 } mr={ 2 } color="gray.500"/>
<chakra.mark overflow="hidden" whiteSpace="nowrap" fontWeight={ 700 }> <chakra.mark overflow="hidden" whiteSpace="nowrap" fontWeight={ 700 }>
<HashStringShortenDynamic hash={ data.tx_hash } isTooltipDisabled/> <HashStringShortenDynamic hash={ data.tx_hash } isTooltipDisabled/>
</chakra.mark> </chakra.mark>
);
const date = dayjs(data.timestamp).format('llll');
if (isMobile) {
return (
<>
<Flex alignItems="center" justifyContent="space-between" gap={ 2 }>
{ icon }
{ hash }
</Flex> </Flex>
<Text variant="secondary">{ dayjs(data.timestamp).format('llll') }</Text> <Text variant="secondary">{ date }</Text>
</> </>
); );
} }
return ( return (
<Grid templateColumns="24px minmax(auto, max-content) auto" gap={ 2 }> <Grid templateColumns="24px minmax(auto, max-content) auto" gap={ 2 }>
<Icon as={ txIcon } boxSize={ 6 } color="gray.500"/> { icon }
{ hash }
<chakra.mark overflow="hidden" whiteSpace="nowrap" display="block" fontWeight={ 700 } > <Text variant="secondary" textAlign="end">{ date }</Text>
<HashStringShortenDynamic hash={ data.tx_hash } isTooltipDisabled/>
</chakra.mark>
<Text variant="secondary" textAlign="end">{ dayjs(data.timestamp).format('llll') }</Text>
</Grid> </Grid>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment