Commit bede9171 authored by Justin Domingue's avatar Justin Domingue Committed by GitHub

add header background on scroll body overlap (#1531)

* add header background-color on scroll overlap

* slide background in/out on scroll

* remove unused import
Co-authored-by: default avatarJustin Domingue <domingue.justin@gmail.com>
parent 251d7c0b
import { ChainId } from '@uniswap/sdk-core' import { ChainId } from '@uniswap/sdk-core'
import useScrollPosition from '@react-hook/window-scroll'
import React, { useState } from 'react' import React, { useState } from 'react'
import { Text } from 'rebass' import { Text } from 'rebass'
import { NavLink } from 'react-router-dom' import { NavLink } from 'react-router-dom'
...@@ -29,7 +30,7 @@ import { Dots } from '../swap/styleds' ...@@ -29,7 +30,7 @@ import { Dots } from '../swap/styleds'
import Modal from '../Modal' import Modal from '../Modal'
import UniBalanceContent from './UniBalanceContent' import UniBalanceContent from './UniBalanceContent'
const HeaderFrame = styled.div` const HeaderFrame = styled.div<{ showBackground: boolean }>`
display: grid; display: grid;
grid-template-columns: 120px 1fr 120px; grid-template-columns: 120px 1fr 120px;
align-items: center; align-items: center;
...@@ -39,12 +40,17 @@ const HeaderFrame = styled.div` ...@@ -39,12 +40,17 @@ const HeaderFrame = styled.div`
width: 100%; width: 100%;
top: 0; top: 0;
position: relative; position: relative;
/* border-bottom: 1px solid ${({ theme }) => theme.bg2}; */
padding: 1rem; padding: 1rem;
z-index: 21; z-index: 21;
/* background-color: ${({ theme }) => theme.bg1}; */
position: relative; position: relative;
/* Background slide effect on scroll. */
background-image: ${({ theme }) => `linear-gradient(to bottom, transparent 50%, ${theme.bg0} 50% )}}`}
background-position: ${({ showBackground }) => (showBackground ? '0 -100%' : '0 0')};
background-size: 100% 200%;
box-shadow: 0px 0px 0px 1px ${({ theme, showBackground }) => (showBackground ? theme.bg2 : 'transparent;')};
transition: background-position .1s, box-shadow .1s;
${({ theme }) => theme.mediaWidth.upToMedium` ${({ theme }) => theme.mediaWidth.upToMedium`
padding: 1rem; padding: 1rem;
grid-template-columns: 120px 1fr; grid-template-columns: 120px 1fr;
...@@ -319,8 +325,10 @@ export default function Header() { ...@@ -319,8 +325,10 @@ export default function Header() {
const [showUniBalanceModal, setShowUniBalanceModal] = useState(false) const [showUniBalanceModal, setShowUniBalanceModal] = useState(false)
const showClaimPopup = useShowClaimPopup() const showClaimPopup = useShowClaimPopup()
const scrollY = useScrollPosition()
return ( return (
<HeaderFrame> <HeaderFrame showBackground={scrollY > 45}>
<ClaimModal /> <ClaimModal />
<Modal isOpen={showUniBalanceModal} onDismiss={() => setShowUniBalanceModal(false)}> <Modal isOpen={showUniBalanceModal} onDismiss={() => setShowUniBalanceModal(false)}>
<UniBalanceContent setShowUniBalanceModal={setShowUniBalanceModal} /> <UniBalanceContent setShowUniBalanceModal={setShowUniBalanceModal} />
......
...@@ -2409,6 +2409,38 @@ ...@@ -2409,6 +2409,38 @@
tslib "^2.0.0" tslib "^2.0.0"
warning "^4.0.3" warning "^4.0.3"
"@react-hook/event@^1.2.1":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@react-hook/event/-/event-1.2.3.tgz#cfe86d5cf36f53e85b367ff619990d001b5c82ae"
integrity sha512-WMBwLnYY2rubLeecsi4skl1imfx0oiXTgazV/1ByPT6WkmLvxUao3hC+mxps5D/+JK4Fq3uG9OWU/dn5jMtXyg==
dependencies:
"@react-hook/passive-layout-effect" "^1.2.0"
"@react-hook/latest@^1.0.2":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@react-hook/latest/-/latest-1.0.3.tgz#c2d1d0b0af8b69ec6e2b3a2412ba0768ac82db80"
integrity sha512-dy6duzl+JnAZcDbNTfmaP3xHiKtbXYOaz3G51MGVljh548Y8MWzTr+PHLOfvpypEVW9zwvl+VyKjbWKEVbV1Rg==
"@react-hook/passive-layout-effect@^1.2.0":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@react-hook/passive-layout-effect/-/passive-layout-effect-1.2.1.tgz#c06dac2d011f36d61259aa1c6df4f0d5e28bc55e"
integrity sha512-IwEphTD75liO8g+6taS+4oqz+nnroocNfWVHWz7j+N+ZO2vYrc6PV1q7GQhuahL0IOR7JccFTsFKQ/mb6iZWAg==
"@react-hook/throttle@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@react-hook/throttle/-/throttle-2.2.0.tgz#d0402714a06e1ba0bc1da1fdf5c3c5cd0e08d45a"
integrity sha512-LJ5eg+yMV8lXtqK3lR+OtOZ2WH/EfWvuiEEu0M3bhR7dZRfTyEJKxH1oK9uyBxiXPtWXiQggWbZirMCXam51tg==
dependencies:
"@react-hook/latest" "^1.0.2"
"@react-hook/window-scroll@^1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@react-hook/window-scroll/-/window-scroll-1.3.0.tgz#07914239a452075c7eb28d15ed0e2fd45aa2d65b"
integrity sha512-LdYnCL22pFI+LTs85Fi2OQHSKWkzIuHFgv8lA+wwuaPxLOEhWR5bzJ21iygUH9X4meeLVRZKEbfpYi3OWWD4GQ==
dependencies:
"@react-hook/event" "^1.2.1"
"@react-hook/throttle" "^2.2.0"
"@reduxjs/toolkit@^1.3.5": "@reduxjs/toolkit@^1.3.5":
version "1.5.1" version "1.5.1"
resolved "https://registry.yarnpkg.com/@reduxjs/toolkit/-/toolkit-1.5.1.tgz#05daa2f6eebc70dc18cd98a90421fab7fa565dc5" resolved "https://registry.yarnpkg.com/@reduxjs/toolkit/-/toolkit-1.5.1.tgz#05daa2f6eebc70dc18cd98a90421fab7fa565dc5"
......
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