sdy

recreate header

1 import React from "react"; 1 import React from "react";
2 import styled from "styled-components"; 2 import styled from "styled-components";
3 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; 3 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4 -import { faComments, faSignOutAlt } from "@fortawesome/free-solid-svg-icons"; 4 +import { faComments } from "@fortawesome/free-solid-svg-icons";
5 -import { gql } from "apollo-boost";
6 -import { useMutation } from "@apollo/react-hooks";
7 -import { BrowserRouter as Router, Link } from "react-router-dom";
8 5
9 -const LOG_OUT = gql` 6 +const HeaderBox = styled.div`
10 - mutation logUserOut { 7 + display: flex;
11 - logUserOut @client 8 + justify-content: space-between;
12 - } 9 + align-items: center;
13 `; 10 `;
14 11
15 -const HeaderContainer = styled.div` 12 +const HeaderTitleBox = styled.div`
13 + display: flex;
14 +`;
15 +
16 +const HeaderTitle = styled.span`
17 + font-size: 15px;
18 +`;
19 +
20 +const HeaderMenuBox = styled.div`
16 display: flex; 21 display: flex;
17 - flex-direction: row;
18 - justify-content: space-between;
19 - width: 100%;
20 - svg {
21 - font-size: 30px;
22 - }
23 - box-shadow: 1px 1px 20px #8395a7;
24 - background-color: #667aff;
25 `; 22 `;
26 23
27 -const TitleBox = styled.div` 24 +const HeaderMenuList = styled.ul`
28 display: flex; 25 display: flex;
29 - flex-direction: row;
30 - padding: 20px 10px;
31 - color: white;
32 - svg {
33 - margin-right: 5px;
34 - opacity: 0.7;
35 - }
36 `; 26 `;
37 27
38 -const HeaderSpan = styled.span` 28 +const HeaderMenuItem = styled.li`
39 - font-family: "Raleway", sans-serif; 29 + content: ${(props) => props.text};
40 - font-size: 30px;
41 `; 30 `;
42 31
43 -const StyledLink = styled(Link)` 32 +const StartBox = styled.div`
44 - text-decoration: none; 33 + background-color: #1b1464;
45 - color: white; 34 + color: #f1f2f6;
46 - cursor: pointer; 35 + font-size: 20px;
47 `; 36 `;
48 37
49 -export default ({ text }) => { 38 +export default () => {
50 - const [logOut] = useMutation(LOG_OUT);
51 return ( 39 return (
52 - <HeaderContainer className="Header"> 40 + <HeaderBox>
53 - <TitleBox> 41 + <HeaderTitleBox>
54 - <FontAwesomeIcon icon={faComments} /> 42 + <FontAwesomeIcon>
55 - <HeaderSpan>{text}</HeaderSpan> 43 + <faComments />
56 - </TitleBox> 44 + </FontAwesomeIcon>
57 - <TitleBox> 45 + <HeaderTitle>KhuChat</HeaderTitle>
58 - <Router> 46 + </HeaderTitleBox>
59 - <StyledLink to="/" onClick={logOut}> 47 + <HeaderMenuBox>
60 - <FontAwesomeIcon icon={faSignOutAlt} /> 48 + <HeaderMenuList>
61 - </StyledLink> 49 + <HeaderMenuItem text={"About This"} />
62 - </Router> 50 + </HeaderMenuList>
63 - </TitleBox> 51 + </HeaderMenuBox>
64 - </HeaderContainer> 52 + <StartBox>Start</StartBox>
53 + </HeaderBox>
65 ); 54 );
66 }; 55 };
......