From 3f244d0f96dfe8273f7793dc8d639fcdde21383e Mon Sep 17 00:00:00 2001 From: Lucid Kobold Date: Thu, 25 Nov 2021 18:03:08 -0600 Subject: [PATCH] Added non-functional navbar to the calender component. Added days of the week to the calender component. --- component/calender/index.tsx | 113 +++++++++++++++++++++++++++-------- component/calender/nav.tsx | 28 +++++++++ 2 files changed, 117 insertions(+), 24 deletions(-) create mode 100644 component/calender/nav.tsx diff --git a/component/calender/index.tsx b/component/calender/index.tsx index bb84b43..0d0c973 100644 --- a/component/calender/index.tsx +++ b/component/calender/index.tsx @@ -1,6 +1,7 @@ import React from "react"; -import { Box, SimpleGrid } from "@chakra-ui/react"; +import { Box, HStack, SimpleGrid, Text, VStack } from "@chakra-ui/react"; import { endOfMonth, getDate } from "date-fns"; +import CalenderNav from "./nav"; const Calender = (): JSX.Element => { const today = new Date(); @@ -10,31 +11,95 @@ const Calender = (): JSX.Element => { // console.info(`This month has ${lastDay} days.`); - const daysArr = []; - for (let i = daysArr.length; i < lastDay; i++) { - daysArr.push(daysArr.length + 1); + const daysOfMonth = []; + for (let i = daysOfMonth.length; i < lastDay; i++) { + daysOfMonth.push(daysOfMonth.length + 1); } + + const daysOfWeek = { + Sunday: [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + ], + Monday: [ + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + "Sunday", + ], + }; + + const userSettings = { + theme: "default", + startOfWeek: "Sunday", + }; + return ( - - {daysArr.map((day) => { - return ( - {`Day ${day}`} - ); - })} - + + + + {daysOfWeek[userSettings.startOfWeek].map((weekDay) => { + return ( + + + {weekDay} + + + ); + })} + + + {daysOfMonth.map((monthDay) => { + return ( + + + {`Day ${monthDay}`} + + + ); + })} + + ); }; diff --git a/component/calender/nav.tsx b/component/calender/nav.tsx new file mode 100644 index 0000000..b62504a --- /dev/null +++ b/component/calender/nav.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import { Heading, HStack, IconButton } from "@chakra-ui/react"; +import { Icon } from "@iconify/react"; +import { format } from "date-fns/esm"; + +const CalenderNav = (): JSX.Element => { + const today = new Date(); + + const currentMonth = format(today, "LLLL uuuu"); + + return ( + + } + /> + + {currentMonth} + + } + /> + + ); +}; + +export default CalenderNav;