qpa-client/packages/qpa/App/Header/Header.tsx

57 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-06-14 07:24:38 +02:00
import styled from "@emotion/styled"
2019-08-03 17:30:54 +02:00
import * as React from "react"
import { Link } from "react-router-dom"
import { AppContext } from "../Context/AppContext"
2019-06-14 07:24:38 +02:00
2017-01-01 01:29:43 +01:00
interface Props {
className?: string
}
const Header = (props: Props) => (
2019-06-14 07:24:38 +02:00
<AppContext>
{({ me }) => (
2017-01-01 01:29:43 +01:00
<Root className={props.className}>
2019-06-14 07:24:38 +02:00
<Menu />
<Title />
<LinksSection>
{me ? (
2019-06-30 09:30:43 +02:00
<>
<StyledLink to="/create">Create event</StyledLink>
<StyledLink to="/logout">Log out</StyledLink>
</>
2019-06-14 07:24:38 +02:00
) : (
<>
<StyledLink to="/login">Log In</StyledLink>
<StyledLink to="/signup">Sign Up</StyledLink>
</>
)}
</LinksSection>
</Root>
)}
</AppContext>
)
const StyledLink = styled(Link)`
color: rgba(0,0,0,.7);
2019-06-21 08:07:56 +02:00
&:not(:first-of-type) {
2019-06-14 07:24:38 +02:00
margin-left: 8px;
}
`
const Menu = styled.div``
const Title = styled.div`
flex: 1;
`
const Root = styled.div`
background: rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: row;
2019-10-07 17:06:08 +02:00
padding-right: 14px;
2019-06-14 07:24:38 +02:00
`
const LinksSection = styled.div`
align-self: center;
padding: 4px;
`
export default Header