diff --git a/component/calender/index.tsx b/component/calender/index.tsx deleted file mode 100644 index bb84b43..0000000 --- a/component/calender/index.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React from "react"; -import { Box, SimpleGrid } from "@chakra-ui/react"; -import { endOfMonth, getDate } from "date-fns"; - -const Calender = (): JSX.Element => { - const today = new Date(); - - const endOfCurrMonth = endOfMonth(today); - const lastDay = getDate(endOfCurrMonth); - - // console.info(`This month has ${lastDay} days.`); - - const daysArr = []; - for (let i = daysArr.length; i < lastDay; i++) { - daysArr.push(daysArr.length + 1); - } - return ( - - {daysArr.map((day) => { - return ( - {`Day ${day}`} - ); - })} - - ); -}; - -export default Calender; diff --git a/components/calender/Calender.tsx b/components/calender/Calender.tsx new file mode 100644 index 0000000..f6f6a76 --- /dev/null +++ b/components/calender/Calender.tsx @@ -0,0 +1,106 @@ +import React from "react"; +import { Box, HStack, SimpleGrid, Text, VStack } from "@chakra-ui/react"; +import { endOfMonth, getDate } from "date-fns"; +import CalenderNav from "./CalenderNav"; + +const Calender = (): JSX.Element => { + const today = new Date(); + + const endOfCurrMonth = endOfMonth(today); + const lastDay = getDate(endOfCurrMonth); + + // console.info(`This month has ${lastDay} days.`); + + 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 ( + + + + {daysOfWeek[userSettings.startOfWeek].map((weekDay) => { + return ( + + + {weekDay} + + + ); + })} + + + {daysOfMonth.map((monthDay) => { + return ( + + + {`Day ${monthDay}`} + + + ); + })} + + + ); +}; + +export default Calender; diff --git a/components/calender/CalenderNav.tsx b/components/calender/CalenderNav.tsx new file mode 100644 index 0000000..5e6903d --- /dev/null +++ b/components/calender/CalenderNav.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"; + +const CalenderNav = (): JSX.Element => { + const today = new Date(); + + const currentMonth = format(today, "LLLL uuuu"); + + return ( + + } + /> + + {currentMonth} + + } + /> + + ); +}; + +export default CalenderNav; diff --git a/package.json b/package.json index 0385b53..6ae99b8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "@chakra-ui/react": "^1.7.2", "@emotion/react": "^11.6.0", "@emotion/styled": "^11.6.0", - "@iconify/react": "^3.1.0", "@types/react": "^17.0.37", "date-fns": "^2.26.0", "framer-motion": "^5.3.3", @@ -29,6 +28,7 @@ "sharp": "^0.29.3" }, "devDependencies": { + "@iconify/react": "^3.1.0", "@typescript-eslint/eslint-plugin": "^5.4.0", "eslint": "<8.0.0", "eslint-config-next": "12.0.3", diff --git a/pages/index.tsx b/pages/index.tsx index 37f34cd..8a1bedd 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,17 +1,11 @@ import React from "react"; -import { Box, Heading } from "@chakra-ui/react"; -import Calender from "../component/calender"; +import { Box } from "@chakra-ui/react"; +import Calender from "../components/calender/Calender"; const IndexPage = (): JSX.Element => { return ( - {Calender ? ( - - ) : ( - - Hello World - - )} + ); };