Merge branch 'main' into v3-main
This commit is contained in:
commit
4bc1b8eb5c
@ -9,27 +9,29 @@ import { useActiveWeb3React } from '../../hooks'
|
|||||||
const StyledPolling = styled.div`
|
const StyledPolling = styled.div`
|
||||||
position: fixed;
|
position: fixed;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
color: white;
|
|
||||||
transition: opacity 0.25s ease;
|
|
||||||
color: ${({ theme }) => theme.green1};
|
color: ${({ theme }) => theme.green1};
|
||||||
:hover {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
${({ theme }) => theme.mediaWidth.upToMedium`
|
${({ theme }) => theme.mediaWidth.upToMedium`
|
||||||
display: none;
|
display: none;
|
||||||
`}
|
`}
|
||||||
`
|
`
|
||||||
|
const StyledPollingNumber = styled(TYPE.small)<{ breathe: boolean; hovering: boolean }>`
|
||||||
|
transition: opacity 0.25s ease;
|
||||||
|
opacity: ${({ breathe, hovering }) => (hovering ? 0.7 : breathe ? 1 : 0.2)};
|
||||||
|
:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
`
|
||||||
const StyledPollingDot = styled.div`
|
const StyledPollingDot = styled.div`
|
||||||
width: 8px;
|
width: 8px;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
min-height: 8px;
|
min-height: 8px;
|
||||||
min-width: 8px;
|
min-width: 8px;
|
||||||
margin-left: 0.5rem;
|
margin-left: 0.5rem;
|
||||||
margin-top: 3px;
|
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: ${({ theme }) => theme.green1};
|
background-color: ${({ theme }) => theme.green1};
|
||||||
@ -67,16 +69,21 @@ export default function Polling() {
|
|||||||
|
|
||||||
const blockNumber = useBlockNumber()
|
const blockNumber = useBlockNumber()
|
||||||
|
|
||||||
const [isMounted, setIsMounted] = useState(true)
|
const [isMounting, setIsMounting] = useState(false)
|
||||||
|
const [isHover, setIsHover] = useState(false)
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
const timer1 = setTimeout(() => setIsMounted(true), 1000)
|
if (!blockNumber) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsMounting(true)
|
||||||
|
const mountingTimer = setTimeout(() => setIsMounting(false), 1000)
|
||||||
|
|
||||||
// this will clear Timeout when component unmount like in willComponentUnmount
|
// this will clear Timeout when component unmount like in willComponentUnmount
|
||||||
return () => {
|
return () => {
|
||||||
setIsMounted(false)
|
clearTimeout(mountingTimer)
|
||||||
clearTimeout(timer1)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[blockNumber] //useEffect will run only one time
|
[blockNumber] //useEffect will run only one time
|
||||||
@ -85,9 +92,11 @@ export default function Polling() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ExternalLink href={chainId && blockNumber ? getEtherscanLink(chainId, blockNumber.toString(), 'block') : ''}>
|
<ExternalLink href={chainId && blockNumber ? getEtherscanLink(chainId, blockNumber.toString(), 'block') : ''}>
|
||||||
<StyledPolling>
|
<StyledPolling onMouseEnter={() => setIsHover(true)} onMouseLeave={() => setIsHover(false)}>
|
||||||
<TYPE.small style={{ opacity: isMounted ? '0.2' : '0.6' }}>{blockNumber}</TYPE.small>
|
<StyledPollingNumber breathe={isMounting} hovering={isHover}>
|
||||||
<StyledPollingDot>{!isMounted && <Spinner />}</StyledPollingDot>
|
{blockNumber}
|
||||||
|
</StyledPollingNumber>
|
||||||
|
<StyledPollingDot>{isMounting && <Spinner />}</StyledPollingDot>
|
||||||
</StyledPolling>
|
</StyledPolling>
|
||||||
</ExternalLink>
|
</ExternalLink>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user