fix(identicon): fix wrapper border-radius (#5144)

* fix(identicon): fix wrapper border-radius

* pr feedback
This commit is contained in:
Jordan Frankfurt 2022-11-09 13:56:25 -06:00 committed by GitHub
parent 491ae578ab
commit d016bdd87c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

@ -1,13 +1,13 @@
import jazzicon from '@metamask/jazzicon' import jazzicon from '@metamask/jazzicon'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import useENSAvatar from 'hooks/useENSAvatar' import useENSAvatar from 'hooks/useENSAvatar'
import { useLayoutEffect, useMemo, useRef, useState } from 'react' import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
const StyledIdenticon = styled.div<{ iconSize: number }>` const StyledIdenticon = styled.div<{ iconSize: number }>`
height: ${({ iconSize }) => `${iconSize}px`}; height: ${({ iconSize }) => `${iconSize}px`};
width: ${({ iconSize }) => `${iconSize}px`}; width: ${({ iconSize }) => `${iconSize}px`};
border-radius: 1.125rem; border-radius: 50%;
background-color: ${({ theme }) => theme.deprecated_bg4}; background-color: ${({ theme }) => theme.deprecated_bg4};
font-size: initial; font-size: initial;
` `
@ -41,10 +41,12 @@ export default function Identicon({ size }: { size?: number }) {
return return
}, [icon, iconRef]) }, [icon, iconRef])
const handleError = useCallback(() => setFetchable(false), [])
return ( return (
<StyledIdenticon iconSize={iconSize}> <StyledIdenticon iconSize={iconSize}>
{avatar && fetchable ? ( {avatar && fetchable ? (
<StyledAvatar alt="avatar" src={avatar} onError={() => setFetchable(false)}></StyledAvatar> <StyledAvatar alt="avatar" src={avatar} onError={handleError}></StyledAvatar>
) : ( ) : (
<span ref={iconRef} /> <span ref={iconRef} />
)} )}

@ -17,7 +17,11 @@ export const ProfileAccountDetails = () => {
setCopied(account ?? '') setCopied(account ?? '')
}, [account, setCopied]) }, [account, setCopied])
return account ? ( if (!account) {
return null
}
return (
<Row className={headlineLarge} marginBottom="48" gap="4"> <Row className={headlineLarge} marginBottom="48" gap="4">
<Identicon size={60} /> <Identicon size={60} />
<Box textOverflow="ellipsis" overflow="hidden" marginLeft="8"> <Box textOverflow="ellipsis" overflow="hidden" marginLeft="8">
@ -36,5 +40,5 @@ export const ProfileAccountDetails = () => {
</Box> </Box>
</MouseoverTooltip> </MouseoverTooltip>
</Row> </Row>
) : null )
} }