-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMainNavigation.tsx
62 lines (57 loc) · 1.3 KB
/
MainNavigation.tsx
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
import React from 'react';
import {
List,
ListItem,
Button,
ButtonProps,
Flex,
Divider
} from '@chakra-ui/react';
import {
CollecticonFolder,
CollecticonPlusSmall
} from '@devseed-ui/collecticons-chakra';
import SmartLink, { SmartLinkProps } from './SmartLink';
import { UserInfo } from './auth/UserInfo';
import { useKeycloak } from 'src/auth/Context';
function NavItem(props: ButtonProps & SmartLinkProps) {
return (
<ListItem>
<Button
as={SmartLink}
variant='ghost'
sx={{
'&:hover': {
textDecoration: 'none'
}
}}
{...props}
/>
</ListItem>
);
}
function MainNavigation() {
const { keycloak } = useKeycloak();
return (
<Flex as='nav' aria-label='Main' gap={4} alignItems='center'>
<List display='flex' gap={2}>
<NavItem to='/collections/' rightIcon={<CollecticonFolder />}>
Browse
</NavItem>
{keycloak?.authenticated && (
<NavItem to='/collections/new' rightIcon={<CollecticonPlusSmall />}>
Create
</NavItem>
)}
</List>
<Divider
orientation='vertical'
borderLeftWidth='2px'
borderColor='base.200'
h='1rem'
/>
<UserInfo />
</Flex>
);
}
export default MainNavigation;