diff --git a/components/calender/NewContext.tsx b/components/calender/NewContext.tsx
index 47d0cfd..fd7135a 100644
--- a/components/calender/NewContext.tsx
+++ b/components/calender/NewContext.tsx
@@ -3,12 +3,11 @@ import { Box, Text } from "@chakra-ui/react";
import { NewCalenderContext } from "../../contexts/NewCalenderContext";
const NewContext = (): JSX.Element => {
- const { selectedMonthInfo } = useContext(NewCalenderContext);
- const { date } = selectedMonthInfo;
+ const { selectedDate } = useContext(NewCalenderContext);
return (
- {`New Context Was Provided. Selected date is ${date}`}
+ {`New Context Was Provided. Selected date is ${selectedDate}`}
);
};
diff --git a/components/calender/index.tsx b/components/calender/index.tsx
index 0d3f179..ffad149 100644
--- a/components/calender/index.tsx
+++ b/components/calender/index.tsx
@@ -2,7 +2,8 @@ import React, { useContext, useEffect } from "react";
import { Box, HStack, SimpleGrid, Text, VStack } from "@chakra-ui/react";
import CalenderNav from "./CalenderNav";
import { CalenderContext } from "../../contexts/CalenderContext";
-import NewContext from "./NewContext";
+import { NewCalenderContext } from "../../contexts/NewCalenderContext";
+import { getDate } from "date-fns";
interface UpdateCalendarProps {
year: number;
@@ -12,6 +13,7 @@ interface UpdateCalendarProps {
const Calender = (newDate?: UpdateCalendarProps): JSX.Element => {
const { daysOfMonth, daysOfWeek, setDate } = useContext(CalenderContext);
+ const { layout } = useContext(NewCalenderContext);
useEffect(() => {
if (newDate) {
@@ -31,9 +33,12 @@ const Calender = (newDate?: UpdateCalendarProps): JSX.Element => {
startOfWeek: "Sunday"
};
+ const currMonth = layout[`${userSettings.startOfWeek.toLowerCase()}`];
+ const { month, weekdays } = currMonth;
+
return (
-
+ {/* */}
{
alignContent="center"
alignItems="center"
>
- {daysOfWeek.startOfWeek[userSettings.startOfWeek].map((weekDay) => {
+ {weekdays.map((weekDay) => {
return (
{
// alignContent="center"
alignItems="center"
>
- {daysOfMonth.map((monthDay) => {
- return (
-
-
- {`Day ${monthDay}`}
-
-
- );
+ {Object.keys(month).map((week) => {
+ const thisWeek = month[week];
+
+ return thisWeek.map((day) => {
+ const { date, isOverflow } = day;
+
+ return (
+
+
+ {`Day ${getDate(date)}`}
+
+
+ );
+ });
})}
diff --git a/contexts/NewCalenderContext.tsx b/contexts/NewCalenderContext.tsx
index d4391ec..50debbd 100644
--- a/contexts/NewCalenderContext.tsx
+++ b/contexts/NewCalenderContext.tsx
@@ -49,11 +49,11 @@ interface MonthInfo {
interface MonthLayout {
sunday: {
- layout: DaysOfWeek;
+ weekdays: DaysOfWeek;
month: Month;
};
monday: {
- layout: DaysOfWeek;
+ weekdays: DaysOfWeek;
month: Month;
};
}
@@ -63,7 +63,9 @@ interface MonthContext extends MonthInfo {
}
interface CalenderContextState {
- selectedMonth: MonthContext;
+ selectedDate: Date;
+ title: string;
+ layout: MonthLayout;
}
const NewCalenderContext = createContext({} as CalenderContextState);
@@ -210,11 +212,11 @@ const NewCalenderContextProvider = ({
const output = {
sunday: {
- layout: weekDays.sunday,
+ weekdays: weekDays.sunday,
month: sundays
},
monday: {
- layout: weekDays.monday,
+ weekdays: weekDays.monday,
month: mondays
}
};
@@ -231,10 +233,7 @@ const NewCalenderContextProvider = ({
// );
const [selectedDate, setSelectedMonth] = useState(new Date());
- const [prevMonth, setPrevMonth] = useState(
- sub(selectedDate, { months: 1 })
- );
- const [selectedMonthInfo, setSelectedMonthInfo] = useState({
+ const [selectedDateInfo, setSelectedMonthInfo] = useState({
date: selectedDate,
title: format(selectedDate, "LLLL uuuu"),
layout: populateMonth(selectedDate)
@@ -249,7 +248,9 @@ const NewCalenderContextProvider = ({
//TODO: Add a useEffect that will trigger the update function(s) to run when the selected date is updated.
const calenderContextValues = {
- selectedMonthInfo
+ selectedDate: selectedDate,
+ title: selectedDateInfo.title,
+ layout: selectedDateInfo.layout
};
return (
diff --git a/theme/AppTheme.ts b/theme/AppTheme.ts
index 16de8ea..5c5e786 100644
--- a/theme/AppTheme.ts
+++ b/theme/AppTheme.ts
@@ -1,5 +1,5 @@
import { extendTheme, ThemeConfig } from "@chakra-ui/react";
-import { createBreakpoints } from "@chakra-ui/theme-tools";
+// import { createBreakpoints } from "@chakra-ui/theme-tools";
import buttons from "./components/buttonStyles";
const config: ThemeConfig = {
@@ -20,6 +20,7 @@ const AppTheme = extendTheme({
colors: {
brand: {
main: "#3138dc",
+ mainInactive: "#181d8f",
primary: "#0068ff",
secondary: "#0086ff",
hover: "#00aec1",