163 lines
4.7 KiB
JavaScript
Raw Normal View History

2022-01-16 22:27:55 +00:00
import React from "react";
import {
Box,
Flex,
HStack,
Button,
useDisclosure,
VStack,
IconButton,
useColorModeValue,
2022-03-03 14:48:37 +00:00
Icon,
2022-01-16 22:27:55 +00:00
} from "@chakra-ui/react";
import Dark from "components/header/dark";
import {
IoApps,
IoBookOutline,
IoCloseSharp,
IoLogoGithub,
IoLogoTwitter,
} from "react-icons/io5";
2022-03-03 14:48:37 +00:00
import { BiLinkExternal } from "react-icons/bi";
2022-01-16 22:27:55 +00:00
import Link from "next/link";
import Hover from "animations/hover";
import Show from "animations/show";
2022-03-03 14:48:37 +00:00
import { svgl } from "components/svg";
import HEADER_LINKS from "./links";
2022-01-16 22:27:55 +00:00
const Header = () => {
const mobileNav = useDisclosure();
2022-03-03 14:48:37 +00:00
const bg = useColorModeValue("light.100", "lightDark.900");
2022-01-16 22:27:55 +00:00
return (
<>
<Box
2022-01-16 22:27:55 +00:00
w="full"
bg={bg}
2022-03-03 14:48:37 +00:00
px={{ base: 3, md: 16 }}
pl={{ base: 3, md: 16 }}
py="5"
2022-01-16 22:27:55 +00:00
pos="sticky"
2022-03-03 14:48:37 +00:00
top="0"
2022-01-16 22:27:55 +00:00
zIndex="1000"
>
2022-03-03 14:48:37 +00:00
<Flex alignItems="center" justifyContent="space-between" mx="auto">
<HStack spacing="1" alignItems="center">
2022-01-21 22:30:32 +00:00
<Hover>
<Link href="/" passHref>
2022-03-03 14:48:37 +00:00
<IconButton
as={svgl}
cursor="pointer"
name="logo"
boxSize="40px"
mr="2"
borderRadius="full"
bg="transparent"
/>
2022-01-21 22:30:32 +00:00
</Link>
</Hover>
2022-03-03 14:48:37 +00:00
{HEADER_LINKS.map((link) => (
<Link key={link.id} href={link.href} passHref>
<Button
as="a"
variant="ghost"
variantColor="teal"
fontWeight="light"
borderRadius="0"
_hover={{
transform: "translateY(-1px)",
transition: "all .1s",
borderBottomWidth: "1px",
}}
>
{link.title}
{link.external && (
<Icon as={BiLinkExternal} ml="2" w="4" h="4" />
)}
</Button>
</Link>
))}
</HStack>
<HStack display="flex" alignItems="center">
<HStack spacing={3} display={{ base: "none", md: "inline-flex" }}>
<Link href="https://github.com/pheralb/svgl" passHref>
<IconButton
aria-label="Github Repository"
bg="transparent"
border="0"
variant="outline"
icon={<IoLogoGithub size="30" />}
/>
</Link>
<Dark />
</HStack>
<Box display={{ base: "inline-flex", md: "none" }}>
<IconButton
display={{ base: "flex", md: "none" }}
aria-label="Open menu"
fontSize="20px"
variant="ghost"
icon={<IoApps />}
onClick={mobileNav.onOpen}
/>
<VStack
pos="absolute"
borderWidth="2px"
bg={bg}
top={0}
left={0}
right={0}
display={mobileNav.isOpen ? "flex" : "none"}
flexDirection="column"
pt="4"
pb={4}
spacing={3}
rounded="sm"
shadow="sm"
2022-01-16 22:27:55 +00:00
>
2022-03-03 14:48:37 +00:00
<Button
bg="transparent"
border="0"
variant="outline"
leftIcon={<IoCloseSharp size="25" />}
fontWeight="light"
onClick={mobileNav.onClose}
>
Close
</Button>
2022-01-16 22:27:55 +00:00
<Link
2022-03-03 14:48:37 +00:00
href="https://github.com/pheralb/svgl/tree/main/public/library"
2022-01-16 22:27:55 +00:00
passHref
>
<Button
2022-03-03 14:48:37 +00:00
bg="transparent"
border="0"
variant="outline"
leftIcon={<IoBookOutline size="25" />}
fontWeight="light"
>
Library
</Button>
2022-01-16 22:27:55 +00:00
</Link>
2022-03-03 14:48:37 +00:00
<Link href="https://github.com/pheralb/svgl" passHref>
<Button
bg="transparent"
border="0"
variant="outline"
2022-03-03 14:48:37 +00:00
leftIcon={<IoLogoGithub size="25" />}
fontWeight="light"
>
2022-03-03 14:48:37 +00:00
Github
</Button>
2022-03-03 14:48:37 +00:00
</Link>
<Dark />
</VStack>
</Box>
</HStack>
</Flex>
</Box>
2022-01-16 22:27:55 +00:00
</>
);
};
export default Header;