-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdesktop-nav.js
More file actions
100 lines (97 loc) · 2.75 KB
/
desktop-nav.js
File metadata and controls
100 lines (97 loc) · 2.75 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { Link } from '@/components/mdx'
import { ChevronRightIcon } from '@chakra-ui/icons'
import {
Box,
Flex,
Icon,
Popover,
PopoverContent,
PopoverTrigger,
Stack,
Text,
useColorModeValue,
} from '@chakra-ui/react'
export const DesktopNav = ({ navItems, ...props }) => {
return (
<Stack direction={'row'} spacing={4} {...props}>
{navItems.map((navItem) => (
<Box key={navItem.label}>
<Popover trigger={'hover'} placement={'bottom-start'}>
<PopoverTrigger>
<Link
p={2}
href={navItem.href ?? '/#'}
fontSize={'sm'}
fontWeight={'bold'}
// eslint-disable-next-line react-hooks/rules-of-hooks
whiteSpace={'nowrap'}
flexShrink={0}
color={useColorModeValue('gray.600', 'gray.200')}
_hover={{
textDecoration: 'none',
// eslint-disable-next-line react-hooks/rules-of-hooks
color: useColorModeValue('gray.800', 'white'),
}}
>
{navItem.label}
</Link>
</PopoverTrigger>
{navItem.children && (
<PopoverContent
border={0}
boxShadow={'xl'}
// eslint-disable-next-line react-hooks/rules-of-hooks
bg={useColorModeValue('white', 'gray.800')}
p={4}
rounded={'xl'}
minW={'sm'}
>
<Stack>
{navItem.children.map((child) => (
<DesktopSubNav key={child.label} {...child} />
))}
</Stack>
</PopoverContent>
)}
</Popover>
</Box>
))}
</Stack>
)
}
const DesktopSubNav = ({ label, href, subLabel }) => {
return (
<Link
href={href ?? '#'}
role={'group'}
display={'block'}
p={2}
rounded={'md'}
_hover={{ bg: useColorModeValue('blue.50', 'gray.900') }}
>
<Stack direction={'row'} align={'center'}>
<Box>
<Text
transition={'all .3s ease'}
_groupHover={{ color: 'blue.400' }}
fontWeight={500}
>
{label}
</Text>
<Text fontSize={'sm'}>{subLabel}</Text>
</Box>
<Flex
transition={'all .3s ease'}
transform={'translateX(-10px)'}
opacity={0}
_groupHover={{ opacity: '100%', transform: 'translateX(0)' }}
justify={'flex-end'}
align={'center'}
flex={1}
>
<Icon color={'blue.400'} w={5} h={5} as={ChevronRightIcon} />
</Flex>
</Stack>
</Link>
)
}