fix: link to explore table when explore tokens banner clicked (#4811)

* token banner

* responses to jordan
This commit is contained in:
lynn 2022-10-05 22:59:35 -04:00 committed by GitHub
parent d794cef770
commit 53b57879a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,7 @@
import { Trans } from '@lingui/macro'
import { useGlobalChainName } from 'graphql/data/util'
import { X } from 'react-feather' import { X } from 'react-feather'
import { Link } from 'react-router-dom' import { Link, useNavigate } from 'react-router-dom'
import { useShowTokensPromoBanner } from 'state/user/hooks' import { useShowTokensPromoBanner } from 'state/user/hooks'
import styled, { useTheme } from 'styled-components/macro' import styled, { useTheme } from 'styled-components/macro'
import { opacify } from 'theme/utils' import { opacify } from 'theme/utils'
@ -59,22 +61,33 @@ const Description = styled(Link)`
export default function TokensBanner() { export default function TokensBanner() {
const theme = useTheme() const theme = useTheme()
const [showTokensPromoBanner, setShowTokensPromoBanner] = useShowTokensPromoBanner() const [showTokensPromoBanner, setShowTokensPromoBanner] = useShowTokensPromoBanner()
const navigate = useNavigate()
const chainName = useGlobalChainName().toLowerCase()
const closeBanner = () => { const navigateToExplorePage = () => {
setShowTokensPromoBanner(false) navigate(`/tokens/${chainName}`)
} }
return ( return (
<PopupContainer show={showTokensPromoBanner}> <PopupContainer show={showTokensPromoBanner} onClick={navigateToExplorePage}>
<Header> <Header>
<HeaderText to={'/tokens'} onClick={closeBanner}> <HeaderText to={'/tokens'}>
Explore Top Tokens <Trans>Explore Top Tokens</Trans>
</HeaderText> </HeaderText>
<X size={20} color={theme.textSecondary} onClick={closeBanner} style={{ cursor: 'pointer' }} /> <X
size={20}
color={theme.textSecondary}
onClick={(e) => {
e.preventDefault()
e.stopPropagation()
setShowTokensPromoBanner(false)
}}
style={{ cursor: 'pointer' }}
/>
</Header> </Header>
<Description to={'/tokens'} onClick={closeBanner}> <Description to={'/tokens'}>
Check out the new explore tab to discover and learn more <Trans>Check out the new explore tab to discover and learn more</Trans>
</Description> </Description>
</PopupContainer> </PopupContainer>
) )