-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.jsx
72 lines (63 loc) · 2.02 KB
/
header.jsx
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
72
/** @jsx jsx */
import { jsx, useColorMode, Styled } from 'theme-ui'
import { Link } from 'gatsby'
import { Flex } from '@theme-ui/components'
import { useSiteMetadata } from 'src/hooks/use-site-metadata'
import ColormodeButton from './colormode-button'
const Navigation = () => (
<nav sx={{ 'a:not(:last-of-type)': { mr: 3 }, fontSize: 2, '.active': { color: 'heading' } }}>
<Styled.a key="blog" as={Link} to="/blog" rel="blog posts">
Blog
</Styled.a>
<Styled.a key="reading notes" as={Link} to="/notes" rel="notes posts">
Digest
</Styled.a>
{/* <Styled.a key="photograph" as={Link} to="/photograph" rel="photos">
Photograph
</Styled.a> */}
<Styled.a key="about" as={Link} to="/about" rel="about">
About
</Styled.a>
</nav>
)
function Header(props) {
const { title: siteTitle } = useSiteMetadata()
const [colorMode, setColorMode] = useColorMode()
const isDark = colorMode === 'dark'
const { children, ...remainProps } = props
const toggleColorMode = (event) => {
event.preventDefault()
setColorMode(isDark ? 'light' : 'dark')
}
return (
// eslint-disable-next-line react/jsx-props-no-spreading
<header {...remainProps}>
<Flex sx={{ alignItems: 'center', justifyContent: 'space-between' }}>
<Link
to="/"
aria-label={`${siteTitle} - Back to home`}
sx={{ color: 'heading', textDecoration: 'none' }}
>
<Styled.h1 sx={{ my: 2, fontWeight: 'medium' }}>{siteTitle}</Styled.h1>
</Link>
</Flex>
<Flex
sx={{
variant: 'dividers.bottom',
alignItems: 'center',
justifyContent: 'space-between',
// mt: 0,
// mb: 2,
paddingBottom: 2,
color: 'toggleIcon',
a: { color: 'toggleIcon', ':hover': { color: 'heading' } },
flexFlow: 'wrap',
}}
>
<Navigation />
<ColormodeButton isDark={isDark} toggle={toggleColorMode} />
</Flex>
</header>
)
}
export default Header