Move heading to it's own component.

This commit is contained in:
Lucid Kobold
2021-12-05 20:55:06 -06:00
parent 992c7f217c
commit ff450533b6

View File

@@ -1,15 +1,14 @@
import React, { useContext } from "react"; import React, { useContext } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { Heading, HStack, IconButton } from "@chakra-ui/react"; import { HStack, IconButton } from "@chakra-ui/react";
import { Icon } from "@iconify/react"; import { Icon } from "@iconify/react";
import { sub, add, format } from "date-fns"; import { sub, add, format } from "date-fns";
import { CalenderContext } from "../../contexts/CalenderContext"; import { CalenderContext } from "../../contexts/CalenderContext";
import DatePicker from "./DatePicker";
const CalenderNav = (): JSX.Element => { const CalenderNav = (): JSX.Element => {
const { selectedDate } = useContext(CalenderContext); const { selectedDate } = useContext(CalenderContext);
const currentMonth = format(selectedDate, "LLLL uuuu");
const router = useRouter(); const router = useRouter();
const handleNavButtons = (direction: "next" | "prev") => { const handleNavButtons = (direction: "next" | "prev") => {
@@ -32,7 +31,7 @@ const CalenderNav = (): JSX.Element => {
router.push(`/calendar/${year}/${month}`); router.push(`/calendar/${year}/${month}`);
} }
} };
return ( return (
<HStack spacing={10} as="nav" w="auto" h="10vh" textAlign="center"> <HStack spacing={10} as="nav" w="auto" h="10vh" textAlign="center">
@@ -41,20 +40,11 @@ const CalenderNav = (): JSX.Element => {
icon={<Icon icon="akar-icons:chevron-left" />} icon={<Icon icon="akar-icons:chevron-left" />}
onClick={() => handleNavButtons("prev")} onClick={() => handleNavButtons("prev")}
/> />
<Heading <DatePicker />
w="100%"
h="auto"
_hover={{
cursor: "default",
}}
>
{currentMonth}
</Heading>
<IconButton <IconButton
aria-label="Next Month" aria-label="Next Month"
icon={<Icon icon="akar-icons:chevron-right" />} icon={<Icon icon="akar-icons:chevron-right" />}
onClick={() => handleNavButtons("next")} onClick={() => handleNavButtons("next")}
/> />
</HStack> </HStack>
); );