Date align #23

Merged
LucidKobold merged 29 commits from date-align into main 2021-12-29 20:09:30 -05:00
18 changed files with 379 additions and 79 deletions
Showing only changes of commit 40ebaec47c - Show all commits

View File

@@ -24,19 +24,22 @@ type Days =
type DaysOfWeek = Days[]; type DaysOfWeek = Days[];
interface WeekDays { interface WeekDays {
startOfWeek: { sunday: DaysOfWeek;
sunday: DaysOfWeek; monday: DaysOfWeek;
monday: DaysOfWeek; }
};
interface MonthDay {
isOverflow: boolean;
date: Date;
} }
interface Month { interface Month {
week1: Date[]; week1: MonthDay[];
week2: Date[]; week2: MonthDay[];
week3: Date[]; week3: MonthDay[];
week4: Date[]; week4: MonthDay[];
week5: Date[]; week5: MonthDay[];
week6: Date[]; week6: MonthDay[];
} }
interface MonthInfo { interface MonthInfo {
@@ -48,18 +51,19 @@ interface MonthInfo {
prevMonth: { prevMonth: {
date: Date; date: Date;
endDay: number; endDay: number;
days: number;
}; };
} }
interface MonthContext extends MonthInfo { interface MonthContext extends MonthInfo {
startOfWeek: { layout: {
sunday: { sunday: {
layout: DaysOfWeek; layout: DaysOfWeek;
header: String;
month: Month; month: Month;
}; };
monday: { monday: {
layout: DaysOfWeek; layout: DaysOfWeek;
header: String;
month: Month; month: Month;
}; };
}; };
@@ -77,26 +81,24 @@ const NewCalenderContextProvider = ({
children: ReactNode; children: ReactNode;
}): JSX.Element => { }): JSX.Element => {
const weekDays: WeekDays = { const weekDays: WeekDays = {
startOfWeek: { sunday: [
sunday: [ "Sunday",
"Sunday", "Monday",
"Monday", "Tuesday",
"Tuesday", "Wednesday",
"Wednesday", "Thursday",
"Thursday", "Friday",
"Friday", "Saturday"
"Saturday" ],
], monday: [
monday: [ "Monday",
"Monday", "Tuesday",
"Tuesday", "Wednesday",
"Wednesday", "Thursday",
"Thursday", "Friday",
"Friday", "Saturday",
"Saturday", "Sunday"
"Sunday" ]
]
}
}; };
const [selectedDate, setSelectedMonth] = useState<Date>(new Date()); const [selectedDate, setSelectedMonth] = useState<Date>(new Date());
@@ -111,16 +113,17 @@ const NewCalenderContextProvider = ({
days: getDate(endOfMonth(selectedDate)), days: getDate(endOfMonth(selectedDate)),
prevMonth: { prevMonth: {
date: prevMonth, date: prevMonth,
endDay: getDate(endOfMonth(prevMonth)), endDay: getDate(endOfMonth(prevMonth))
days: getDate(endOfMonth(prevMonth))
}, },
startOfWeek: { layout: {
sunday: { sunday: {
layout: weekDays.startOfWeek.sunday, layout: weekDays.sunday,
header: "Month title here",
month: {} as Month month: {} as Month
}, },
monday: { monday: {
layout: weekDays.startOfWeek.monday, layout: weekDays.monday,
header: "Month title here",
month: {} as Month month: {} as Month
} }
} }