|
1 | 1 | import React from "react"; |
2 | 2 | import styled from "styled-components"; |
3 | | -import { useLockBodyScroll, useToggle } from "react-use"; |
4 | | -import ConnectWallet from "components/ConnectWallet"; |
5 | | -import LightButton from "components/LightButton"; |
6 | | -import KlerosSolutionsIcon from "svgs/menu-icons/kleros-solutions.svg"; |
| 3 | +import { useToggle } from "react-use"; |
7 | 4 | import { useOpenContext } from "../index"; |
8 | 5 | import DappList from "./DappList"; |
9 | 6 | import Explore from "./Explore"; |
| 7 | +import ConnectWallet from "components/ConnectWallet"; |
| 8 | +import LightButton from "components/LightButton"; |
| 9 | +import { Overlay } from "components/Overlay"; |
| 10 | +import KlerosSolutionsIcon from "svgs/menu-icons/kleros-solutions.svg"; |
10 | 11 | import Menu from "./Menu"; |
11 | 12 | import Debug from "./Debug"; |
| 13 | +import Help from "./Menu/Help"; |
| 14 | +import Settings from "./Menu/Settings"; |
| 15 | +import { useLockOverlayScroll } from "hooks/useLockOverlayScroll"; |
12 | 16 |
|
13 | 17 | const Container = styled.div<{ isOpen: boolean }>` |
14 | 18 | position: absolute; |
15 | 19 | top: 64px; |
16 | 20 | left: 0; |
17 | 21 | right: 0; |
| 22 | + max-height: calc(100vh - 64px); |
| 23 | + overflow-y: auto; |
18 | 24 | z-index: 1; |
19 | 25 | background-color: ${({ theme }) => theme.whiteBackground}; |
20 | 26 | border: 1px solid ${({ theme }) => theme.stroke}; |
21 | 27 | box-shadow: 0px 2px 3px ${({ theme }) => theme.defaultShadow}; |
22 | | -
|
23 | 28 | transform-origin: top; |
24 | 29 | transform: scaleY(${({ isOpen }) => (isOpen ? "1" : "0")}); |
25 | 30 | visibility: ${({ isOpen }) => (isOpen ? "visible" : "hidden")}; |
26 | 31 | transition-property: transform, visibility; |
27 | 32 | transition-duration: ${({ theme }) => theme.transitionSpeed}; |
28 | 33 | transition-timing-function: ease; |
29 | | -
|
30 | 34 | padding: 24px; |
31 | 35 |
|
32 | 36 | hr { |
33 | 37 | margin: 24px 0; |
34 | 38 | } |
35 | 39 | `; |
36 | 40 |
|
| 41 | +const PopupContainer = styled.div` |
| 42 | + position: fixed; |
| 43 | + top: 0; |
| 44 | + left: 0; |
| 45 | + width: 100%; |
| 46 | + height: 100%; |
| 47 | + z-index: 20; |
| 48 | +`; |
| 49 | + |
37 | 50 | const NavBar: React.FC = () => { |
38 | | - const [isSolutionsOpen, toggleSolution] = useToggle(false); |
| 51 | + const [isDappListOpen, toggleIsDappListOpen] = useToggle(false); |
| 52 | + const [isHelpOpen, toggleIsHelpOpen] = useToggle(false); |
| 53 | + const [isSettingsOpen, toggleIsSettingsOpen] = useToggle(false); |
39 | 54 | const { isOpen } = useOpenContext(); |
40 | | - useLockBodyScroll(isOpen); |
| 55 | + useLockOverlayScroll(isOpen); |
41 | 56 |
|
42 | 57 | return ( |
43 | | - <Container {...{ isOpen }}> |
44 | | - <LightButton |
45 | | - text="Kleros Solutions" |
46 | | - onClick={() => { |
47 | | - toggleSolution(); |
48 | | - }} |
49 | | - Icon={KlerosSolutionsIcon} |
50 | | - /> |
51 | | - {isSolutionsOpen && <DappList toggleSolution={toggleSolution} />} |
52 | | - <hr /> |
53 | | - <Explore /> |
54 | | - <hr /> |
55 | | - <ConnectWallet /> |
56 | | - <hr /> |
57 | | - <Menu /> |
58 | | - <br /> |
59 | | - <Debug /> |
60 | | - </Container> |
| 58 | + <> |
| 59 | + <Container {...{ isOpen }}> |
| 60 | + <LightButton |
| 61 | + text="Kleros Solutions" |
| 62 | + onClick={() => { |
| 63 | + toggleIsDappListOpen(); |
| 64 | + }} |
| 65 | + Icon={KlerosSolutionsIcon} |
| 66 | + /> |
| 67 | + <hr /> |
| 68 | + <Explore /> |
| 69 | + <hr /> |
| 70 | + <ConnectWallet /> |
| 71 | + <hr /> |
| 72 | + <Menu {...{ toggleIsHelpOpen, toggleIsSettingsOpen }} /> |
| 73 | + <br /> |
| 74 | + <Debug /> |
| 75 | + </Container> |
| 76 | + {(isDappListOpen || isHelpOpen || isSettingsOpen) && ( |
| 77 | + <PopupContainer> |
| 78 | + <Overlay /> |
| 79 | + {isDappListOpen && <DappList {...{ toggleIsDappListOpen }} />} |
| 80 | + {isHelpOpen && <Help {...{ toggleIsHelpOpen }} />} |
| 81 | + {isSettingsOpen && <Settings {...{ toggleIsSettingsOpen }} />} |
| 82 | + </PopupContainer> |
| 83 | + )} |
| 84 | + </> |
61 | 85 | ); |
62 | 86 | }; |
63 | 87 |
|
|
0 commit comments