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

feat: dismiss the landing page when the account drawer is opened (#6633)

* feat: dismiss the landing page when the account drawer is opened

* remove the gradient before the page transition

* pr feedback

* clean up darkmode handling

* pr feedback from design

* update link test

---------
Co-authored-by: default avatarJordan Frankfurt <jordan@CORN-Jordan-949.frankfurt>
parent ed58c39b
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
describe('Link', () => { describe('Link', () => {
it('should update route', () => { it('should update route', () => {
cy.viewport(2000, 1600) cy.viewport(2000, 1600)
cy.visit('/') cy.visit('/swap')
cy.contains('Pool').click() cy.contains('Pool').click()
cy.get('[data-cy="join-pool-button"]').should('exist') cy.get('[data-cy="join-pool-button"]').should('exist')
}) })
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { useAccountDrawer } from 'components/AccountDrawer'
import Web3Status from 'components/Web3Status' import Web3Status from 'components/Web3Status'
import { chainIdToBackendName } from 'graphql/data/util' import { chainIdToBackendName } from 'graphql/data/util'
import { useIsNftPage } from 'hooks/useIsNftPage' import { useIsNftPage } from 'hooks/useIsNftPage'
...@@ -10,7 +11,7 @@ import { Row } from 'nft/components/Flex' ...@@ -10,7 +11,7 @@ import { Row } from 'nft/components/Flex'
import { UniIcon } from 'nft/components/icons' import { UniIcon } from 'nft/components/icons'
import { useProfilePageState } from 'nft/hooks' import { useProfilePageState } from 'nft/hooks'
import { ProfilePageStateType } from 'nft/types' import { ProfilePageStateType } from 'nft/types'
import { ReactNode } from 'react' import { ReactNode, useCallback } from 'react'
import { NavLink, NavLinkProps, useLocation, useNavigate } from 'react-router-dom' import { NavLink, NavLinkProps, useLocation, useNavigate } from 'react-router-dom'
import { shouldDisableNFTRoutesAtom } from 'state/application/atoms' import { shouldDisableNFTRoutesAtom } from 'state/application/atoms'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
...@@ -93,6 +94,18 @@ const Navbar = ({ blur }: { blur: boolean }) => { ...@@ -93,6 +94,18 @@ const Navbar = ({ blur }: { blur: boolean }) => {
const navigate = useNavigate() const navigate = useNavigate()
const isNavSearchInputVisible = useIsNavSearchInputVisible() const isNavSearchInputVisible = useIsNavSearchInputVisible()
const [accountDrawerOpen, toggleAccountDrawer] = useAccountDrawer()
const handleUniIconClick = useCallback(() => {
if (accountDrawerOpen) {
toggleAccountDrawer()
}
navigate({
pathname: '/',
search: '?intro=true',
})
}, [accountDrawerOpen, navigate, toggleAccountDrawer])
return ( return (
<> <>
{blur && <Blur />} {blur && <Blur />}
...@@ -105,12 +118,7 @@ const Navbar = ({ blur }: { blur: boolean }) => { ...@@ -105,12 +118,7 @@ const Navbar = ({ blur }: { blur: boolean }) => {
height="48" height="48"
data-testid="uniswap-logo" data-testid="uniswap-logo"
className={styles.logo} className={styles.logo}
onClick={() => { onClick={handleUniIconClick}
navigate({
pathname: '/',
search: '?intro=true',
})
}}
/> />
</Box> </Box>
{!isNftPage && ( {!isNftPage && (
......
...@@ -5,6 +5,7 @@ import { AboutFooter } from 'components/About/AboutFooter' ...@@ -5,6 +5,7 @@ import { AboutFooter } from 'components/About/AboutFooter'
import Card, { CardType } from 'components/About/Card' import Card, { CardType } from 'components/About/Card'
import { MAIN_CARDS, MORE_CARDS } from 'components/About/constants' import { MAIN_CARDS, MORE_CARDS } from 'components/About/constants'
import ProtocolBanner from 'components/About/ProtocolBanner' import ProtocolBanner from 'components/About/ProtocolBanner'
import { useAccountDrawer } from 'components/AccountDrawer'
import { BaseButton } from 'components/Button' import { BaseButton } from 'components/Button'
import { useAtomValue } from 'jotai/utils' import { useAtomValue } from 'jotai/utils'
import Swap from 'pages/Swap' import Swap from 'pages/Swap'
...@@ -18,9 +19,10 @@ import { useAppSelector } from 'state/hooks' ...@@ -18,9 +19,10 @@ import { useAppSelector } from 'state/hooks'
import styled, { css } from 'styled-components/macro' import styled, { css } from 'styled-components/macro'
import { BREAKPOINTS } from 'theme' import { BREAKPOINTS } from 'theme'
import { useIsDarkMode } from 'theme/components/ThemeToggle' import { useIsDarkMode } from 'theme/components/ThemeToggle'
import { TRANSITION_DURATIONS } from 'theme/styles'
import { Z_INDEX } from 'theme/zIndex' import { Z_INDEX } from 'theme/zIndex'
const PageContainer = styled.div<{ isDarkMode: boolean }>` const PageContainer = styled.div`
position: absolute; position: absolute;
top: 0; top: 0;
padding: ${({ theme }) => theme.navHeight}px 0px 0px 0px; padding: ${({ theme }) => theme.navHeight}px 0px 0px 0px;
...@@ -30,11 +32,6 @@ const PageContainer = styled.div<{ isDarkMode: boolean }>` ...@@ -30,11 +32,6 @@ const PageContainer = styled.div<{ isDarkMode: boolean }>`
align-items: center; align-items: center;
scroll-behavior: smooth; scroll-behavior: smooth;
overflow-x: hidden; overflow-x: hidden;
background: ${({ isDarkMode }) =>
isDarkMode
? 'linear-gradient(rgba(8, 10, 24, 0) 0%, rgb(8 10 24 / 100%) 45%)'
: 'linear-gradient(rgba(255, 255, 255, 0) 0%, rgb(255 255 255 /100%) 45%)'};
` `
const Gradient = styled.div<{ isDarkMode: boolean }>` const Gradient = styled.div<{ isDarkMode: boolean }>`
...@@ -46,10 +43,14 @@ const Gradient = styled.div<{ isDarkMode: boolean }>` ...@@ -46,10 +43,14 @@ const Gradient = styled.div<{ isDarkMode: boolean }>`
bottom: 0; bottom: 0;
width: 100%; width: 100%;
min-height: 550px; min-height: 550px;
background: ${({ isDarkMode }) => ${({ isDarkMode }) =>
isDarkMode isDarkMode
? 'linear-gradient(rgba(8, 10, 24, 0) 0%, rgb(8 10 24 / 100%) 45%)' ? css`
: 'linear-gradient(rgba(255, 255, 255, 0) 0%, rgb(255 255 255 /100%) 45%)'}; background: linear-gradient(rgba(8, 10, 24, 0) 0%, rgb(8 10 24 / 100%) 45%);
`
: css`
background: linear-gradient(rgba(255, 255, 255, 0) 0%, rgb(255 255 255 /100%) 45%);
`};
z-index: ${Z_INDEX.under_dropdown}; z-index: ${Z_INDEX.under_dropdown};
pointer-events: none; pointer-events: none;
height: ${({ theme }) => `calc(100vh - ${theme.mobileBottomBarHeight}px)`}; height: ${({ theme }) => `calc(100vh - ${theme.mobileBottomBarHeight}px)`};
...@@ -111,10 +112,14 @@ const TitleText = styled.h1<{ isDarkMode: boolean }>` ...@@ -111,10 +112,14 @@ const TitleText = styled.h1<{ isDarkMode: boolean }>`
font-weight: 700; font-weight: 700;
text-align: center; text-align: center;
margin: 0 0 24px; margin: 0 0 24px;
background: ${({ isDarkMode }) => ${({ isDarkMode }) =>
isDarkMode isDarkMode
? 'linear-gradient(20deg, rgba(255, 244, 207, 1) 10%, rgba(255, 87, 218, 1) 100%)' ? css`
: 'linear-gradient(10deg, rgba(255,79,184,1) 0%, rgba(255,159,251,1) 100%)'}; background: linear-gradient(20deg, rgba(255, 244, 207, 1) 10%, rgba(255, 87, 218, 1) 100%);
`
: css`
background: linear-gradient(10deg, rgba(255, 79, 184, 1) 0%, rgba(255, 159, 251, 1) 100%);
`};
background-clip: text; background-clip: text;
-webkit-background-clip: text; -webkit-background-clip: text;
...@@ -214,10 +219,14 @@ const AboutContentContainer = styled.div<{ isDarkMode: boolean }>` ...@@ -214,10 +219,14 @@ const AboutContentContainer = styled.div<{ isDarkMode: boolean }>`
align-items: center; align-items: center;
padding: 0 24px 5rem; padding: 0 24px 5rem;
width: 100%; width: 100%;
background: ${({ isDarkMode }) => ${({ isDarkMode }) =>
isDarkMode isDarkMode
? 'linear-gradient(179.82deg, rgba(0, 0, 0, 0) 0.16%, #050026 99.85%)' ? css`
: 'linear-gradient(179.82deg, rgba(255, 255, 255, 0) 0.16%, #eaeaea 99.85%)'}; background: linear-gradient(179.82deg, rgba(0, 0, 0, 0) 0.16%, #050026 99.85%);
`
: css`
background: linear-gradient(179.82deg, rgba(255, 255, 255, 0) 0.16%, #eaeaea 99.85%);
`};
@media screen and (min-width: ${BREAKPOINTS.md}px) { @media screen and (min-width: ${BREAKPOINTS.md}px) {
padding: 0 96px 5rem; padding: 0 96px 5rem;
} }
...@@ -301,21 +310,23 @@ export default function Landing() { ...@@ -301,21 +310,23 @@ export default function Landing() {
ignoreQueryPrefix: true, ignoreQueryPrefix: true,
}) })
// This can be simplified significantly once the flag is removed! For now being explicit is clearer. const [accountDrawerOpen] = useAccountDrawer()
useEffect(() => { useEffect(() => {
if (queryParams.intro || !selectedWallet) { if ((queryParams.intro || !selectedWallet) && !accountDrawerOpen) {
setShowContent(true) setShowContent(true)
} else { } else {
setShowContent(false)
setTimeout(() => {
navigate('/swap') navigate('/swap')
}, TRANSITION_DURATIONS.medium)
} }
}, [navigate, selectedWallet, queryParams.intro]) }, [navigate, selectedWallet, queryParams.intro, accountDrawerOpen])
const shouldDisableNFTRoutes = useAtomValue(shouldDisableNFTRoutesAtom) const shouldDisableNFTRoutes = useAtomValue(shouldDisableNFTRoutesAtom)
return ( return (
<Trace page={InterfacePageName.LANDING_PAGE} shouldLogImpression> <Trace page={InterfacePageName.LANDING_PAGE} shouldLogImpression>
{showContent && ( <PageContainer data-testid="landing-page">
<PageContainer isDarkMode={isDarkMode} data-testid="landing-page">
<LandingSwapContainer> <LandingSwapContainer>
<TraceEvent <TraceEvent
events={[BrowserEvent.onClick]} events={[BrowserEvent.onClick]}
...@@ -327,6 +338,8 @@ export default function Landing() { ...@@ -327,6 +338,8 @@ export default function Landing() {
</Link> </Link>
</TraceEvent> </TraceEvent>
</LandingSwapContainer> </LandingSwapContainer>
{showContent && (
<>
<Gradient isDarkMode={isDarkMode} /> <Gradient isDarkMode={isDarkMode} />
<GlowContainer> <GlowContainer>
<Glow /> <Glow />
...@@ -388,8 +401,9 @@ export default function Landing() { ...@@ -388,8 +401,9 @@ export default function Landing() {
<ProtocolBanner /> <ProtocolBanner />
<AboutFooter /> <AboutFooter />
</AboutContentContainer> </AboutContentContainer>
</PageContainer> </>
)} )}
</PageContainer>
</Trace> </Trace>
) )
} }
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