Commit 21594343 authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

fix(polling): correct gas price color (#5413)

* fix(polling): correct gas price color

* pr feedback
parent f29c9f84
...@@ -9,29 +9,42 @@ import useMachineTimeMs from 'hooks/useMachineTime' ...@@ -9,29 +9,42 @@ import useMachineTimeMs from 'hooks/useMachineTime'
import JSBI from 'jsbi' import JSBI from 'jsbi'
import useBlockNumber from 'lib/hooks/useBlockNumber' import useBlockNumber from 'lib/hooks/useBlockNumber'
import ms from 'ms.macro' import ms from 'ms.macro'
import { useEffect, useState } from 'react' import { useEffect, useMemo, useState } from 'react'
import styled, { keyframes, useTheme } from 'styled-components/macro' import styled, { keyframes } from 'styled-components/macro'
import { ExternalLink, ThemedText } from 'theme' import { ExternalLink, ThemedText } from 'theme'
import { ExplorerDataType, getExplorerLink } from 'utils/getExplorerLink' import { ExplorerDataType, getExplorerLink } from 'utils/getExplorerLink'
import { MouseoverTooltip } from '../Tooltip' import { MouseoverTooltip } from '../Tooltip'
import { ChainConnectivityWarning } from './ChainConnectivityWarning' import { ChainConnectivityWarning } from './ChainConnectivityWarning'
const StyledPolling = styled.div<{ warning: boolean }>` const StyledPolling = styled.div`
position: fixed;
display: flex;
align-items: center; align-items: center;
right: 0;
bottom: 0; bottom: 0;
color: ${({ theme }) => theme.textTertiary};
display: none;
padding: 1rem; padding: 1rem;
color: ${({ theme, warning }) => (warning ? theme.deprecated_yellow3 : theme.deprecated_green1)}; position: fixed;
right: 0;
transition: 250ms ease color; transition: 250ms ease color;
${({ theme }) => theme.deprecated_mediaWidth.deprecated_upToMedium` a {
display: none; color: unset;
`} }
a:hover {
color: unset;
text-decoration: none;
}
@media screen and (min-width: ${({ theme }) => theme.breakpoint.md}px) {
display: flex;
}
` `
const StyledPollingNumber = styled(ThemedText.DeprecatedSmall)<{ breathe: boolean; hovering: boolean }>` const StyledPollingBlockNumber = styled(ThemedText.DeprecatedSmall)<{
breathe: boolean
hovering: boolean
warning: boolean
}>`
color: ${({ theme, warning }) => (warning ? theme.deprecated_yellow3 : theme.deprecated_green1)};
transition: opacity 0.25s ease; transition: opacity 0.25s ease;
opacity: ${({ breathe, hovering }) => (hovering ? 0.7 : breathe ? 1 : 0.5)}; opacity: ${({ breathe, hovering }) => (hovering ? 0.7 : breathe ? 1 : 0.5)};
:hover { :hover {
...@@ -106,7 +119,6 @@ export default function Polling() { ...@@ -106,7 +119,6 @@ export default function Polling() {
const [isHover, setIsHover] = useState(false) const [isHover, setIsHover] = useState(false)
const machineTime = useMachineTimeMs(NETWORK_HEALTH_CHECK_MS) const machineTime = useMachineTimeMs(NETWORK_HEALTH_CHECK_MS)
const blockTime = useCurrentBlockTimestamp() const blockTime = useCurrentBlockTimestamp()
const theme = useTheme()
const isNftPage = useIsNftPage() const isNftPage = useIsNftPage()
const ethGasPrice = useGasPrice() const ethGasPrice = useGasPrice()
...@@ -137,19 +149,27 @@ export default function Polling() { ...@@ -137,19 +149,27 @@ export default function Polling() {
//TODO - chainlink gas oracle is really slow. Can we get a better data source? //TODO - chainlink gas oracle is really slow. Can we get a better data source?
return isNftPage ? null : ( const blockExternalLinkHref = useMemo(() => {
<> if (!chainId || !blockNumber) return ''
return getExplorerLink(chainId, blockNumber.toString(), ExplorerDataType.BLOCK)
}, [blockNumber, chainId])
if (isNftPage) {
return null
}
return (
<RowFixed> <RowFixed>
<StyledPolling onMouseEnter={() => setIsHover(true)} onMouseLeave={() => setIsHover(false)} warning={warning}> <StyledPolling onMouseEnter={() => setIsHover(true)} onMouseLeave={() => setIsHover(false)}>
<ExternalLink href="https://etherscan.io/gastracker"> <ExternalLink href="https://etherscan.io/gastracker">
{priceGwei ? ( {!!priceGwei && (
<RowFixed style={{ marginRight: '8px' }}> <RowFixed style={{ marginRight: '8px' }}>
<ThemedText.DeprecatedMain fontSize="11px" mr="8px" color={theme.deprecated_text3}> <ThemedText.DeprecatedMain fontSize="11px" mr="8px">
<MouseoverTooltip <MouseoverTooltip
text={ text={
<Trans> <Trans>
The current fast gas amount for sending a transaction on L1. Gas fees are paid in The current fast gas amount for sending a transaction on L1. Gas fees are paid in Ethereum&apos;s
Ethereum&apos;s native currency Ether (ETH) and denominated in GWEI. native currency Ether (ETH) and denominated in GWEI.
</Trans> </Trans>
} }
> >
...@@ -158,25 +178,20 @@ export default function Polling() { ...@@ -158,25 +178,20 @@ export default function Polling() {
</ThemedText.DeprecatedMain> </ThemedText.DeprecatedMain>
<StyledGasDot /> <StyledGasDot />
</RowFixed> </RowFixed>
) : null} )}
</ExternalLink> </ExternalLink>
<StyledPollingNumber breathe={isMounting} hovering={isHover}> <StyledPollingBlockNumber breathe={isMounting} hovering={isHover} warning={warning}>
<ExternalLink <ExternalLink href={blockExternalLinkHref}>
href={
chainId && blockNumber ? getExplorerLink(chainId, blockNumber.toString(), ExplorerDataType.BLOCK) : ''
}
>
<MouseoverTooltip <MouseoverTooltip
text={<Trans>The most recent block number on this network. Prices update on every block.</Trans>} text={<Trans>The most recent block number on this network. Prices update on every block.</Trans>}
> >
{blockNumber}&ensp; {blockNumber}&ensp;
</MouseoverTooltip> </MouseoverTooltip>
</ExternalLink> </ExternalLink>
</StyledPollingNumber> </StyledPollingBlockNumber>
<StyledPollingDot warning={warning}>{isMounting && <Spinner warning={warning} />}</StyledPollingDot>{' '} <StyledPollingDot warning={warning}>{isMounting && <Spinner warning={warning} />}</StyledPollingDot>{' '}
</StyledPolling> </StyledPolling>
{warning && <ChainConnectivityWarning />} {warning && <ChainConnectivityWarning />}
</RowFixed> </RowFixed>
</>
) )
} }
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