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
|
import { useState } from 'react'
import {
Link,
Box,
HStack,
IconButton,
Menu,
Heading,
MenuButton,
MenuList,
MenuItem,
MenuItemOption,
MenuGroup,
MenuOptionGroup,
MenuDivider,
useMediaQuery,
} from '@chakra-ui/react'
import { GiHamburgerMenu } from "react-icons/gi"
import { DiGithubBadge } from "react-icons/di"
function NavLink({to, children}) {
return <a href={to} className={`mx-4`}>
{children}
</a>
}
function MobileNav() {
return <Menu>
<MenuButton as={IconButton} icon={<GiHamburgerMenu/>}>
Action
</MenuButton>
<MenuList>
<MenuItem>Publications</MenuItem>
<MenuItem icon={<DiGithubBadge/>}>View source</MenuItem>
</MenuList>
</Menu>
}
function DesktopNav() {
return <HStack>
<Box>
<Link>Publications</Link>
</Box>
<Box>
<Link href="https://github.com/michalsapka/michal-sapka-pl">Source code</Link>
</Box>
</HStack>
}
function Navigation() {
const [isMobile] = useMediaQuery("(max-width: 768px)")
let navigationComponent = isMobile ? MobileNav : DesktopNav
return <HStack as="nav">{navigationComponent()}</HStack>
}
export default function Navbar() {
return <HStack>
<Heading>Michal </Heading>
<Navigation/>
</HStack>
}
|