You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.6 KiB

import { useLayoutEffect, useState } from "react";
4 years ago
import Link from "next/link";
import Profile from "./Profile";
4 years ago
function useWindowSize() {
const [size, setSize] = useState([0, 0]);
useLayoutEffect(() => {
function updateSize() {
setSize([window.innerWidth, window.innerHeight]);
}
window.addEventListener("resize", updateSize);
updateSize();
return () => window.removeEventListener("resize", updateSize);
}, []);
return size;
}
4 years ago
export default function Header(props) {
const [windowWidth, windowHeight] = useWindowSize();
4 years ago
return (
<header className="header">
<nav className="nav" role="navigation" aria-label="main navigation">
<Link href="/">
<a>
<h1>{props.siteTitle}</h1>
</a>
4 years ago
</Link>
{windowWidth >= 768 && <Profile></Profile>}
4 years ago
</nav>
<style jsx>
{`
h1 {
margin-bottom: 0;
}
h1:hover {
cursor: pointer;
}
nav {
padding: 1.5rem 1.25rem;
display: flex;
justify-content: space-between;
flex-direction: row;
align-items: center;
}
@media (min-width: 768px) {
.header {
height: 100vh;
position: fixed;
left: 0;
top: 0;
}
.nav {
padding: 2rem;
width: 30vw;
height: 100%;
border-bottom: none;
flex-direction: column;
align-items: flex-start;
}
}
`}
</style>
</header>
);
}