Skip to content

Commit

Permalink
fix(responsiveness): small tweaks for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed Jul 7, 2020
1 parent 91a8202 commit 875203f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-scripts true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@ethersproject/strings": "^5.0.0-beta.136",
"@ethersproject/units": "^5.0.0-beta.132",
"@ethersproject/wallet": "^5.0.0-beta.141",
"@popperjs/core": "^2.4.0",
"@popperjs/core": "^2.4.4",
"@reach/dialog": "^0.10.3",
"@reach/portal": "^0.10.3",
"@reduxjs/toolkit": "^1.3.5",
Expand Down
11 changes: 10 additions & 1 deletion src/components/SearchModal/TokenSearchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ThemeContext } from 'styled-components'
import Card from '../../components/Card'
import { useActiveWeb3React } from '../../hooks'
import { useAllTokens, useToken } from '../../hooks/Tokens'
import useInterval from '../../hooks/useInterval'
import { useAllTokenBalancesTreatingWETHasETH, useTokenBalanceTreatingWETHasETH } from '../../state/wallet/hooks'
import { CloseIcon, LinkStyledButton } from '../../theme/components'
import { isAddress } from '../../utils'
Expand Down Expand Up @@ -110,10 +111,17 @@ export default function TokenSearchModal({

const openTooltip = useCallback(() => {
setTooltipOpen(true)
inputRef.current?.focus()
}, [setTooltipOpen])
const closeTooltip = useCallback(() => setTooltipOpen(false), [setTooltipOpen])

useInterval(
() => {
setTooltipOpen(false)
},
tooltipOpen ? 4000 : null,
false
)

return (
<Modal
isOpen={isOpen}
Expand Down Expand Up @@ -146,6 +154,7 @@ export default function TokenSearchModal({
value={searchQuery}
ref={inputRef}
onChange={handleInput}
onFocus={closeTooltip}
onBlur={closeTooltip}
/>
</Tooltip>
Expand Down
4 changes: 2 additions & 2 deletions src/components/SlippageTabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const Option = styled(FancyButton)<{ active: boolean }>`
const Input = styled.input`
background: ${({ theme }) => theme.bg1};
flex-grow: 1;
font-size: 12px;
min-width: 20px;
font-size: 16px;
min-width: 60px;
outline: none;
&::-webkit-outer-spin-button,
&::-webkit-inner-spin-button {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useInterval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef } from 'react'

export default function useInterval(callback: () => void, delay: null | number) {
export default function useInterval(callback: () => void, delay: null | number, leading = true) {
const savedCallback = useRef<() => void>()

// Remember the latest callback.
Expand All @@ -16,7 +16,7 @@ export default function useInterval(callback: () => void, delay: null | number)
}

if (delay !== null) {
tick()
if (leading) tick()
const id = setInterval(tick, delay)
return () => clearInterval(id)
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2046,10 +2046,10 @@
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==

"@popperjs/core@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.4.0.tgz#0e1bdf8d021e7ea58affade33d9d607e11365915"
integrity sha512-NMrDy6EWh9TPdSRiHmHH2ye1v5U0gBD7pRYwSwJvomx7Bm4GG04vu63dYiVzebLOx2obPpJugew06xVP0Nk7hA==
"@popperjs/core@^2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.4.4.tgz#11d5db19bd178936ec89cd84519c4de439574398"
integrity sha512-1oO6+dN5kdIA3sKPZhRGJTfGVP4SWV6KqlMOwry4J3HfyD68sl/3KmG7DeYUzvN+RbhXDnv/D8vNNB8168tAMg==

"@portis/eth-json-rpc-middleware@^4.1.2":
version "4.1.2"
Expand Down

0 comments on commit 875203f

Please sign in to comment.