From e16348e2e0b408fb610e68668cdbd1b77b0d3180 Mon Sep 17 00:00:00 2001 From: cartcrom <39385577+cartcrom@users.noreply.github.com> Date: Tue, 10 Oct 2023 18:25:50 -0400 Subject: [PATCH] feat: new chain logos (#7438) * feat: new consolidated chain logos * test: update snapshots * refactor: simplify border radius formula * fix: pass style prop to portofolio logo container * lint * fix: accessibility * fix: pr nits' * fix: unnused styled component --- cypress/e2e/token-explore.test.ts | 2 +- .../wallet-connection/switch-network.test.ts | 2 +- src/assets/images/bnbCircle.svg | 20 - src/assets/images/celoCircle.png | Bin 1517 -> 0 bytes src/assets/images/polygonCircle.png | Bin 3395 -> 0 bytes src/assets/svg/arbitrum_logo.svg | 9 - src/assets/svg/avax_square_logo.svg | 11 - src/assets/svg/base_logo.svg | 11 - src/assets/svg/base_square_logo.svg | 11 - src/assets/svg/bnb_square_logo.svg | 21 - src/assets/svg/celo_square_logo.svg | 5 - src/assets/svg/ethereum_square_logo.svg | 16 - src/assets/svg/optimism_square_logo.svg | 15 - src/assets/svg/optimistic_ethereum.svg | 5 - src/assets/svg/polygon-matic-logo.svg | 1 - src/assets/svg/polygon_square_logo.svg | 1 - .../MiniPortfolio/PortfolioLogo.tsx | 31 +- .../__snapshots__/PortfolioLogo.test.tsx.snap | 42 +- src/components/DoubleLogo/index.tsx | 4 +- src/components/Logo/AssetLogo.tsx | 18 - src/components/Logo/ChainLogo.tsx | 122 ++++ src/components/Logo/ChainSymbols/arbitrum.svg | 9 + src/components/Logo/ChainSymbols/avax.svg | 10 + src/components/Logo/ChainSymbols/base.svg | 3 + src/components/Logo/ChainSymbols/bnb.svg | 3 + src/components/Logo/ChainSymbols/celo.svg | 3 + .../Logo/ChainSymbols/celo_light.svg | 3 + src/components/Logo/ChainSymbols/ethereum.svg | 4 + src/components/Logo/ChainSymbols/optimism.svg | 4 + src/components/Logo/ChainSymbols/polygon.svg | 3 + src/components/Logo/CurrencyLogo.tsx | 1 - src/components/Logo/QueryTokenLogo.tsx | 29 +- src/components/NavBar/ChainSelector.css.ts | 7 - src/components/NavBar/ChainSelector.tsx | 3 +- src/components/NavBar/ChainSelectorRow.tsx | 12 +- src/components/NavBar/SearchBarDropdown.tsx | 11 +- .../ChainSelectorRow.test.tsx.snap | 686 ++++++++++++------ src/components/NetworkAlert/NetworkAlert.tsx | 215 ++---- .../Tokens/TokenDetails/BalanceSummary.tsx | 7 +- src/components/Tokens/TokenDetails/index.tsx | 4 +- .../Tokens/TokenTable/NetworkFilter.tsx | 22 +- src/components/Tokens/TokenTable/TokenRow.tsx | 4 +- .../__snapshots__/TokenRow.test.tsx.snap | 143 ++-- .../TransactionConfirmationModal/index.tsx | 11 +- src/components/swap/ConfirmSwapModal.tsx | 8 +- src/components/swap/SwapLineItem.tsx | 4 +- .../SwapDetailsDropdown.test.tsx.snap | 31 +- .../__snapshots__/SwapLineItem.test.tsx.snap | 186 ++++- .../SwapModalFooter.test.tsx.snap | 31 +- src/constants/chainInfo.ts | 47 -- src/graphql/data/util.tsx | 3 +- src/pages/PoolDetails/PoolDetailsHeader.tsx | 27 +- 52 files changed, 1043 insertions(+), 838 deletions(-) delete mode 100644 src/assets/images/bnbCircle.svg delete mode 100644 src/assets/images/celoCircle.png delete mode 100644 src/assets/images/polygonCircle.png delete mode 100644 src/assets/svg/arbitrum_logo.svg delete mode 100644 src/assets/svg/avax_square_logo.svg delete mode 100644 src/assets/svg/base_logo.svg delete mode 100644 src/assets/svg/base_square_logo.svg delete mode 100644 src/assets/svg/bnb_square_logo.svg delete mode 100644 src/assets/svg/celo_square_logo.svg delete mode 100644 src/assets/svg/ethereum_square_logo.svg delete mode 100644 src/assets/svg/optimism_square_logo.svg delete mode 100644 src/assets/svg/optimistic_ethereum.svg delete mode 100644 src/assets/svg/polygon-matic-logo.svg delete mode 100644 src/assets/svg/polygon_square_logo.svg create mode 100644 src/components/Logo/ChainLogo.tsx create mode 100644 src/components/Logo/ChainSymbols/arbitrum.svg create mode 100644 src/components/Logo/ChainSymbols/avax.svg create mode 100644 src/components/Logo/ChainSymbols/base.svg create mode 100644 src/components/Logo/ChainSymbols/bnb.svg create mode 100644 src/components/Logo/ChainSymbols/celo.svg create mode 100644 src/components/Logo/ChainSymbols/celo_light.svg create mode 100644 src/components/Logo/ChainSymbols/ethereum.svg create mode 100644 src/components/Logo/ChainSymbols/optimism.svg create mode 100644 src/components/Logo/ChainSymbols/polygon.svg diff --git a/cypress/e2e/token-explore.test.ts b/cypress/e2e/token-explore.test.ts index 4a0c9aecbe..036581b549 100644 --- a/cypress/e2e/token-explore.test.ts +++ b/cypress/e2e/token-explore.test.ts @@ -69,6 +69,6 @@ describe('Token explore', () => { cy.get(getTestSelector('tokens-network-filter-selected')).click() cy.get(getTestSelector('tokens-network-filter-option-optimism')).click() cy.get(getTestSelector('tokens-network-filter-selected')).should('contain', 'Optimism') - cy.get(getTestSelector('chain-selector-logo')).invoke('attr', 'alt').should('eq', 'Ethereum') + cy.get(getTestSelector('chain-selector-logo')).find('title').should('include.text', 'Ethereum logo') }) }) diff --git a/cypress/e2e/wallet-connection/switch-network.test.ts b/cypress/e2e/wallet-connection/switch-network.test.ts index f75fcf0dfe..917a719ff8 100644 --- a/cypress/e2e/wallet-connection/switch-network.test.ts +++ b/cypress/e2e/wallet-connection/switch-network.test.ts @@ -2,7 +2,7 @@ import { createDeferredPromise } from '../../../src/test-utils/promise' import { getTestSelector } from '../../utils' function waitsForActiveChain(chain: string) { - cy.get(getTestSelector('chain-selector-logo')).invoke('attr', 'alt').should('eq', chain) + cy.get(getTestSelector('chain-selector-logo')).find('title').should('include.text', `${chain} logo`) } function switchChain(chain: string) { diff --git a/src/assets/images/bnbCircle.svg b/src/assets/images/bnbCircle.svg deleted file mode 100644 index f39dba1be1..0000000000 --- a/src/assets/images/bnbCircle.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - diff --git a/src/assets/images/celoCircle.png b/src/assets/images/celoCircle.png deleted file mode 100644 index 912b8f4f1e37971aa1ae2ede80f34e01d3201335..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1517 zcmVy)(1j>CSekG(vv zU5sZ6?nm)B)5d)ytLbi>Nl8Fwd2A%*Vf7aFb^MCYJ5M4V*5oh7E1pN-vSlTbc!)^& zk_hPM^v_7jy9Pqo?)wTCBQ5c^DfR*^be5tpBNwgxJ!puw#6ZjyYs%zPm*(C24F!v;!abkKlZ`S^O`}nt*-xY(kFB zZVag+0r*Y%84X~=iS2NPy5Ye9K2jz_%5VW$Zpit|Amx+;;|eV2zSLBMx;~$%AG!B+ zxHEH&uDwKHo2;L`wQ{;}YTF^yo!pGV_C`3uLA+RyBidPiH(2NrV!lr?c<~J}&I+50 zR>te!cGo3#t>?OBXzn!`{auLF?}FNT5Oux1qG^INALS*FLdstbY5XEc#;!S08W*eI z0SxwX3#F% zzKZ<&h7a%I1bn6@wO=dA$r#`+bfbH@sQYN)-Q?jS#<&z1Bx~(zK8zOq{MQvOjUQzK ze4M~pQnsuVAA2rfEyaaDdM)k*oqv5KiXF|ZIC4XaywmJ%yh?Gy z0%y1%s6~P&lU>!`+Cu zw7W2q`aV>igH4jH2ppGmSIh&Eun+fWhFi7GdJB?kcG4^!l=cTsBB~CU+MRttlzLBV zL?)Htsj_v#au(0eK%Nnds;Jm1ng)UxJhw%&2Hk4g%r`A(atr*`=fw}fv+&;viVSI9 z;|UZ~uqtyn@c4>qICK}B0yPwjHd=;b)&FJO8OenY554bHU<~T@YN%bmX>&YJLoQy8 zG!Wrf9E_eK?KOI2PX*nDB8^Po7YZ^v!EQEN>*f*h^3J$&DZ7M}uS%zUuaTCePRV#Q zy!;*onLvD&M2fTA5^gOJGggPtt+e6pKTtqd2^zz2)8 z+!A;5!(=29{L`$8-8uLgqx&?outp6V9fG=ICEfZGZWCble?~C0+>7i35IFa+g<{q`dMJ<0>3BULOVk5&qT!b%n?89G ze6kdHHb8e__=-L1)E6`iUa{=8?n8DT^)BaEQ$17T4lJ}r*IG=dY)Hzp+u9NHmC4;%!$ ztmW-Zf)4@8F(BuWr#X)z&0#o27RHoWaH(<^oXXr!ovIw=P~`I^Bl1j!-b^i?8P96&t4ZC&BOV-to16=$X?E^$e@kjIF~A0cPVq=ROMD2 zOkU|=@|1(g3+zmRvN6Ris)-`4jp4$g$fGmDNE5?}qYa`Shu|h93+UW+1tY#a7#J?u zf$LbyVK}@oT;0j!!J*2p+nKxq!P%LDz@{!zR!ylJZjOh;pK}8Owuh4#(9K{t zAnI`rCeJxkc?4Itsf%D!7yo5{wAN?SE+I(DtSwR0>%t2}J#2AcMu_3+Bp5ik2o76& zmzozK!SKsd;8&%X2BuNfK`|Vw>k$d1_5IAI6G6|?CJv8m}1?k zE`n84GFvr8%AzR>%-S-tc&?vVE1nTXIINyH%8|0t3P#6T$q!o_P^PeY_Pq(1dMpQX ze_4UeItOT#&fkRBep3PS{tVb;IdEwU;NY$0Yz$VfY1Nd#qA6`yG^IVGnlfe4l=`T! zDB6$HD~g;Z>NSvh-PYbU7<4BX&Ve{Sdmp>Mfwij**t(jV9L&wGLhzR*7~Y=+o2meI zWGz$Vka`w%sczAfVN_dw#iA`CKtU@cduN1^Itd0hEh5%RI@bPRFl0QOSDJ*k4lTiQ zW}^q{oAd_czgX+}w_B^5@Xx?iaOx0T0c;vBgw0yvwXX7UP;1F?R)n z>kY;q6F!@|0$yznY~l>ezIX|)6mIwY&bgDT zU>wYYU0*`#aYVg_S-S*g?b7pR?Na;pI8SQc=C)w;SQ~>0Ij`Q>z8H80;}BG*z_B+D zADC+RKjkQ$>94Y$ zumDyA0mRl~^%}#vDh%nXPou8cLvDLaOc)$4^;M(?_fE-j=%r) zB^KW50-XIr4J?CcaBK76LU%2b$8~R%&V%cbQX6pL!!fOyih>n48-vY#DulJUX#5&9#TEb^9z@%aBjqC8{a}}6kZfF?cb#DJvcVZfGp81Ugm zD1GrA{$us^CY<$L2A?#6%Zgu_0uP-6r!Wb&fh3$UUTOoLe6|Yj9JvH@Z+{DJLjf#w z9^M^UhU+Y^Tx)&)`YIe16~SU?TZ;jQ^azmU0jI?CZcl-5{wQU z4C|}hkgnP=AwUCr3{7Y+kkmFvmrMZT;6;FEc?DOicOYa)gOBdCQXY94yi5kH1F2rX zXIVI7{$^X48h1E2cj{Yk|DuAGGiyjN+V-Mzhr+=&Oa>N=`r1JRcz^_>$R~vd-m=NS z?w|sSMJgm&{0jGa(%5FO4Vb`yrLS)A_G~oa-0>?AP^ZB@ki=cGi%#R~?A0gBP>FQT z+3bWA?czKoxLEMZ^`%= zlqbOba17@De68mkT`%8;_m0-UAxgo-V|lpn#tLjU_@1xTQoVYxiff)-Q^eb*}&?P@|{`$s*bhO-N%Kq)X=KTUmnhqgGy-gpXa9;pVm8{%+~Q zO<1kaycS=${96H?E>HjR3$-l|bw+lc{#bi99pj#EKt z>;!408l+3+TGJWoR;GTQg^Q=Iw>#wSb*+2{-Z^#|EYci|N^;=PpccN+fm4@wYg_7V zv$m~XoqSFrIHR5wAh7L;YT5fQwf${43@A%b0UE(21%6qQ z^2?J-pFFiruCqE;kAE3JPZxOj#(kbD*M{3>Z7UetYaVI_a5zkQwoYo^iqTLT#Oe`i zdjQc2&`BzQ;Zg!0dJUDQlwNuI8nL$SR%Dv3XA74SJzL~(pVy<_-GagQc^nBw6Ty)i zqh>O&7|vv1??YhQ;JTMjo~C^Al)x)bQyzJGw?~ma-?mnnt-DmYCh3yVvjut?0P-^M zL&4xibhwR2);5Q9)jDpac(}7BJ-Y*+H$8iwNskr$@i#*Bmh6?M1s+A3^5|22ZbimC zrp(^%dRJ*UnEa-L$v3-R1~@$1^5Y{%g24|#+R7&Cl7~Cit{DxrmybPiiNcB1vjU_V z`hHK#gVaNCigdq6m7?6}9a)v#<5K2cajJ4RwgjVTQx_Xnyh{y>rqn>Q?Wkr6&9}`h z&A_Tj&rX^Q>;p)(r*#~H>L=09=ctsEahZ!yBwe)X2=jx9F Z{0CXV!f+Fv49Wli002ovPDHLkV1n0^TkZe= diff --git a/src/assets/svg/arbitrum_logo.svg b/src/assets/svg/arbitrum_logo.svg deleted file mode 100644 index a1cce5c33d..0000000000 --- a/src/assets/svg/arbitrum_logo.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/assets/svg/avax_square_logo.svg b/src/assets/svg/avax_square_logo.svg deleted file mode 100644 index a3827f1c12..0000000000 --- a/src/assets/svg/avax_square_logo.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/assets/svg/base_logo.svg b/src/assets/svg/base_logo.svg deleted file mode 100644 index d0303fb153..0000000000 --- a/src/assets/svg/base_logo.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/assets/svg/base_square_logo.svg b/src/assets/svg/base_square_logo.svg deleted file mode 100644 index 32371c259b..0000000000 --- a/src/assets/svg/base_square_logo.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/assets/svg/bnb_square_logo.svg b/src/assets/svg/bnb_square_logo.svg deleted file mode 100644 index 9e1b2e0ec1..0000000000 --- a/src/assets/svg/bnb_square_logo.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - diff --git a/src/assets/svg/celo_square_logo.svg b/src/assets/svg/celo_square_logo.svg deleted file mode 100644 index 801df12176..0000000000 --- a/src/assets/svg/celo_square_logo.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/src/assets/svg/ethereum_square_logo.svg b/src/assets/svg/ethereum_square_logo.svg deleted file mode 100644 index ea3c75c444..0000000000 --- a/src/assets/svg/ethereum_square_logo.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/assets/svg/optimism_square_logo.svg b/src/assets/svg/optimism_square_logo.svg deleted file mode 100644 index fc61510262..0000000000 --- a/src/assets/svg/optimism_square_logo.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/assets/svg/optimistic_ethereum.svg b/src/assets/svg/optimistic_ethereum.svg deleted file mode 100644 index 2e5ce3103d..0000000000 --- a/src/assets/svg/optimistic_ethereum.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/assets/svg/polygon-matic-logo.svg b/src/assets/svg/polygon-matic-logo.svg deleted file mode 100644 index 6189792a28..0000000000 --- a/src/assets/svg/polygon-matic-logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/svg/polygon_square_logo.svg b/src/assets/svg/polygon_square_logo.svg deleted file mode 100644 index b2e21f5990..0000000000 --- a/src/assets/svg/polygon_square_logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/components/AccountDrawer/MiniPortfolio/PortfolioLogo.tsx b/src/components/AccountDrawer/MiniPortfolio/PortfolioLogo.tsx index 48b391d306..4746de6406 100644 --- a/src/components/AccountDrawer/MiniPortfolio/PortfolioLogo.tsx +++ b/src/components/AccountDrawer/MiniPortfolio/PortfolioLogo.tsx @@ -2,8 +2,8 @@ import { ChainId, Currency } from '@uniswap/sdk-core' import blankTokenUrl from 'assets/svg/blank_token.svg' import { ReactComponent as UnknownStatus } from 'assets/svg/contract-interaction.svg' import { MissingImageLogo } from 'components/Logo/AssetLogo' +import { ChainLogo, getDefaultBorderRadius } from 'components/Logo/ChainLogo' import { Unicon } from 'components/Unicon' -import { getChainInfo } from 'constants/chainInfo' import useTokenLogoSource from 'hooks/useAssetLogoSource' import useENSAvatar from 'hooks/useENSAvatar' import React from 'react' @@ -48,25 +48,14 @@ const ENSAvatarImg = styled.img` width: 40px; ` -const StyledChainLogo = styled.img` - height: 14px; - width: 14px; -` - -const SquareChainLogo = styled.img` - height: 100%; - width: 100%; -` - const CircleLogoImage = styled.img<{ size: string }>` width: ${({ size }) => size}; height: ${({ size }) => size}; border-radius: 50%; ` -const L2LogoContainer = styled.div<{ hasSquareLogo?: boolean }>` - background-color: ${({ theme, hasSquareLogo }) => (hasSquareLogo ? theme.surface2 : theme.neutral1)}; - border-radius: 2px; +const L2LogoContainer = styled.div` + border-radius: ${getDefaultBorderRadius(16)}px; height: 16px; left: 60%; position: absolute; @@ -152,27 +141,21 @@ interface PortfolioLogoProps { function SquareL2Logo({ chainId }: { chainId: ChainId }) { if (chainId === ChainId.MAINNET) return null - const { squareLogoUrl, logoUrl } = getChainInfo(chainId) - - const chainLogo = squareLogoUrl ?? logoUrl return ( - - {squareLogoUrl ? ( - - ) : ( - - )} + + ) } +// TODO(WEB-2983) /** * Renders an image by prioritizing a list of sources, and then eventually a fallback contract icon */ export function PortfolioLogo(props: PortfolioLogoProps) { return ( - + {getLogo(props)} diff --git a/src/components/AccountDrawer/MiniPortfolio/__snapshots__/PortfolioLogo.test.tsx.snap b/src/components/AccountDrawer/MiniPortfolio/__snapshots__/PortfolioLogo.test.tsx.snap index 6eb8b28d14..4f273f7e34 100644 --- a/src/components/AccountDrawer/MiniPortfolio/__snapshots__/PortfolioLogo.test.tsx.snap +++ b/src/components/AccountDrawer/MiniPortfolio/__snapshots__/PortfolioLogo.test.tsx.snap @@ -37,11 +37,6 @@ exports[`PortfolioLogo renders with L2 icon 1`] = ` left: 0; } -.c4 { - height: 14px; - width: 14px; -} - .c2 { width: 40px; height: 40px; @@ -49,8 +44,7 @@ exports[`PortfolioLogo renders with L2 icon 1`] = ` } .c3 { - background-color: #222222; - border-radius: 2px; + border-radius: 4px; height: 16px; left: 60%; position: absolute; @@ -90,11 +84,35 @@ exports[`PortfolioLogo renders with L2 icon 1`] = `
- chainLogo + + + Arbitrum logo + + + + + arbitrum.svg + +
diff --git a/src/components/DoubleLogo/index.tsx b/src/components/DoubleLogo/index.tsx index 73a8ca7cee..6b7ef9dfc8 100644 --- a/src/components/DoubleLogo/index.tsx +++ b/src/components/DoubleLogo/index.tsx @@ -35,12 +35,12 @@ export default function DoubleCurrencyLogo({ {currency0 && ( - + )} {currency1 && ( - + )} diff --git a/src/components/Logo/AssetLogo.tsx b/src/components/Logo/AssetLogo.tsx index cc709fb086..ad8fa1e017 100644 --- a/src/components/Logo/AssetLogo.tsx +++ b/src/components/Logo/AssetLogo.tsx @@ -1,5 +1,4 @@ import { ChainId } from '@uniswap/sdk-core' -import { getChainInfo } from 'constants/chainInfo' import useTokenLogoSource from 'hooks/useAssetLogoSource' import React, { useState } from 'react' import styled from 'styled-components' @@ -42,7 +41,6 @@ export type AssetLogoBaseProps = { backupImg?: string | null size?: string style?: React.CSSProperties - hideL2Icon?: boolean } type AssetLogoProps = AssetLogoBaseProps & { isNative?: boolean; address?: string | null; chainId?: number } @@ -51,19 +49,6 @@ const LogoContainer = styled.div` display: flex; ` -const L2NetworkLogo = styled.div<{ networkUrl?: string; parentSize: string }>` - --size: ${({ parentSize }) => `calc(${parentSize} / 2)`}; - width: var(--size); - height: var(--size); - position: absolute; - left: 50%; - bottom: 0; - background: url(${({ networkUrl }) => networkUrl}); - background-repeat: no-repeat; - background-size: ${({ parentSize }) => `calc(${parentSize} / 2) calc(${parentSize} / 2)`}; - display: ${({ networkUrl }) => !networkUrl && 'none'}; -` - /** * Renders an image by prioritizing a list of sources, and then eventually a fallback triangle alert */ @@ -75,10 +60,8 @@ export default function AssetLogo({ backupImg, size = '24px', style, - hideL2Icon = false, }: AssetLogoProps) { const [src, nextSrc] = useTokenLogoSource(address, chainId, isNative, backupImg) - const L2Icon = getChainInfo(chainId)?.circleLogoUrl const [imgLoaded, setImgLoaded] = useState(() => { const img = document.createElement('img') img.src = src ?? '' @@ -104,7 +87,6 @@ export default function AssetLogo({ {symbol?.toUpperCase().replace('$', '').replace(/\s+/g, '').slice(0, 3)} )} - {!hideL2Icon && } ) } diff --git a/src/components/Logo/ChainLogo.tsx b/src/components/Logo/ChainLogo.tsx new file mode 100644 index 0000000000..b15b135e25 --- /dev/null +++ b/src/components/Logo/ChainLogo.tsx @@ -0,0 +1,122 @@ +import { ChainId } from '@uniswap/sdk-core' +import { getChainInfo } from 'constants/chainInfo' +import { isSupportedChain, SupportedInterfaceChain } from 'constants/chains' +import { CSSProperties, FunctionComponent } from 'react' +import { useTheme } from 'styled-components' +import { useIsDarkMode } from 'theme/components/ThemeToggle' + +import { ReactComponent as arbitrum } from './ChainSymbols/arbitrum.svg' +import { ReactComponent as avax } from './ChainSymbols/avax.svg' +import { ReactComponent as base } from './ChainSymbols/base.svg' +import { ReactComponent as bnb } from './ChainSymbols/bnb.svg' +import { ReactComponent as celo } from './ChainSymbols/celo.svg' +import { ReactComponent as celoLight } from './ChainSymbols/celo_light.svg' +import { ReactComponent as ethereum } from './ChainSymbols/ethereum.svg' +import { ReactComponent as optimism } from './ChainSymbols/optimism.svg' +import { ReactComponent as polygon } from './ChainSymbols/polygon.svg' + +type SVG = FunctionComponent> +type ChainUI = { Symbol: SVG; bgColor: string; textColor: string } + +export function getChainUI(chainId: SupportedInterfaceChain, darkMode: boolean): ChainUI +export function getChainUI(chainId: ChainId, darkMode: boolean): ChainUI | undefined { + switch (chainId) { + case ChainId.MAINNET: + case ChainId.GOERLI: + case ChainId.SEPOLIA: + return { + Symbol: ethereum, + bgColor: '#6B8AFF33', + textColor: '#6B8AFF', + } + case ChainId.POLYGON: + case ChainId.POLYGON_MUMBAI: + return { + Symbol: polygon, + bgColor: '#9558FF33', + textColor: '#9558FF', + } + case ChainId.ARBITRUM_ONE: + case ChainId.ARBITRUM_GOERLI: + return { + Symbol: arbitrum, + bgColor: '#00A3FF33', + textColor: '#00A3FF', + } + case ChainId.OPTIMISM: + case ChainId.OPTIMISM_GOERLI: + return { + Symbol: optimism, + bgColor: '#FF042033', + textColor: '#FF0420', + } + case ChainId.CELO: + case ChainId.CELO_ALFAJORES: + return darkMode + ? { + Symbol: celo, + bgColor: '#FCFF5233', + textColor: '#FCFF52', + } + : { + Symbol: celoLight, + bgColor: '#FCFF5299', + textColor: '#655947', + } + case ChainId.AVALANCHE: + return { + Symbol: avax, + bgColor: '#E8414233', + textColor: '#E84142', + } + case ChainId.BNB: + return { + Symbol: bnb, + bgColor: '#EAB20033', + textColor: '#EAB200', + } + case ChainId.BASE: + return { + Symbol: base, + bgColor: '#0052FF33', + textColor: '#0052FF', + } + default: + return undefined + } +} + +export const getDefaultBorderRadius = (size: number) => size / 2 - 4 + +type ChainLogoProps = { + chainId: ChainId + className?: string + size?: number + borderRadius?: number + style?: CSSProperties + testId?: string +} +export function ChainLogo({ + chainId, + className, + style, + size = 16, + borderRadius = getDefaultBorderRadius(size), + testId, +}: ChainLogoProps) { + const darkMode = useIsDarkMode() + const { surface2 } = useTheme() + + if (!isSupportedChain(chainId)) return null + const { label } = getChainInfo(chainId) + + const { Symbol, bgColor } = getChainUI(chainId, darkMode) + return ( + + {`${label} logo`} + + + + + ) +} diff --git a/src/components/Logo/ChainSymbols/arbitrum.svg b/src/components/Logo/ChainSymbols/arbitrum.svg new file mode 100644 index 0000000000..ebcbdd5cd8 --- /dev/null +++ b/src/components/Logo/ChainSymbols/arbitrum.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/components/Logo/ChainSymbols/avax.svg b/src/components/Logo/ChainSymbols/avax.svg new file mode 100644 index 0000000000..ee1f505f05 --- /dev/null +++ b/src/components/Logo/ChainSymbols/avax.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/components/Logo/ChainSymbols/base.svg b/src/components/Logo/ChainSymbols/base.svg new file mode 100644 index 0000000000..39a6229dd2 --- /dev/null +++ b/src/components/Logo/ChainSymbols/base.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/Logo/ChainSymbols/bnb.svg b/src/components/Logo/ChainSymbols/bnb.svg new file mode 100644 index 0000000000..9c04309fc4 --- /dev/null +++ b/src/components/Logo/ChainSymbols/bnb.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/Logo/ChainSymbols/celo.svg b/src/components/Logo/ChainSymbols/celo.svg new file mode 100644 index 0000000000..48bffb342a --- /dev/null +++ b/src/components/Logo/ChainSymbols/celo.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/Logo/ChainSymbols/celo_light.svg b/src/components/Logo/ChainSymbols/celo_light.svg new file mode 100644 index 0000000000..3a99877f96 --- /dev/null +++ b/src/components/Logo/ChainSymbols/celo_light.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/Logo/ChainSymbols/ethereum.svg b/src/components/Logo/ChainSymbols/ethereum.svg new file mode 100644 index 0000000000..15053e9206 --- /dev/null +++ b/src/components/Logo/ChainSymbols/ethereum.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/components/Logo/ChainSymbols/optimism.svg b/src/components/Logo/ChainSymbols/optimism.svg new file mode 100644 index 0000000000..83b6d2abc8 --- /dev/null +++ b/src/components/Logo/ChainSymbols/optimism.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/components/Logo/ChainSymbols/polygon.svg b/src/components/Logo/ChainSymbols/polygon.svg new file mode 100644 index 0000000000..074d2d6171 --- /dev/null +++ b/src/components/Logo/ChainSymbols/polygon.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/Logo/CurrencyLogo.tsx b/src/components/Logo/CurrencyLogo.tsx index 0fccd6a998..08a7078ab4 100644 --- a/src/components/Logo/CurrencyLogo.tsx +++ b/src/components/Logo/CurrencyLogo.tsx @@ -15,7 +15,6 @@ export default function CurrencyLogo( address={props.currency?.wrapped.address} symbol={props.symbol ?? props.currency?.symbol} backupImg={(props.currency as TokenInfo)?.logoURI} - hideL2Icon={props.hideL2Icon ?? true} {...props} /> ) diff --git a/src/components/Logo/QueryTokenLogo.tsx b/src/components/Logo/QueryTokenLogo.tsx index b969e19b91..386cc97c13 100644 --- a/src/components/Logo/QueryTokenLogo.tsx +++ b/src/components/Logo/QueryTokenLogo.tsx @@ -1,32 +1,21 @@ -import { NATIVE_CHAIN_ID } from 'constants/tokens' -import { TokenStandard } from 'graphql/data/__generated__/types-and-hooks' +import { ChainId } from '@uniswap/sdk-core' +import { PortfolioLogo } from 'components/AccountDrawer/MiniPortfolio/PortfolioLogo' import { SearchToken } from 'graphql/data/SearchTokens' import { TokenQueryData } from 'graphql/data/Token' import { TopToken } from 'graphql/data/TopTokens' -import { supportedChainIdFromGQLChain } from 'graphql/data/util' +import { gqlToCurrency, supportedChainIdFromGQLChain } from 'graphql/data/util' +import { useMemo } from 'react' -import AssetLogo, { AssetLogoBaseProps } from './AssetLogo' +import { AssetLogoBaseProps } from './AssetLogo' export default function QueryTokenLogo( props: AssetLogoBaseProps & { token?: TopToken | TokenQueryData | SearchToken } ) { - const chainId = props.token?.chain ? supportedChainIdFromGQLChain(props.token?.chain) : undefined + const chainId = + (props.token?.chain ? supportedChainIdFromGQLChain(props.token?.chain) : ChainId.MAINNET) ?? ChainId.MAINNET + const currency = props.token ? gqlToCurrency(props.token) : undefined - return ( - - ) + return [currency], [currency])} chainId={chainId} {...props} /> } diff --git a/src/components/NavBar/ChainSelector.css.ts b/src/components/NavBar/ChainSelector.css.ts index 0c887ead60..eed1b6c46a 100644 --- a/src/components/NavBar/ChainSelector.css.ts +++ b/src/components/NavBar/ChainSelector.css.ts @@ -14,10 +14,3 @@ export const ChainSelector = style([ background: 'none', }), ]) - -export const Image = style([ - sprinkles({ - width: '24', - height: '24', - }), -]) diff --git a/src/components/NavBar/ChainSelector.tsx b/src/components/NavBar/ChainSelector.tsx index eb38b64245..59b9c9963c 100644 --- a/src/components/NavBar/ChainSelector.tsx +++ b/src/components/NavBar/ChainSelector.tsx @@ -2,6 +2,7 @@ import { t } from '@lingui/macro' import { ChainId } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' import { showTestnetsAtom } from 'components/AccountDrawer/TestnetsToggle' +import { ChainLogo } from 'components/Logo/ChainLogo' import { MouseoverTooltip } from 'components/Tooltip' import { getConnection } from 'connection' import { ConnectionType } from 'connection/types' @@ -145,7 +146,7 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { {!isSupported ? ( ) : ( - {info.label} + )} {isOpen ? : } diff --git a/src/components/NavBar/ChainSelectorRow.tsx b/src/components/NavBar/ChainSelectorRow.tsx index 2b14f3004a..4adf3b59e8 100644 --- a/src/components/NavBar/ChainSelectorRow.tsx +++ b/src/components/NavBar/ChainSelectorRow.tsx @@ -4,6 +4,7 @@ import { ChainId } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' import { TraceEvent } from 'analytics' import Loader from 'components/Icons/LoadingSpinner' +import { ChainLogo } from 'components/Logo/ChainLogo' import { getChainInfo } from 'constants/chainInfo' import { CheckMarkIcon } from 'nft/components/icons' import styled, { useTheme } from 'styled-components' @@ -36,14 +37,12 @@ const Container = styled.button<{ disabled: boolean }>` background-color: ${({ disabled, theme }) => (disabled ? 'none' : theme.surface3)}; } ` - const Label = styled.div` grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; ` - const Status = styled.div` grid-column: 3; grid-row: 1; @@ -51,7 +50,6 @@ const Status = styled.div` align-items: center; width: ${LOGO_SIZE}px; ` - const CaptionText = styled.div` color: ${({ theme }) => theme.neutral2}; font-size: 12px; @@ -59,11 +57,6 @@ const CaptionText = styled.div` grid-row: 2; ` -const Logo = styled.img` - height: ${LOGO_SIZE}px; - width: ${LOGO_SIZE}px; - margin-right: 12px; -` interface ChainSelectorRowProps { disabled?: boolean targetChain: ChainId @@ -75,7 +68,6 @@ export default function ChainSelectorRow({ disabled, targetChain, onSelectChain, const active = chainId === targetChain const chainInfo = getChainInfo(targetChain) const label = chainInfo?.label - const logoUrl = chainInfo?.logoUrl const theme = useTheme() @@ -88,7 +80,7 @@ export default function ChainSelectorRow({ disabled, targetChain, onSelectChain, if (!disabled) onSelectChain(targetChain) }} > - {logoUrl && } + {label && } {disabled && ( diff --git a/src/components/NavBar/SearchBarDropdown.tsx b/src/components/NavBar/SearchBarDropdown.tsx index 4ff6f9e52a..62e4437771 100644 --- a/src/components/NavBar/SearchBarDropdown.tsx +++ b/src/components/NavBar/SearchBarDropdown.tsx @@ -5,7 +5,7 @@ import { useWeb3React } from '@web3-react/core' import { useTrace } from 'analytics' import clsx from 'clsx' import Badge from 'components/Badge' -import { getChainInfo } from 'constants/chainInfo' +import { ChainLogo } from 'components/Logo/ChainLogo' import { HistoryDuration, SafetyLevel } from 'graphql/data/__generated__/types-and-hooks' import { useTrendingCollections } from 'graphql/data/nft/TrendingCollections' import { SearchToken } from 'graphql/data/SearchTokens' @@ -107,11 +107,6 @@ function isKnownToken(token: SearchToken) { return token.project?.safetyLevel == SafetyLevel.Verified || token.project?.safetyLevel == SafetyLevel.MediumWarning } -const ChainLogo = styled.img` - height: 20px; - width: 20px; - margin-right: 8px; -` const ChainComingSoonBadge = styled(Badge)` align-items: center; background-color: ${({ theme }) => theme.surface2}; @@ -123,6 +118,7 @@ const ChainComingSoonBadge = styled(Badge)` padding: 8px; margin: 16px 16px 4px; width: calc(100% - 32px); + gap: 8px; ` interface SearchBarDropdownProps { @@ -138,7 +134,6 @@ export const SearchBarDropdown = (props: SearchBarDropdownProps) => { const { isLoading } = props const { chainId } = useWeb3React() const showChainComingSoonBadge = chainId && BACKEND_NOT_YET_SUPPORTED_CHAIN_IDS.includes(chainId) && !isLoading - const logoUri = getChainInfo(chainId)?.logoUrl return ( @@ -150,7 +145,7 @@ export const SearchBarDropdown = (props: SearchBarDropdownProps) => { {showChainComingSoonBadge && ( - + diff --git a/src/components/NavBar/__snapshots__/ChainSelectorRow.test.tsx.snap b/src/components/NavBar/__snapshots__/ChainSelectorRow.test.tsx.snap index df639228f6..c535254596 100644 --- a/src/components/NavBar/__snapshots__/ChainSelectorRow.test.tsx.snap +++ b/src/components/NavBar/__snapshots__/ChainSelectorRow.test.tsx.snap @@ -30,14 +30,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 1 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -51,12 +51,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 1 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -68,18 +62,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 1 1`] = ` class="c0" data-testid="Ethereum-selector" > - Ethereum + + + Ethereum logo + + + + + ethereum.svg + +
Ethereum
- Görli + + + Görli logo + + + + + ethereum.svg + +
Görli
@@ -216,14 +254,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 10 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -237,12 +275,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 10 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -254,18 +286,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 10 1`] = ` class="c0" data-testid="Optimism-selector" > - Optimism + + + Optimism logo + + + + + optimism.svg + +
Optimism
@@ -301,14 +358,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 56 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -322,12 +379,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 56 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -339,18 +390,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 56 1`] = ` class="c0" data-testid="BNB Chain-selector" > - BNB Chain + + + BNB Chain logo + + + + + bnb.svg + +
BNB Chain
@@ -386,14 +462,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 137 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -407,12 +483,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 137 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -424,18 +494,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 137 1`] = ` class="c0" data-testid="Polygon-selector" > - Polygon + + + Polygon logo + + + + + polygon.svg + +
Polygon
@@ -471,14 +566,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 420 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -492,12 +587,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 420 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -509,18 +598,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 420 1`] = ` class="c0" data-testid="Optimism Görli-selector" > - Optimism Görli + + + Optimism Görli logo + + + + + optimism.svg + +
Optimism Görli
@@ -556,14 +670,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 8453 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -577,12 +691,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 8453 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -594,18 +702,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 8453 1`] = ` class="c0" data-testid="Base-selector" > - Base + + + Base logo + + + + + base.svg + +
Base
@@ -641,14 +774,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 42161 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -662,12 +795,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 42161 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -679,18 +806,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 42161 1`] = ` class="c0" data-testid="Arbitrum-selector" > - Arbitrum + + + Arbitrum logo + + + + + arbitrum.svg + +
Arbitrum
@@ -726,14 +878,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 42220 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -747,12 +899,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 42220 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -764,18 +910,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 42220 1`] = ` class="c0" data-testid="Celo-selector" > - Celo + + + Celo logo + + + + + celo_light.svg + +
Celo
@@ -811,14 +982,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 43114 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -832,12 +1003,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 43114 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -849,18 +1014,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 43114 1`] = ` class="c0" data-testid="Avalanche-selector" > - Avalanche + + + Avalanche logo + + + + + avax.svg + +
Avalanche
@@ -896,14 +1086,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 44787 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -917,12 +1107,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 44787 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -934,18 +1118,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 44787 1`] = ` class="c0" data-testid="Celo Alfajores-selector" > - Celo Alfajores + + + Celo Alfajores logo + + + + + celo_light.svg + +
Celo Alfajores
@@ -981,14 +1190,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 80001 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -1002,12 +1211,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 80001 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -1019,18 +1222,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 80001 1`] = ` class="c0" data-testid="Polygon Mumbai-selector" > - Polygon Mumbai + + + Polygon Mumbai logo + + + + + polygon.svg + +
Polygon Mumbai
@@ -1128,14 +1356,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 421613 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -1149,12 +1377,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 421613 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -1166,18 +1388,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 421613 1`] = ` class="c0" data-testid="Arbitrum Goerli-selector" > - Arbitrum Goerli + + + Arbitrum Goerli logo + + + + + arbitrum.svg + +
Arbitrum Goerli
@@ -1213,14 +1460,14 @@ exports[`ChainSelectorRow should match snapshot for chainId 11155111 1`] = ` background-color: #22222212; } -.c2 { +.c1 { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 485; } -.c3 { +.c2 { grid-column: 3; grid-row: 1; display: -webkit-box; @@ -1234,12 +1481,6 @@ exports[`ChainSelectorRow should match snapshot for chainId 11155111 1`] = ` width: 20px; } -.c1 { - height: 20px; - width: 20px; - margin-right: 12px; -} - @media only screen and (max-width:640px) { .c0 { width: 100%; @@ -1251,18 +1492,43 @@ exports[`ChainSelectorRow should match snapshot for chainId 11155111 1`] = ` class="c0" data-testid="Sepolia-selector" > - Sepolia + + + Sepolia logo + + + + + ethereum.svg + +
Sepolia
diff --git a/src/components/NetworkAlert/NetworkAlert.tsx b/src/components/NetworkAlert/NetworkAlert.tsx index e2a7cfe931..dca61014a4 100644 --- a/src/components/NetworkAlert/NetworkAlert.tsx +++ b/src/components/NetworkAlert/NetworkAlert.tsx @@ -1,200 +1,75 @@ import { Trans } from '@lingui/macro' -import { ChainId } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' +import { getChainUI } from 'components/Logo/ChainLogo' +import { RowBetween } from 'components/Row' import { getChainInfo } from 'constants/chainInfo' +import { isSupportedChain } from 'constants/chains' import { ArrowUpRight } from 'react-feather' import styled from 'styled-components' -import { colors } from 'theme/colors' -import { ExternalLink, HideSmall } from 'theme/components' -import { useDarkModeManager } from 'theme/components/ThemeToggle' +import { ExternalLink, HideSmall, ThemedText } from 'theme/components' +import { useIsDarkMode } from 'theme/components/ThemeToggle' import Column from '../Column' -const L2Icon = styled.img` - width: 24px; - height: 24px; - margin-right: 16px; -` - -const BodyText = styled.div` +const BridgeLink = styled(ExternalLink)<{ bgColor: string }>` color: ${({ color }) => color}; - display: flex; - align-items: center; - justify-content: flex-start; - margin: 8px; - font-size: 14px; - line-height: 20px; -` -const RootWrapper = styled.div` - margin-top: 16px; -` - -const SHOULD_SHOW_ALERT = { - [ChainId.OPTIMISM]: true, - [ChainId.OPTIMISM_GOERLI]: true, - [ChainId.ARBITRUM_ONE]: true, - [ChainId.ARBITRUM_GOERLI]: true, - [ChainId.POLYGON]: true, - [ChainId.POLYGON_MUMBAI]: true, - [ChainId.CELO]: true, - [ChainId.CELO_ALFAJORES]: true, - [ChainId.BNB]: true, - [ChainId.AVALANCHE]: true, - [ChainId.BASE]: true, -} - -type NetworkAlertChains = keyof typeof SHOULD_SHOW_ALERT - -const BG_COLORS_BY_DARK_MODE_AND_CHAIN_ID: { - [darkMode in 'dark' | 'light']: { [chainId in NetworkAlertChains]: string } -} = { - dark: { - [ChainId.POLYGON]: - 'radial-gradient(100% 93.36% at 0% 6.64%, rgba(160, 108, 247, 0.1) 0%, rgba(82, 32, 166, 0.1) 100%)', - [ChainId.POLYGON_MUMBAI]: - 'radial-gradient(100% 93.36% at 0% 6.64%, rgba(160, 108, 247, 0.1) 0%, rgba(82, 32, 166, 0.1) 100%)', - [ChainId.CELO]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)', - [ChainId.CELO_ALFAJORES]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)', - [ChainId.BNB]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(240, 185, 11, 0.16) 0%, rgba(255, 168, 0, 0.16) 100%)', - [ChainId.OPTIMISM]: - 'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.01) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.01) 0%, rgba(235, 0, 255, 0.01) 96%)', - [ChainId.OPTIMISM_GOERLI]: - 'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.04) 0%, rgba(235, 0, 255, 0.01 96%)', - [ChainId.ARBITRUM_ONE]: - 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.01) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(75% 75% at 0% 0%, rgba(150, 190, 220, 0.05) 0%, rgba(33, 114, 229, 0.05) 100%), hsla(0, 0%, 100%, 0.05)', - [ChainId.ARBITRUM_GOERLI]: - 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.05) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(75% 75% at 0% 0%, rgba(150, 190, 220, 0.05) 0%, rgba(33, 114, 229, 0.1) 100%), hsla(0, 0%, 100%, 0.05)', - [ChainId.AVALANCHE]: - 'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.01) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.01) 0%, rgba(235, 0, 255, 0.01) 96%)', - [ChainId.BASE]: - 'radial-gradient(100% 100% at 50% 0%, rgba(10, 41, 75, 0.7) 0%, rgba(0, 82, 255, .1) 40%, rgba(0, 82, 255, 0) 100%), rgb(13, 14, 14);', - }, - light: { - [ChainId.POLYGON]: - 'radial-gradient(182.71% 205.59% at 2.81% 7.69%, rgba(130, 71, 229, 0.2) 0%, rgba(167, 202, 255, 0.2) 100%)', - [ChainId.POLYGON_MUMBAI]: - 'radial-gradient(182.71% 205.59% at 2.81% 7.69%, rgba(130, 71, 229, 0.2) 0%, rgba(167, 202, 255, 0.2) 100%)', - [ChainId.CELO]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)', - [ChainId.CELO_ALFAJORES]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)', - [ChainId.BNB]: - 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(240, 185, 11, 0.16) 0%, rgba(255, 168, 0, 0.16) 100%)', - [ChainId.OPTIMISM]: - 'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)', - [ChainId.OPTIMISM_GOERLI]: - 'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)', - [ChainId.ARBITRUM_ONE]: - 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.1) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(circle at top left, hsla(206, 50%, 75%, 0.01), hsla(215, 79%, 51%, 0.12)), hsla(0, 0%, 100%, 0.1)', - [ChainId.ARBITRUM_GOERLI]: - 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.1) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(circle at top left, hsla(206, 50%, 75%, 0.01), hsla(215, 79%, 51%, 0.12)), hsla(0, 0%, 100%, 0.1)', - [ChainId.AVALANCHE]: - 'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)', - [ChainId.BASE]: - 'radial-gradient(100% 100% at 50% 0%, rgba(0, 82, 255, 0.20) 0%, rgba(0, 82, 255, 0.08) 40.0%, rgba(252, 255, 82, 0.00) 100%), rgb(255, 255, 255)', - }, -} - -const ContentWrapper = styled.div<{ chainId: NetworkAlertChains; darkMode: boolean; logoUrl: string }>` - background: ${({ chainId, darkMode }) => BG_COLORS_BY_DARK_MODE_AND_CHAIN_ID[darkMode ? 'dark' : 'light'][chainId]}; - border-radius: 20px; - display: flex; - flex-direction: row; - overflow: hidden; - position: relative; - width: 100%; - - :before { - background-image: url(${({ logoUrl }) => logoUrl}); - background-repeat: no-repeat; - background-size: 300px; - content: ''; - height: 300px; - opacity: 0.1; - position: absolute; - transform: rotate(25deg) translate(-90px, -40px); - width: 300px; - pointer-events: none; - } -` -const Header = styled.h2` - font-weight: 535; - font-size: 16px; - margin: 0; -` - -const LinkOutToBridge = styled(ExternalLink)` + background: ${({ bgColor }) => bgColor}; align-items: center; border-radius: 8px; color: white; display: flex; font-size: 16px; justify-content: space-between; - padding: 6px 8px; + padding: 12px 18px 12px 12px; text-decoration: none !important; width: 100%; + + border-radius: 20px; + display: flex; + flex-direction: row; + gap: 12px; + overflow: hidden; + position: relative; + width: 100%; + + margin-top: 16px; ` -const StyledArrowUpRight = styled(ArrowUpRight)` - margin-left: 12px; - width: 24px; - height: 24px; +const TitleText = styled(ThemedText.BodyPrimary)<{ $color: string }>` + font-weight: 535; + color: ${({ $color }) => $color}; ` -const TEXT_COLORS: { [chainId in NetworkAlertChains]: string } = { - [ChainId.POLYGON]: 'rgba(130, 71, 229)', - [ChainId.POLYGON_MUMBAI]: 'rgba(130, 71, 229)', - [ChainId.CELO]: 'rgba(53, 178, 97)', - [ChainId.CELO_ALFAJORES]: 'rgba(53, 178, 97)', - [ChainId.OPTIMISM]: '#ff3856', - [ChainId.OPTIMISM_GOERLI]: '#ff3856', - [ChainId.ARBITRUM_ONE]: '#0490ed', - [ChainId.BNB]: colors.gold400, - [ChainId.ARBITRUM_GOERLI]: '#0490ed', - [ChainId.AVALANCHE]: '#ff3856', - [ChainId.BASE]: colors.networkBase, -} - -function shouldShowAlert(chainId: number | undefined): chainId is NetworkAlertChains { - return Boolean(chainId && SHOULD_SHOW_ALERT[chainId as unknown as NetworkAlertChains]) -} +const SubtitleText = styled(ThemedText.BodySmall)<{ $color: string }>` + line-height: 20px; + color: ${({ $color }) => $color}; +` export function NetworkAlert() { const { chainId } = useWeb3React() - const [darkMode] = useDarkModeManager() + const darkMode = useIsDarkMode() - if (!shouldShowAlert(chainId)) { - return null - } + if (!chainId || !isSupportedChain(chainId)) return null - const chainInfo = getChainInfo(chainId) - - if (!chainInfo) return null - - const { label, logoUrl, bridge } = chainInfo - const textColor = TEXT_COLORS[chainId] + const { Symbol: ChainSymbol, bgColor, textColor } = getChainUI(chainId, darkMode) + const { label, bridge } = getChainInfo(chainId) return bridge ? ( - - - - - - -
- {label} token bridge -
- - Deposit tokens to the {label} network. - -
-
- -
-
-
+ + + + + + {label} token bridge + + + + Deposit tokens to the {label} network. + + + + + + ) : null } diff --git a/src/components/Tokens/TokenDetails/BalanceSummary.tsx b/src/components/Tokens/TokenDetails/BalanceSummary.tsx index 649427aa58..55895773c7 100644 --- a/src/components/Tokens/TokenDetails/BalanceSummary.tsx +++ b/src/components/Tokens/TokenDetails/BalanceSummary.tsx @@ -1,11 +1,12 @@ import { Trans } from '@lingui/macro' import { ChainId, Currency } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' -import CurrencyLogo from 'components/Logo/CurrencyLogo' +import { PortfolioLogo } from 'components/AccountDrawer/MiniPortfolio/PortfolioLogo' import { getChainInfo } from 'constants/chainInfo' import { asSupportedChain } from 'constants/chains' import { useStablecoinValue } from 'hooks/useStablecoinPrice' import useCurrencyBalance from 'lib/hooks/useCurrencyBalance' +import { useMemo } from 'react' import styled, { useTheme } from 'styled-components' import { ThemedText } from 'theme/components' import { NumberType, useFormatter } from 'utils/formatNumbers' @@ -75,6 +76,8 @@ export default function BalanceSummary({ token }: { token: Currency }) { type: NumberType.FiatTokenStats, }) + const currencies = useMemo(() => [token], [token]) + if (!account || !balance) { return null } @@ -85,7 +88,7 @@ export default function BalanceSummary({ token }: { token: Currency }) { Your balance on {label} - + diff --git a/src/components/Tokens/TokenDetails/index.tsx b/src/components/Tokens/TokenDetails/index.tsx index c5b73daf7d..11c8dd983c 100644 --- a/src/components/Tokens/TokenDetails/index.tsx +++ b/src/components/Tokens/TokenDetails/index.tsx @@ -2,7 +2,7 @@ import { Trans } from '@lingui/macro' import { InterfacePageName } from '@uniswap/analytics-events' import { useWeb3React } from '@web3-react/core' import { Trace } from 'analytics' -import CurrencyLogo from 'components/Logo/CurrencyLogo' +import { PortfolioLogo } from 'components/AccountDrawer/MiniPortfolio/PortfolioLogo' import { AboutSection } from 'components/Tokens/TokenDetails/About' import AddressSection from 'components/Tokens/TokenDetails/AddressSection' import BalanceSummary from 'components/Tokens/TokenDetails/BalanceSummary' @@ -212,7 +212,7 @@ export default function TokenDetails({ - + {detailedToken.name ?? Name not found} {detailedToken.symbol ?? Symbol not found} diff --git a/src/components/Tokens/TokenTable/NetworkFilter.tsx b/src/components/Tokens/TokenTable/NetworkFilter.tsx index 502f2f9c93..3a9b39adf5 100644 --- a/src/components/Tokens/TokenTable/NetworkFilter.tsx +++ b/src/components/Tokens/TokenTable/NetworkFilter.tsx @@ -1,4 +1,5 @@ import Badge from 'components/Badge' +import { ChainLogo } from 'components/Logo/ChainLogo' import { getChainInfo } from 'constants/chainInfo' import { BACKEND_NOT_YET_SUPPORTED_CHAIN_IDS, @@ -91,10 +92,6 @@ const NetworkLabel = styled.div` gap: 8px; align-items: center; ` -const Logo = styled.img` - height: 20px; - width: 20px; -` const CheckContainer = styled.div` display: flex; flex-direction: flex-end; @@ -118,10 +115,10 @@ export default function NetworkFilter() { useOnClickOutside(node, open ? toggleMenu : undefined) const navigate = useNavigate() - const { chainName } = useParams<{ chainName?: string }>() - const currentChainName = validateUrlChainParam(chainName) + const currentChainName = validateUrlChainParam(useParams().chainName) + const chainId = supportedChainIdFromGQLChain(currentChainName) - const chainInfo = getChainInfo(supportedChainIdFromGQLChain(currentChainName)) + const chainInfo = getChainInfo(chainId) return ( @@ -133,7 +130,7 @@ export default function NetworkFilter() { > - {chainInfo.label} + {chainInfo.label} {open ? ( @@ -147,7 +144,8 @@ export default function NetworkFilter() { {open && ( {BACKEND_SUPPORTED_CHAINS.map((network) => { - const chainInfo = getChainInfo(supportedChainIdFromGQLChain(network)) + const chainId = supportedChainIdFromGQLChain(network) + const chainInfo = getChainInfo(chainId) return ( - - {chainInfo.label} + {chainInfo.label} {network === currentChainName && ( @@ -178,8 +175,7 @@ export default function NetworkFilter() { disabled > - - {chainInfo.label} + {chainInfo.label} Coming soon diff --git a/src/components/Tokens/TokenTable/TokenRow.tsx b/src/components/Tokens/TokenTable/TokenRow.tsx index 88706f1dec..0f5c9a1839 100644 --- a/src/components/Tokens/TokenTable/TokenRow.tsx +++ b/src/components/Tokens/TokenTable/TokenRow.tsx @@ -113,7 +113,7 @@ const ClickableContent = styled.div<{ gap?: number }>` cursor: pointer; ` const ClickableName = styled(ClickableContent)` - gap: 8px; + gap: 12px; max-width: 100%; ` const StyledHeaderRow = styled(StyledTokenRow)` @@ -480,7 +480,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef - + {token.name} {token.symbol} diff --git a/src/components/Tokens/TokenTable/__snapshots__/TokenRow.test.tsx.snap b/src/components/Tokens/TokenTable/__snapshots__/TokenRow.test.tsx.snap index c739db76a4..9f6bf95244 100644 --- a/src/components/Tokens/TokenTable/__snapshots__/TokenRow.test.tsx.snap +++ b/src/components/Tokens/TokenTable/__snapshots__/TokenRow.test.tsx.snap @@ -2,51 +2,23 @@ exports[`LoadedRow.tsx renders a row 1`] = ` - .c9 { - opacity: 0; - -webkit-transition: opacity 250ms ease-in; - transition: opacity 250ms ease-in; - width: 24px; - height: 24px; - border-radius: 50%; + .c7 { + position: relative; + top: 0; + left: 0; } .c8 { - width: 24px; - height: 24px; - background: #22222212; - -webkit-transition: background-color 250ms ease-in; - transition: background-color 250ms ease-in; - box-shadow: 0 0 1px white; + width: 32px; + height: 32px; border-radius: 50%; } -.c7 { - position: relative; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; -} - -.c10 { - --size: calc(24px / 2); - width: var(--size); - height: var(--size); - position: absolute; - left: 50%; - bottom: 0; - background: url(); - background-repeat: no-repeat; - background-size: calc(24px / 2) calc(24px / 2); - display: none; -} - -.c18 { +.c16 { color: #40B66B; } -.c19 { +.c17 { color: #40B66B; } @@ -105,7 +77,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` cursor: pointer; } -.c21 { +.c19 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -122,7 +94,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` } .c6 { - gap: 8px; + gap: 12px; max-width: 100%; } @@ -132,7 +104,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` font-size: 14px; } -.c14 { +.c12 { -webkit-box-pack: end; -webkit-justify-content: flex-end; -ms-flex-pack: end; @@ -146,7 +118,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` transition: background-color 250ms ease; } -.c22 { +.c20 { padding-right: 8px; } @@ -160,19 +132,19 @@ exports[`LoadedRow.tsx renders a row 1`] = ` gap: 8px; } +.c13 { + padding-right: 8px; +} + +.c18 { + padding-right: 8px; +} + .c15 { - padding-right: 8px; -} - -.c20 { - padding-right: 8px; -} - -.c17 { display: none; } -.c16 { +.c14 { -webkit-box-pack: end; -webkit-justify-content: flex-end; -ms-flex-pack: end; @@ -182,12 +154,12 @@ exports[`LoadedRow.tsx renders a row 1`] = ` flex: 1; } -.c24 { +.c22 { padding: 0px 24px; min-width: 120px; } -.c25 { +.c23 { width: 124px; height: 42px; } @@ -197,7 +169,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` text-decoration: none; } -.c11 { +.c9 { gap: 8px; line-height: 24px; font-size: 16px; @@ -207,19 +179,19 @@ exports[`LoadedRow.tsx renders a row 1`] = ` white-space: nowrap; } -.c12 { +.c10 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; } -.c13 { +.c11 { color: #7D7D7D; text-transform: uppercase; } -.c23 { +.c21 { padding-right: 8px; } @@ -260,7 +232,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` } @media only screen and (max-width:720px) { - .c22 { + .c20 { display: none; } } @@ -272,13 +244,13 @@ exports[`LoadedRow.tsx renders a row 1`] = ` } @media only screen and (max-width:540px) { - .c20 { + .c18 { display: none; } } @media only screen and (max-width:540px) { - .c17 { + .c15 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -295,7 +267,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` } @media only screen and (max-width:540px) { - .c16 { + .c14 { -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; @@ -307,13 +279,13 @@ exports[`LoadedRow.tsx renders a row 1`] = ` } @media only screen and (max-width:1200px) { - .c24 { + .c22 { display: none; } } @media only screen and (max-width:540px) { - .c11 { + .c9 { -webkit-box-pack: start; -webkit-justify-content: flex-start; -ms-flex-pack: start; @@ -330,7 +302,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` } @media only screen and (max-width:540px) { - .c13 { + .c11 { font-size: 12px; height: 16px; -webkit-box-pack: start; @@ -342,7 +314,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` } @media only screen and (max-width:840px) { - .c23 { + .c21 { display: none; } } @@ -371,32 +343,23 @@ exports[`LoadedRow.tsx renders a row 1`] = ` >
-
- USDC logo -
-
USD Coin
USDC
@@ -404,22 +367,22 @@ exports[`LoadedRow.tsx renders a row 1`] = `
$1.00
0.00% @@ -441,15 +404,15 @@ exports[`LoadedRow.tsx renders a row 1`] = `
0.00%
` padding: ${({ inline }) => (inline ? '20px 0' : '32px 0;')}; ` -const StyledLogo = styled.img` - height: 16px; - width: 16px; - margin-left: 6px; -` - const ConfirmationModalContentWrapper = styled(AutoColumn)` padding-bottom: 12px; ` @@ -231,8 +226,8 @@ function L2Content({ {!inline && ( - - + + {info.label} diff --git a/src/components/swap/ConfirmSwapModal.tsx b/src/components/swap/ConfirmSwapModal.tsx index d8ab028cbf..98796538d2 100644 --- a/src/components/swap/ConfirmSwapModal.tsx +++ b/src/components/swap/ConfirmSwapModal.tsx @@ -9,6 +9,7 @@ import { Currency, Percent } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' import { sendAnalyticsEvent, Trace, useTrace } from 'analytics' import Badge from 'components/Badge' +import { ChainLogo } from 'components/Logo/ChainLogo' import Modal, { MODAL_TRANSITION_DURATION } from 'components/Modal' import { RowFixed } from 'components/Row' import { getChainInfo } from 'constants/chainInfo' @@ -55,11 +56,6 @@ const StyledL2Badge = styled(Badge)` padding: 6px 8px; ` -const StyledL2Logo = styled.img` - height: 16px; - width: 16px; -` - function isInApprovalPhase(confirmModalState: ConfirmModalState) { return ( confirmModalState === ConfirmModalState.RESETTING_TOKEN_ALLOWANCE || @@ -412,7 +408,7 @@ export default function ConfirmSwapModal({ return ( - + {info.label} diff --git a/src/components/swap/SwapLineItem.tsx b/src/components/swap/SwapLineItem.tsx index 397975b91a..a4ad6400a5 100644 --- a/src/components/swap/SwapLineItem.tsx +++ b/src/components/swap/SwapLineItem.tsx @@ -1,10 +1,10 @@ import { t, Trans } from '@lingui/macro' import { Currency, CurrencyAmount, Percent, TradeType } from '@uniswap/sdk-core' import { LoadingRow } from 'components/Loader/styled' +import { ChainLogo } from 'components/Logo/ChainLogo' import RouterLabel from 'components/RouterLabel' import Row, { RowBetween } from 'components/Row' import { MouseoverTooltip, TooltipSize } from 'components/Tooltip' -import { getChainInfo } from 'constants/chainInfo' import { SUPPORTED_GAS_ESTIMATE_CHAIN_IDS } from 'constants/chains' import useHoverProps from 'hooks/useHoverProps' import { useIsMobile } from 'nft/hooks' @@ -128,7 +128,7 @@ function useLineItem(props: SwapLineItemProps): LineItemData | undefined { if (isPreview) return return ( - gas cost icon + {formatNumber({ input: trade.totalGasUseEstimateUSD, type: NumberType.FiatGasPrice })} ) diff --git a/src/components/swap/__snapshots__/SwapDetailsDropdown.test.tsx.snap b/src/components/swap/__snapshots__/SwapDetailsDropdown.test.tsx.snap index 0391cdb5f2..c838b3cdee 100644 --- a/src/components/swap/__snapshots__/SwapDetailsDropdown.test.tsx.snap +++ b/src/components/swap/__snapshots__/SwapDetailsDropdown.test.tsx.snap @@ -399,12 +399,35 @@ exports[`SwapDetailsDropdown.tsx renders a trade 1`] = `
- gas cost icon + > + + Ethereum logo + + + + + ethereum.svg + + $1.00
diff --git a/src/components/swap/__snapshots__/SwapLineItem.test.tsx.snap b/src/components/swap/__snapshots__/SwapLineItem.test.tsx.snap index 05b2fcf01b..c1f7d1105b 100644 --- a/src/components/swap/__snapshots__/SwapLineItem.test.tsx.snap +++ b/src/components/swap/__snapshots__/SwapLineItem.test.tsx.snap @@ -198,12 +198,35 @@ exports[`SwapLineItem.tsx dutch order eth input 1`] = `
- gas cost icon + > + + Ethereum logo + + + + + ethereum.svg + + $0.00
@@ -1199,12 +1222,35 @@ exports[`SwapLineItem.tsx exact input 1`] = `
- gas cost icon + > + + Ethereum logo + + + + + ethereum.svg + + $1.00
@@ -2629,12 +2675,35 @@ exports[`SwapLineItem.tsx exact input api 1`] = `
- gas cost icon + > + + Ethereum logo + + + + + ethereum.svg + + $1.00
@@ -4059,12 +4128,35 @@ exports[`SwapLineItem.tsx exact output 1`] = `
- gas cost icon + > + + Ethereum logo + + + + + ethereum.svg + + -
@@ -5489,12 +5581,35 @@ exports[`SwapLineItem.tsx fee on buy 1`] = `
- gas cost icon + > + + Ethereum logo + + + + + ethereum.svg + + $1.00
@@ -7125,12 +7240,35 @@ exports[`SwapLineItem.tsx fee on sell 1`] = `
- gas cost icon + > + + Ethereum logo + + + + + ethereum.svg + + $1.00
diff --git a/src/components/swap/__snapshots__/SwapModalFooter.test.tsx.snap b/src/components/swap/__snapshots__/SwapModalFooter.test.tsx.snap index 66278adacc..093c9e8efb 100644 --- a/src/components/swap/__snapshots__/SwapModalFooter.test.tsx.snap +++ b/src/components/swap/__snapshots__/SwapModalFooter.test.tsx.snap @@ -281,12 +281,35 @@ exports[`SwapModalFooter.tsx matches base snapshot, test trade exact input 1`] =
- gas cost icon + > + + Ethereum logo + + + + + ethereum.svg + + $1.00
diff --git a/src/constants/chainInfo.ts b/src/constants/chainInfo.ts index 9fe2a175e5..6166348dfc 100644 --- a/src/constants/chainInfo.ts +++ b/src/constants/chainInfo.ts @@ -1,20 +1,4 @@ import { ChainId } from '@uniswap/sdk-core' -import bnbCircleLogoUrl from 'assets/images/bnbCircle.svg' -import ethereumLogoUrl from 'assets/images/ethereum-logo.png' -import polygonCircleLogoUrl from 'assets/images/polygonCircle.png' -import { default as arbitrumCircleLogoUrl, default as arbitrumLogoUrl } from 'assets/svg/arbitrum_logo.svg' -import avaxLogo from 'assets/svg/avax_logo.svg' -import avaxSquareLogo from 'assets/svg/avax_square_logo.svg' -import baseLogo from 'assets/svg/base_logo.svg' -import baseSquareLogo from 'assets/svg/base_square_logo.svg' -import bnbSquareLogoUrl from 'assets/svg/bnb_square_logo.svg' -import bnbLogo from 'assets/svg/bnb-logo.svg' -import celoLogo from 'assets/svg/celo_logo.svg' -import celoSquareLogoUrl from 'assets/svg/celo_square_logo.svg' -import optimismSquareLogoUrl from 'assets/svg/optimism_square_logo.svg' -import optimismLogoUrl from 'assets/svg/optimistic_ethereum.svg' -import polygonSquareLogoUrl from 'assets/svg/polygon_square_logo.svg' -import polygonMaticLogo from 'assets/svg/polygon-matic-logo.svg' import ms from 'ms' import { darkTheme } from 'theme/colors' @@ -46,9 +30,6 @@ interface BaseChainInfo { readonly bridge?: string readonly explorer: string readonly infoLink: string - readonly logoUrl: string - readonly circleLogoUrl?: string - readonly squareLogoUrl?: string readonly label: string readonly helpCenterUrl?: string readonly nativeCurrency: { @@ -83,7 +64,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://etherscan.io/', infoLink: 'https://info.uniswap.org/#/', label: 'Ethereum', - logoUrl: ethereumLogoUrl, nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, color: darkTheme.chain_1, }, @@ -93,7 +73,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://goerli.etherscan.io/', infoLink: 'https://info.uniswap.org/#/', label: 'Görli', - logoUrl: ethereumLogoUrl, nativeCurrency: { name: 'Görli Ether', symbol: 'görETH', decimals: 18 }, color: darkTheme.chain_5, }, @@ -103,7 +82,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://sepolia.etherscan.io/', infoLink: 'https://info.uniswap.org/#/', label: 'Sepolia', - logoUrl: ethereumLogoUrl, nativeCurrency: { name: 'Sepolia Ether', symbol: 'SepoliaETH', decimals: 18 }, color: darkTheme.chain_5, }, @@ -116,10 +94,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://optimistic.etherscan.io/', infoLink: 'https://info.uniswap.org/#/optimism/', label: 'Optimism', - logoUrl: optimismLogoUrl, - // Optimism perfers same icon for both - circleLogoUrl: optimismLogoUrl, - squareLogoUrl: optimismSquareLogoUrl, statusPage: 'https://optimism.io/status', helpCenterUrl: 'https://help.uniswap.org/en/collections/3137778-uniswap-on-optimistic-ethereum-oξ', nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, @@ -135,7 +109,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://goerli-optimism.etherscan.io/', infoLink: 'https://info.uniswap.org/#/optimism/', label: 'Optimism Görli', - logoUrl: optimismLogoUrl, statusPage: 'https://optimism.io/status', helpCenterUrl: 'https://help.uniswap.org/en/collections/3137778-uniswap-on-optimistic-ethereum-oξ', nativeCurrency: { name: 'Optimism Goerli Ether', symbol: 'görOpETH', decimals: 18 }, @@ -149,8 +122,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://arbiscan.io/', infoLink: 'https://info.uniswap.org/#/arbitrum', label: 'Arbitrum', - logoUrl: arbitrumLogoUrl, - circleLogoUrl: arbitrumCircleLogoUrl, defaultListUrl: ARBITRUM_LIST, helpCenterUrl: 'https://help.uniswap.org/en/collections/3137787-uniswap-on-arbitrum', nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, @@ -165,7 +136,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://goerli.arbiscan.io/', infoLink: 'https://info.uniswap.org/#/arbitrum/', label: 'Arbitrum Goerli', - logoUrl: arbitrumLogoUrl, defaultListUrl: ARBITRUM_LIST, // TODO: use arbitrum goerli token list helpCenterUrl: 'https://help.uniswap.org/en/collections/3137787-uniswap-on-arbitrum', nativeCurrency: { name: 'Goerli Arbitrum Ether', symbol: 'goerliArbETH', decimals: 18 }, @@ -179,9 +149,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://polygonscan.com/', infoLink: 'https://info.uniswap.org/#/polygon/', label: 'Polygon', - logoUrl: polygonMaticLogo, - circleLogoUrl: polygonCircleLogoUrl, - squareLogoUrl: polygonSquareLogoUrl, nativeCurrency: { name: 'Polygon Matic', symbol: 'MATIC', decimals: 18 }, color: darkTheme.chain_137, backgroundColor: darkTheme.chain_137_background, @@ -194,7 +161,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://mumbai.polygonscan.com/', infoLink: 'https://info.uniswap.org/#/polygon/', label: 'Polygon Mumbai', - logoUrl: polygonMaticLogo, nativeCurrency: { name: 'Polygon Mumbai Matic', symbol: 'mMATIC', decimals: 18 }, }, [ChainId.CELO]: { @@ -205,9 +171,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://celoscan.io/', infoLink: 'https://info.uniswap.org/#/celo/', label: 'Celo', - logoUrl: celoLogo, - circleLogoUrl: celoLogo, - squareLogoUrl: celoSquareLogoUrl, nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 }, defaultListUrl: CELO_LIST, }, @@ -219,7 +182,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://alfajores-blockscout.celo-testnet.org/', infoLink: 'https://info.uniswap.org/#/celo/', label: 'Celo Alfajores', - logoUrl: celoLogo, nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 }, defaultListUrl: CELO_LIST, }, @@ -231,9 +193,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://bscscan.com/', infoLink: 'https://info.uniswap.org/#/bnb/', label: 'BNB Chain', - logoUrl: bnbLogo, - circleLogoUrl: bnbCircleLogoUrl, - squareLogoUrl: bnbSquareLogoUrl, nativeCurrency: { name: 'BNB', symbol: 'BNB', decimals: 18 }, defaultListUrl: PLASMA_BNB_LIST, color: darkTheme.chain_56, @@ -247,9 +206,6 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://snowtrace.io/', infoLink: 'https://info.uniswap.org/#/avax/', // TODO(WEB-2336): Add avax support to info site label: 'Avalanche', - logoUrl: avaxLogo, - circleLogoUrl: avaxLogo, - squareLogoUrl: avaxSquareLogo, nativeCurrency: { name: 'AVAX', symbol: 'AVAX', decimals: 18 }, defaultListUrl: AVALANCHE_LIST, color: darkTheme.chain_43114, @@ -264,10 +220,7 @@ const CHAIN_INFO: ChainInfoMap = { explorer: 'https://basescan.org/', infoLink: 'https://info.uniswap.org/#/base/', label: 'Base', - logoUrl: baseLogo, statusPage: 'https://status.base.org/', - circleLogoUrl: baseLogo, - squareLogoUrl: baseSquareLogo, nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, color: darkTheme.chain_84531, }, diff --git a/src/graphql/data/util.tsx b/src/graphql/data/util.tsx index 65ce6f2d8b..d5088efbec 100644 --- a/src/graphql/data/util.tsx +++ b/src/graphql/data/util.tsx @@ -117,7 +117,8 @@ export function gqlToCurrency(token: { }): Currency | undefined { const chainId = supportedChainIdFromGQLChain(token.chain) if (!chainId) return undefined - if (token.standard === TokenStandard.Native || !token.address) return nativeOnChain(chainId) + if (token.standard === TokenStandard.Native || token.address === 'NATIVE' || !token.address) + return nativeOnChain(chainId) else return new Token(chainId, token.address, token.decimals ?? 18, token.symbol, token.name) } diff --git a/src/pages/PoolDetails/PoolDetailsHeader.tsx b/src/pages/PoolDetails/PoolDetailsHeader.tsx index 158134ad53..0588490b17 100644 --- a/src/pages/PoolDetails/PoolDetailsHeader.tsx +++ b/src/pages/PoolDetails/PoolDetailsHeader.tsx @@ -2,8 +2,8 @@ import { Trans } from '@lingui/macro' import { ChainId, Currency } from '@uniswap/sdk-core' import blankTokenUrl from 'assets/svg/blank_token.svg' import Column from 'components/Column' +import { ChainLogo } from 'components/Logo/ChainLogo' import Row from 'components/Row' -import { getChainInfo } from 'constants/chainInfo' import { chainIdToBackendName } from 'graphql/data/util' import { useCurrency } from 'hooks/Tokens' import useTokenLogoSource from 'hooks/useAssetLogoSource' @@ -116,8 +116,8 @@ function DoubleCurrencyAndChainLogo({ ) } -const L2LogoContainer = styled.div<{ hasSquareLogo?: boolean }>` - background-color: ${({ theme, hasSquareLogo }) => (hasSquareLogo ? theme.surface2 : theme.neutral1)}; +const L2LogoContainer = styled.div` + background-color: ${({ theme }) => theme.surface2}; border-radius: 2px; height: 12px; left: 60%; @@ -130,29 +130,12 @@ const L2LogoContainer = styled.div<{ hasSquareLogo?: boolean }>` justify-content: center; ` -const StyledChainLogo = styled.img` - height: 12px; - width: 12px; -` - -const SquareChainLogo = styled.img` - height: 100%; - width: 100%; -` - function SquareL2Logo({ chainId }: { chainId: ChainId }) { if (chainId === ChainId.MAINNET) return null - const { squareLogoUrl, logoUrl } = getChainInfo(chainId) - - const chainLogo = squareLogoUrl ?? logoUrl return ( - - {squareLogoUrl ? ( - - ) : ( - - )} + + ) }