Commit 05ba0e4a authored by Nate Wienert's avatar Nate Wienert Committed by GitHub

fix: make popups appear above drawer and near top conditionally only … (#7201)

* fix: make popups appear above drawer and near top conditionally only when drawer is open

* remove logic around top bar
parent 5c53d823
import { ChainId } from '@uniswap/sdk-core' import { useActivePopups } from 'state/application/hooks'
import { useWeb3React } from '@web3-react/core'
import styled from 'styled-components' import styled from 'styled-components'
import { MEDIA_WIDTHS } from 'theme' import { Z_INDEX } from 'theme/zIndex'
import { useActivePopups } from '../../state/application/hooks' import { useAccountDrawer } from '../AccountDrawer'
import { useURLWarningVisible } from '../../state/user/hooks'
import { AutoColumn } from '../Column' import { AutoColumn } from '../Column'
import ClaimPopup from './ClaimPopup' import ClaimPopup from './ClaimPopup'
import PopupItem from './PopupItem' import PopupItem from './PopupItem'
...@@ -14,6 +12,8 @@ const MobilePopupWrapper = styled.div` ...@@ -14,6 +12,8 @@ const MobilePopupWrapper = styled.div`
max-width: 100%; max-width: 100%;
margin: 0 auto; margin: 0 auto;
display: none; display: none;
padding-left: 20px;
padding-right: 20px;
${({ theme }) => theme.deprecated_mediaWidth.deprecated_upToSmall` ${({ theme }) => theme.deprecated_mediaWidth.deprecated_upToSmall`
display: block; display: block;
...@@ -33,40 +33,31 @@ const MobilePopupInner = styled.div` ...@@ -33,40 +33,31 @@ const MobilePopupInner = styled.div`
} }
` `
const StopOverflowQuery = `@media screen and (min-width: ${MEDIA_WIDTHS.deprecated_upToMedium + 1}px) and (max-width: ${ const FixedPopupColumn = styled(AutoColumn)<{
MEDIA_WIDTHS.deprecated_upToMedium + 500 drawerOpen: boolean
}px)` }>`
const FixedPopupColumn = styled(AutoColumn)<{ extraPadding: boolean; xlPadding: boolean }>`
position: fixed; position: fixed;
top: ${({ extraPadding }) => (extraPadding ? '72px' : '64px')}; top: ${({ drawerOpen }) => `${64 + (drawerOpen ? -50 : 0)}px`};
right: 1rem; right: 1rem;
max-width: 348px !important; max-width: 348px !important;
width: 100%; width: 100%;
z-index: 3; z-index: ${Z_INDEX.modal};
transition: ${({ theme }) => `top ${theme.transition.timing.inOut} ${theme.transition.duration.slow}`};
${({ theme }) => theme.deprecated_mediaWidth.deprecated_upToSmall` ${({ theme }) => theme.deprecated_mediaWidth.deprecated_upToSmall`
display: none; display: none;
`}; `};
${StopOverflowQuery} {
top: ${({ extraPadding, xlPadding }) => (xlPadding ? '72px' : extraPadding ? '72px' : '64px')};
}
` `
export default function Popups() { export default function Popups() {
const [isAccountDrawerOpen] = useAccountDrawer()
// get all popups // get all popups
const activePopups = useActivePopups() const activePopups = useActivePopups()
const urlWarningActive = useURLWarningVisible()
// need extra padding if network is not L1 Ethereum
const { chainId } = useWeb3React()
const isNotOnMainnet = Boolean(chainId && chainId !== ChainId.MAINNET)
return ( return (
<> <>
<FixedPopupColumn gap="20px" extraPadding={urlWarningActive} xlPadding={isNotOnMainnet} data-testid="popups"> <FixedPopupColumn gap="20px" drawerOpen={isAccountDrawerOpen} data-testid="popups">
<ClaimPopup /> <ClaimPopup />
{activePopups.map((item) => ( {activePopups.map((item) => (
<PopupItem key={item.key} content={item.content} popKey={item.key} removeAfterMs={item.removeAfterMs} /> <PopupItem key={item.key} content={item.content} popKey={item.key} removeAfterMs={item.removeAfterMs} />
......
...@@ -43,7 +43,6 @@ export const sentryEnhancer = Sentry.createReduxEnhancer({ ...@@ -43,7 +43,6 @@ export const sentryEnhancer = Sentry.createReduxEnhancer({
userSlippageToleranceHasBeenMigratedToAuto: user.userSlippageToleranceHasBeenMigratedToAuto, userSlippageToleranceHasBeenMigratedToAuto: user.userSlippageToleranceHasBeenMigratedToAuto,
userDeadline: user.userDeadline, userDeadline: user.userDeadline,
timestamp: user.timestamp, timestamp: user.timestamp,
URLWarningVisible: user.URLWarningVisible,
showSurveyPopup: user.showSurveyPopup, showSurveyPopup: user.showSurveyPopup,
}, },
transactions, transactions,
......
...@@ -85,7 +85,6 @@ interface ExpectedUserState { ...@@ -85,7 +85,6 @@ interface ExpectedUserState {
} }
} }
timestamp: number timestamp: number
URLWarningVisible: boolean
hideBaseWalletBanner: boolean hideBaseWalletBanner: boolean
showSurveyPopup?: boolean showSurveyPopup?: boolean
disabledUniswapX?: boolean disabledUniswapX?: boolean
......
...@@ -12,7 +12,6 @@ import { UserAddedToken } from 'types/tokens' ...@@ -12,7 +12,6 @@ import { UserAddedToken } from 'types/tokens'
import { BASES_TO_TRACK_LIQUIDITY_FOR, PINNED_PAIRS } from '../../constants/routing' import { BASES_TO_TRACK_LIQUIDITY_FOR, PINNED_PAIRS } from '../../constants/routing'
import { useDefaultActiveTokens } from '../../hooks/Tokens' import { useDefaultActiveTokens } from '../../hooks/Tokens'
import { AppState } from '../reducer'
import { import {
addSerializedPair, addSerializedPair,
addSerializedToken, addSerializedToken,
...@@ -207,10 +206,6 @@ export function usePairAdder(): (pair: Pair) => void { ...@@ -207,10 +206,6 @@ export function usePairAdder(): (pair: Pair) => void {
) )
} }
export function useURLWarningVisible(): boolean {
return useAppSelector((state: AppState) => state.user.URLWarningVisible)
}
export function useHideBaseWalletBanner(): [boolean, () => void] { export function useHideBaseWalletBanner(): [boolean, () => void] {
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const hideBaseWalletBanner = useAppSelector((state) => state.user.hideBaseWalletBanner) const hideBaseWalletBanner = useAppSelector((state) => state.user.hideBaseWalletBanner)
......
...@@ -45,7 +45,6 @@ export interface UserState { ...@@ -45,7 +45,6 @@ export interface UserState {
} }
timestamp: number timestamp: number
URLWarningVisible: boolean
hideBaseWalletBanner: boolean hideBaseWalletBanner: boolean
disabledUniswapX?: boolean disabledUniswapX?: boolean
// undefined means has not gone through A/B split yet // undefined means has not gone through A/B split yet
...@@ -67,7 +66,6 @@ export const initialState: UserState = { ...@@ -67,7 +66,6 @@ export const initialState: UserState = {
tokens: {}, tokens: {},
pairs: {}, pairs: {},
timestamp: currentTimestamp(), timestamp: currentTimestamp(),
URLWarningVisible: true,
hideBaseWalletBanner: false, hideBaseWalletBanner: false,
showSurveyPopup: undefined, showSurveyPopup: undefined,
} }
......
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