-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathindex.tsx
71 lines (62 loc) · 1.67 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React, { useState, useRef, useContext } from "react";
import styled from "styled-components";
import { Link } from "react-router-dom";
import HamburgerIcon from "svgs/header/hamburger.svg";
import KlerosCourtLogo from "svgs/header/kleros-court.svg";
import LightButton from "components/LightButton";
import NavBar from "./navbar";
import { useFocusOutside } from "hooks/useFocusOutside";
const Container = styled.div`
position: sticky;
z-index: 9999;
top: 0;
width: 100%;
height: 64px;
background-color: ${({ theme }) => theme.primaryPurple};
padding: 0 24px;
display: flex;
align-items: center;
justify-content: space-between;
.kleros-court-link {
min-height: 48px;
}
`;
const StyledLightButton = styled(LightButton)`
padding: 0;
.button-svg {
margin-right: 0px;
fill: white;
}
.button-text {
display: none;
}
`;
const OpenContext = React.createContext({
isOpen: false,
toggleIsOpen: () => {
// Placeholder
},
});
export function useOpenContext() {
return useContext(OpenContext);
}
const Header: React.FC = () => {
const [isOpen, setIsOpen] = useState<boolean>(false);
const toggleIsOpen = () => setIsOpen(!isOpen);
const containerRef = useRef(null);
useFocusOutside(containerRef, () => setIsOpen(false));
return (
<Container>
<OpenContext.Provider value={{ isOpen, toggleIsOpen }}>
<Link className="kleros-court-link" to={"/"}>
<KlerosCourtLogo />
</Link>
<div ref={containerRef}>
<NavBar />
<StyledLightButton text="" Icon={HamburgerIcon} onClick={toggleIsOpen} />
</div>
</OpenContext.Provider>
</Container>
);
};
export default Header;