Header.js
1.46 KB
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
import React from "react";
import styled from "styled-components";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faComments, faSignOutAlt } from "@fortawesome/free-solid-svg-icons";
import { gql } from "apollo-boost";
import { useMutation } from "@apollo/react-hooks";
import { BrowserRouter as Router, Link } from "react-router-dom";
const LOG_OUT = gql`
mutation logUserOut {
logUserOut @client
}
`;
const HeaderContainer = styled.div`
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
svg {
font-size: 30px;
}
box-shadow: 1px 1px 20px #8395a7;
background-color: #667aff;
`;
const TitleBox = styled.div`
display: flex;
flex-direction: row;
padding: 20px 10px;
color: white;
svg {
margin-right: 5px;
opacity: 0.7;
}
`;
const HeaderSpan = styled.span`
font-family: "Raleway", sans-serif;
font-size: 30px;
`;
const StyledLink = styled(Link)`
text-decoration: none;
color: white;
cursor: pointer;
`;
export default ({ text }) => {
const [logOut] = useMutation(LOG_OUT);
return (
<HeaderContainer className="Header">
<TitleBox>
<FontAwesomeIcon icon={faComments} />
<HeaderSpan>{text}</HeaderSpan>
</TitleBox>
<TitleBox>
<Router>
<StyledLink to="/" onClick={logOut}>
<FontAwesomeIcon icon={faSignOutAlt} />
</StyledLink>
</Router>
</TitleBox>
</HeaderContainer>
);
};