Commit 90f5ec53 authored by tom's avatar tom

add icon for tokens in search results

parent 2ae0217f
...@@ -7,6 +7,7 @@ export const token1: SearchResultToken = { ...@@ -7,6 +7,7 @@ export const token1: SearchResultToken = {
symbol: 'TNT', symbol: 'TNT',
token_url: '/token/0x377c5F2B300B25a534d4639177873b7fEAA56d4B', token_url: '/token/0x377c5F2B300B25a534d4639177873b7fEAA56d4B',
type: 'token' as const, type: 'token' as const,
icon_url: 'http://localhost:3000/token-icon.png',
}; };
export const token2: SearchResultToken = { export const token2: SearchResultToken = {
...@@ -16,6 +17,7 @@ export const token2: SearchResultToken = { ...@@ -16,6 +17,7 @@ export const token2: SearchResultToken = {
symbol: 'pdE1B', symbol: 'pdE1B',
token_url: '/token/0xC35Cc7223B0175245E9964f2E3119c261E8e21F9', token_url: '/token/0xC35Cc7223B0175245E9964f2E3119c261E8e21F9',
type: 'token' as const, type: 'token' as const,
icon_url: null,
}; };
export const block1: SearchResultBlock = { export const block1: SearchResultBlock = {
......
...@@ -9,7 +9,7 @@ export const tokenInfo: TokenInfo = { ...@@ -9,7 +9,7 @@ export const tokenInfo: TokenInfo = {
symbol: 'ARIA', symbol: 'ARIA',
type: 'ERC-20', type: 'ERC-20',
total_supply: '1235', total_supply: '1235',
icon_url: null, icon_url: 'http://localhost:3000/token-icon.png',
}; };
export const tokenCounters: TokenCounters = { export const tokenCounters: TokenCounters = {
......
...@@ -7,6 +7,7 @@ export interface SearchResultToken { ...@@ -7,6 +7,7 @@ export interface SearchResultToken {
address: string; address: string;
token_url: string; token_url: string;
address_url: string; address_url: string;
icon_url: string | null;
} }
export interface SearchResultAddressOrContract { export interface SearchResultAddressOrContract {
......
...@@ -23,6 +23,12 @@ test('search by name +@mobile +@dark-mode', async({ mount, page }) => { ...@@ -23,6 +23,12 @@ test('search by name +@mobile +@dark-mode', async({ mount, page }) => {
], ],
}), }),
})); }));
await page.route(searchMock.token1.icon_url as string, (route) => {
return route.fulfill({
status: 200,
path: './playwright/image_s.jpg',
});
});
const component = await mount( const component = await mount(
<TestApp> <TestApp>
......
...@@ -76,6 +76,12 @@ test('with verified info', async({ mount, page, createSocket }) => { ...@@ -76,6 +76,12 @@ test('with verified info', async({ mount, page, createSocket }) => {
await page.route(VERIFIED_INFO_URL, (route) => route.fulfill({ await page.route(VERIFIED_INFO_URL, (route) => route.fulfill({
body: JSON.stringify(verifiedAddressesMocks.TOKEN_INFO_APPLICATION.APPROVED), body: JSON.stringify(verifiedAddressesMocks.TOKEN_INFO_APPLICATION.APPROVED),
})); }));
await page.route(tokenInfo.icon_url as string, (route) => {
return route.fulfill({
status: 200,
path: './playwright/image_s.jpg',
});
});
const component = await mount( const component = await mount(
<TestApp withSocket> <TestApp withSocket>
...@@ -119,6 +125,12 @@ test.describe('mobile', () => { ...@@ -119,6 +125,12 @@ test.describe('mobile', () => {
await page.route(VERIFIED_INFO_URL, (route) => route.fulfill({ await page.route(VERIFIED_INFO_URL, (route) => route.fulfill({
body: JSON.stringify(verifiedAddressesMocks.TOKEN_INFO_APPLICATION.APPROVED), body: JSON.stringify(verifiedAddressesMocks.TOKEN_INFO_APPLICATION.APPROVED),
})); }));
await page.route(tokenInfo.icon_url as string, (route) => {
return route.fulfill({
status: 200,
path: './playwright/image_s.jpg',
});
});
const component = await mount( const component = await mount(
<TestApp withSocket> <TestApp withSocket>
......
...@@ -31,7 +31,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => { ...@@ -31,7 +31,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
return ( return (
<Flex alignItems="flex-start"> <Flex alignItems="flex-start">
<TokenLogo boxSize={ 6 } hash={ data.address } name={ data.name } flexShrink={ 0 } isLoading={ isLoading }/> <TokenLogo boxSize={ 6 } data={ data } flexShrink={ 0 } isLoading={ isLoading }/>
<LinkInternal <LinkInternal
ml={ 2 } ml={ 2 }
href={ route({ pathname: '/token/[hash]', query: { hash: data.address } }) } href={ route({ pathname: '/token/[hash]', query: { hash: data.address } }) }
......
...@@ -27,11 +27,12 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => { ...@@ -27,11 +27,12 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
switch (data.type) { switch (data.type) {
case 'token': { case 'token': {
const name = data.name + (data.symbol ? ` (${ trimTokenSymbol(data.symbol) })` : ''); const name = data.name + (data.symbol ? ` (${ trimTokenSymbol(data.symbol) })` : '');
return ( return (
<> <>
<Td fontSize="sm"> <Td fontSize="sm">
<Flex alignItems="center"> <Flex alignItems="center">
<TokenLogo boxSize={ 6 } hash={ data.address } name={ data.name } flexShrink={ 0 } isLoading={ isLoading }/> <TokenLogo boxSize={ 6 } data={ data } flexShrink={ 0 } isLoading={ isLoading }/>
<LinkInternal <LinkInternal
ml={ 2 } ml={ 2 }
href={ route({ pathname: '/token/[hash]', query: { hash: data.address } }) } href={ route({ pathname: '/token/[hash]', query: { hash: data.address } }) }
......
...@@ -19,6 +19,12 @@ test.beforeEach(async({ page }) => { ...@@ -19,6 +19,12 @@ test.beforeEach(async({ page }) => {
path: './playwright/image_s.jpg', path: './playwright/image_s.jpg',
}); });
}); });
await page.route(searchMock.token1.icon_url as string, (route) => {
return route.fulfill({
status: 200,
path: './playwright/image_s.jpg',
});
});
}); });
test('search by name +@mobile +@dark-mode', async({ mount, page }) => { test('search by name +@mobile +@dark-mode', async({ mount, page }) => {
......
...@@ -47,7 +47,7 @@ const SearchBarSuggestItem = ({ data, isMobile, searchTerm, onClick }: Props) => ...@@ -47,7 +47,7 @@ const SearchBarSuggestItem = ({ data, isMobile, searchTerm, onClick }: Props) =>
return ( return (
<> <>
<TokenLogo boxSize={ 6 } hash={ data.address } name={ data.name } flexShrink={ 0 }/> <TokenLogo boxSize={ 6 } data={ data } flexShrink={ 0 }/>
<Text fontWeight={ 700 } ml={ 2 } w="200px" overflow="hidden" whiteSpace="nowrap" textOverflow="ellipsis" flexShrink={ 0 }> <Text fontWeight={ 700 } ml={ 2 } w="200px" overflow="hidden" whiteSpace="nowrap" textOverflow="ellipsis" flexShrink={ 0 }>
<span dangerouslySetInnerHTML={{ __html: highlightText(name, searchTerm) }}/> <span dangerouslySetInnerHTML={{ __html: highlightText(name, searchTerm) }}/>
</Text> </Text>
......
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