1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-02-23 19:13:19 +01:00
developer-roadmap/components/global-header.tsx

113 lines
3.3 KiB
TypeScript
Raw Normal View History

2021-09-03 10:52:43 +02:00
import { useState } from 'react';
2021-09-05 20:55:22 +02:00
import { HamburgerIcon } from '@chakra-ui/icons';
import { Box, CloseButton, Container, Flex, IconButton, Image, Link, Stack, Text } from '@chakra-ui/react';
import RoadmapLogo from '../components/icons/roadmap.svg';
2021-09-03 10:52:43 +02:00
import siteConfig from '../content/site.json';
2021-08-28 12:48:48 +02:00
type MenuLinkProps = {
text: string;
link: string;
};
function MenuLink(props: MenuLinkProps) {
const { text, link } = props;
return <Link
borderBottomWidth={0}
borderBottomColor='gray.500'
_hover={{ textDecoration: 'none', borderBottomColor: 'white' }}
fontWeight={500}
href={link}
>
{text}
</Link>;
}
function DesktopMenuLinks() {
return (
<Stack d={['none', 'flex', 'flex']} shouldWrapChildren isInline spacing='15px' alignItems='center' color='gray.50'
fontSize='15px'>
<MenuLink text={'Roadmaps'} link={'/roadmaps'} />
<MenuLink text={'Guides'} link={'/guides'} />
<MenuLink text={'Videos'} link={'/watch'} />
<Link ml='10px' bgGradient='linear(to-l, yellow.700, red.600)' p='7px 10px' rounded='4px'
_hover={{ textDecoration: 'none', bgGradient: 'linear(to-l, red.800, yellow.700)' }}
2021-09-01 14:45:26 +02:00
fontWeight={500} href={'/signup'}>Subscribe</Link>
2021-08-28 12:48:48 +02:00
</Stack>
);
}
function MobileMenuLinks() {
2021-09-03 10:52:43 +02:00
const [isOpen, setIsOpen] = useState(false);
2021-08-28 12:48:48 +02:00
return (
2021-09-03 10:52:43 +02:00
<>
<IconButton
rounded='5px'
padding={0}
aria-label={'Menu'}
2021-08-28 12:48:48 +02:00
d={['block', 'none', 'none']}
2021-09-03 10:52:43 +02:00
icon={<HamburgerIcon color='white' w='25px' height='25px' />}
color='white'
2021-08-28 12:48:48 +02:00
cursor='pointer'
2021-09-03 10:52:43 +02:00
h='auto'
bg='transparent'
_hover={{ bg: 'transparent' }}
_active={{ bg: 'transparent' }}
_focus={{ bg: 'transparent' }}
onClick={() => setIsOpen(true)}
2021-08-28 12:48:48 +02:00
/>
2021-09-03 10:52:43 +02:00
{isOpen && (
<Stack color='gray.100'
fontSize={['22px', '22px', '22px', '32px']}
alignItems='center'
justifyContent='center'
pos='fixed'
left={0}
right={0}
bottom={0}
top={0}
bg='gray.900'
spacing='12px'
zIndex={1}
>
<Link href='/roadmaps'>Roadmaps</Link>
<Link href='/guides'>Guides</Link>
<Link href='/watch'>Videos</Link>
<Link target='_blank' href={siteConfig.url.youtube}>YouTube</Link>
<Link href='/signup'>Subscribe</Link>
<CloseButton onClick={() => setIsOpen(false)} pos='fixed' top='3px' right='15px' size='lg' />
</Stack>
)}
</>
2021-08-28 12:48:48 +02:00
);
}
2021-08-14 14:01:42 +02:00
2021-08-20 17:06:26 +02:00
export function GlobalHeader() {
2021-08-14 14:01:42 +02:00
return (
2021-09-09 22:32:12 +02:00
<Box bg='gray.900' p='58px 0 20px'>
2021-08-14 14:01:42 +02:00
<Container maxW='container.md'>
2021-08-28 12:48:48 +02:00
<Flex justifyContent='space-between' alignItems='center'>
2021-08-28 13:38:29 +02:00
<Box>
<Link w='100%'
d='flex'
href='/'
alignItems='center'
color='white'
fontWeight={600}
_hover={{ textDecoration: 'none' }}
fontSize='18px'>
2021-09-05 20:55:22 +02:00
<RoadmapLogo style={{ height: '30px', width: '30px', marginRight: '10px' }} />
2021-09-04 18:50:38 +02:00
<Text d={['block', 'none', 'block']} as='span'>roadmap.sh</Text>
2021-08-28 13:38:29 +02:00
</Link>
</Box>
2021-08-28 12:48:48 +02:00
<DesktopMenuLinks />
<MobileMenuLinks />
2021-08-14 14:01:42 +02:00
</Flex>
</Container>
</Box>
);
}