sdy

update styling

1 import React from "react"; 1 import React from "react";
2 import styled from "styled-components"; 2 import styled from "styled-components";
3 -import { Link } from "react-router-dom";
4 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; 3 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5 import { faArrowRight } from "@fortawesome/free-solid-svg-icons"; 4 import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
5 +import { BrowserRouter as Router, Link } from "react-router-dom";
6 6
7 const Wrapper = styled.div` 7 const Wrapper = styled.div`
8 display: flex; 8 display: flex;
...@@ -63,18 +63,52 @@ const CreateContainer = styled.div` ...@@ -63,18 +63,52 @@ const CreateContainer = styled.div`
63 box-shadow: 0 -4px 4px rgba(0, 0, 0, 0.04); 63 box-shadow: 0 -4px 4px rgba(0, 0, 0, 0.04);
64 `; 64 `;
65 65
66 +const StyledLink = styled(Link)`
67 + width: 100%;
68 + display: flex;
69 + flex-direction: row;
70 + justify-content: space-between;
71 + align-items: center;
72 + text-decoration: none;
73 + cursor: pointer;
74 + color: #079992;
75 + svg {
76 + color: #079992;
77 + &:hover {
78 + border-bottom: 1px solid #079992;
79 + }
80 + }
81 + li {
82 + color: black;
83 + &:hover {
84 + color: #079992;
85 + }
86 + }
87 + span {
88 + &:hover {
89 + border-bottom: 1px solid #079992;
90 + }
91 + }
92 +`;
93 +
66 export default () => { 94 export default () => {
67 return ( 95 return (
68 - <Wrapper> 96 + <Router>
69 - <ChannelContainer> 97 + <Wrapper>
70 - <ChannelList> 98 + <ChannelContainer>
71 - <ChannelItem>First Channel</ChannelItem> 99 + <ChannelList>
72 - <FontAwesomeIcon icon={faArrowRight} /> 100 + <StyledLink to="/">
73 - </ChannelList> 101 + <ChannelItem>First Channel</ChannelItem>
74 - </ChannelContainer> 102 + <FontAwesomeIcon icon={faArrowRight} />
75 - <CreateContainer> 103 + </StyledLink>
76 - <Link to="/">Create New Channel</Link> 104 + </ChannelList>
77 - </CreateContainer> 105 + </ChannelContainer>
78 - </Wrapper> 106 + <CreateContainer>
107 + <StyledLink to="/">
108 + <span>Create New Channel</span>
109 + </StyledLink>
110 + </CreateContainer>
111 + </Wrapper>
112 + </Router>
79 ); 113 );
80 }; 114 };
......
...@@ -2,6 +2,15 @@ import React from "react"; ...@@ -2,6 +2,15 @@ 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, faSignOutAlt } 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 +
9 +const LOG_OUT = gql`
10 + mutation logUserOut {
11 + logUserOut @client
12 + }
13 +`;
5 14
6 const HeaderContainer = styled.div` 15 const HeaderContainer = styled.div`
7 display: flex; 16 display: flex;
...@@ -33,7 +42,14 @@ const HeaderSpan = styled.span` ...@@ -33,7 +42,14 @@ const HeaderSpan = styled.span`
33 font-size: 30px; 42 font-size: 30px;
34 `; 43 `;
35 44
45 +const StyledLink = styled(Link)`
46 + text-decoration: none;
47 + color: white;
48 + cursor: pointer;
49 +`;
50 +
36 export default ({ text }) => { 51 export default ({ text }) => {
52 + const [logOut] = useMutation(LOG_OUT);
37 return ( 53 return (
38 <HeaderContainer> 54 <HeaderContainer>
39 <TitleBox> 55 <TitleBox>
...@@ -41,7 +57,11 @@ export default ({ text }) => { ...@@ -41,7 +57,11 @@ export default ({ text }) => {
41 <HeaderSpan>{text}</HeaderSpan> 57 <HeaderSpan>{text}</HeaderSpan>
42 </TitleBox> 58 </TitleBox>
43 <TitleBox> 59 <TitleBox>
44 - <FontAwesomeIcon icon={faSignOutAlt} /> 60 + <Router>
61 + <StyledLink to="/" onClick={logOut}>
62 + <FontAwesomeIcon icon={faSignOutAlt} />
63 + </StyledLink>
64 + </Router>
45 </TitleBox> 65 </TitleBox>
46 </HeaderContainer> 66 </HeaderContainer>
47 ); 67 );
......