Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new chain logos #7438

Merged
merged 8 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/assets/images/bnbCircle.svg

This file was deleted.

Binary file removed src/assets/images/polygonCircle.png
Binary file not shown.
9 changes: 0 additions & 9 deletions src/assets/svg/arbitrum_logo.svg

This file was deleted.

11 changes: 0 additions & 11 deletions src/assets/svg/avax_square_logo.svg

This file was deleted.

11 changes: 0 additions & 11 deletions src/assets/svg/base_logo.svg

This file was deleted.

11 changes: 0 additions & 11 deletions src/assets/svg/base_square_logo.svg

This file was deleted.

21 changes: 0 additions & 21 deletions src/assets/svg/bnb_square_logo.svg

This file was deleted.

5 changes: 0 additions & 5 deletions src/assets/svg/celo_square_logo.svg

This file was deleted.

15 changes: 0 additions & 15 deletions src/assets/svg/optimism_square_logo.svg

This file was deleted.

5 changes: 0 additions & 5 deletions src/assets/svg/optimistic_ethereum.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/svg/polygon-matic-logo.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/svg/polygon_square_logo.svg

This file was deleted.

30 changes: 6 additions & 24 deletions src/components/AccountDrawer/MiniPortfolio/PortfolioLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -152,17 +141,10 @@ interface PortfolioLogoProps {

function SquareL2Logo({ chainId }: { chainId: ChainId }) {
if (chainId === ChainId.MAINNET) return null
const { squareLogoUrl, logoUrl } = getChainInfo(chainId)

const chainLogo = squareLogoUrl ?? logoUrl

return (
<L2LogoContainer hasSquareLogo={!!squareLogoUrl}>
{squareLogoUrl ? (
<SquareChainLogo src={chainLogo} alt="chainLogo" />
) : (
<StyledChainLogo src={chainLogo} alt="chainLogo" />
)}
<L2LogoContainer>
<ChainLogo chainId={chainId} size={16} />
cartcrom marked this conversation as resolved.
Show resolved Hide resolved
</L2LogoContainer>
)
}
Expand All @@ -172,7 +154,7 @@ function SquareL2Logo({ chainId }: { chainId: ChainId }) {
*/
export function PortfolioLogo(props: PortfolioLogoProps) {
return (
<StyledLogoParentContainer>
<StyledLogoParentContainer style={props.style}>
{getLogo(props)}
<SquareL2Logo chainId={props.chainId} />
</StyledLogoParentContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,14 @@ exports[`PortfolioLogo renders with L2 icon 1`] = `
left: 0;
}

.c4 {
height: 14px;
width: 14px;
}

.c2 {
width: 40px;
height: 40px;
border-radius: 50%;
}

.c3 {
background-color: #222222;
border-radius: 2px;
border-radius: 4px;
height: 16px;
left: 60%;
position: absolute;
Expand Down Expand Up @@ -90,11 +84,29 @@ exports[`PortfolioLogo renders with L2 icon 1`] = `
<div
class="c3"
>
<img
alt="chainLogo"
class="c4"
src="arbitrum_logo.svg"
/>
<svg
height="16"
width="16"
>
<rect
fill="#F9F9F9"
height="16"
rx="4"
width="16"
/>
<rect
fill="#00A3FF33"
height="16"
rx="4"
width="16"
/>
<svg
height="16"
width="16"
>
arbitrum.svg
</svg>
</svg>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/DoubleLogo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export default function DoubleCurrencyLogo({
<Wrapper sizeraw={size} margin={margin}>
{currency0 && (
<HigherLogoWrapper>
<CurrencyLogo hideL2Icon currency={currency0} size={size.toString() + 'px'} />
<CurrencyLogo currency={currency0} size={size.toString() + 'px'} />
cartcrom marked this conversation as resolved.
Show resolved Hide resolved
</HigherLogoWrapper>
)}
{currency1 && (
<CoveredLogoWapper sizeraw={size}>
<CurrencyLogo hideL2Icon currency={currency1} size={size.toString() + 'px'} />
<CurrencyLogo currency={currency1} size={size.toString() + 'px'} />
cartcrom marked this conversation as resolved.
Show resolved Hide resolved
</CoveredLogoWapper>
)}
</Wrapper>
Expand Down
18 changes: 0 additions & 18 deletions src/components/Logo/AssetLogo.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 }

Expand All @@ -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
*/
Expand All @@ -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 ?? ''
Expand All @@ -104,7 +87,6 @@ export default function AssetLogo({
{symbol?.toUpperCase().replace('$', '').replace(/\s+/g, '').slice(0, 3)}
</MissingImageLogo>
)}
{!hideL2Icon && <L2NetworkLogo networkUrl={L2Icon} parentSize={size} />}
</LogoContainer>
)
}
Loading
Loading