Prittier rules.
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
{
|
{
|
||||||
"trailingComma": "none"
|
"trailingComma": "none",
|
||||||
|
"tabWidth": 2,
|
||||||
|
"bracketSameLine": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,11 @@ const DatePicker = (): JSX.Element => {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(formProps: FormikProps<{ date: string }>) => (
|
{(
|
||||||
|
formProps: FormikProps<{
|
||||||
|
date: string;
|
||||||
|
}>
|
||||||
|
) => (
|
||||||
<Form
|
<Form
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
|||||||
@@ -45,13 +45,6 @@ interface Month {
|
|||||||
interface MonthInfo {
|
interface MonthInfo {
|
||||||
date: Date;
|
date: Date;
|
||||||
title: string;
|
title: string;
|
||||||
startDay: string;
|
|
||||||
endDay: string;
|
|
||||||
days: number;
|
|
||||||
prevMonth: {
|
|
||||||
date: Date;
|
|
||||||
endDay: number;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MonthLayout {
|
interface MonthLayout {
|
||||||
@@ -121,15 +114,13 @@ const NewCalenderContextProvider = ({
|
|||||||
return flag;
|
return flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Populates the month.
|
/**
|
||||||
const populateMonth = (
|
* A function that will return a month layout when given a date. It produces an object with 6 weeks that include overflow from the previous and next month with all dates aligned with the day of the week.
|
||||||
selectedDate: Date,
|
* @param selectedDate The date of the month to generate a month layout for.
|
||||||
startOfMonth: string,
|
*/
|
||||||
prevMonth: {
|
const populateMonth = (selectedDate: Date): MonthLayout => {
|
||||||
endDay: number;
|
const endLastMonth = getDate(endOfMonth(sub(selectedDate, { months: 1 })));
|
||||||
}
|
const startOfSelectedMonth = format(startOfMonth(selectedDate), "iii");
|
||||||
): MonthLayout => {
|
|
||||||
const { endDay: endLastMonth } = prevMonth;
|
|
||||||
|
|
||||||
const ISOToIndex = {
|
const ISOToIndex = {
|
||||||
sunday: {
|
sunday: {
|
||||||
@@ -161,7 +152,8 @@ const NewCalenderContextProvider = ({
|
|||||||
week6: new Array(7).fill(null)
|
week6: new Array(7).fill(null)
|
||||||
};
|
};
|
||||||
|
|
||||||
const sunStartDay = endLastMonth - (ISOToIndex.sunday[startOfMonth] - 1);
|
const sunStartDay =
|
||||||
|
endLastMonth - (ISOToIndex.sunday[startOfSelectedMonth] - 1);
|
||||||
|
|
||||||
let sunCurrDate = set(sub(selectedDate, { months: 1 }), {
|
let sunCurrDate = set(sub(selectedDate, { months: 1 }), {
|
||||||
date: sunStartDay
|
date: sunStartDay
|
||||||
@@ -175,7 +167,9 @@ const NewCalenderContextProvider = ({
|
|||||||
isOverflow: isOverflow(selectedDate, sunCurrDate),
|
isOverflow: isOverflow(selectedDate, sunCurrDate),
|
||||||
date: sunCurrDate
|
date: sunCurrDate
|
||||||
};
|
};
|
||||||
sunCurrDate = add(sunCurrDate, { days: 1 });
|
sunCurrDate = add(sunCurrDate, {
|
||||||
|
days: 1
|
||||||
|
});
|
||||||
|
|
||||||
sundays[week][i] = day;
|
sundays[week][i] = day;
|
||||||
});
|
});
|
||||||
@@ -190,7 +184,7 @@ const NewCalenderContextProvider = ({
|
|||||||
week6: new Array(7).fill(null)
|
week6: new Array(7).fill(null)
|
||||||
};
|
};
|
||||||
|
|
||||||
const monStartDay = endLastMonth - ISOToIndex.monday[startOfMonth];
|
const monStartDay = endLastMonth - ISOToIndex.monday[startOfSelectedMonth];
|
||||||
|
|
||||||
let monCurrDate = set(sub(selectedDate, { months: 1 }), {
|
let monCurrDate = set(sub(selectedDate, { months: 1 }), {
|
||||||
date: monStartDay
|
date: monStartDay
|
||||||
@@ -204,7 +198,9 @@ const NewCalenderContextProvider = ({
|
|||||||
isOverflow: isOverflow(selectedDate, monCurrDate),
|
isOverflow: isOverflow(selectedDate, monCurrDate),
|
||||||
date: monCurrDate
|
date: monCurrDate
|
||||||
};
|
};
|
||||||
monCurrDate = add(monCurrDate, { days: 1 });
|
monCurrDate = add(monCurrDate, {
|
||||||
|
days: 1
|
||||||
|
});
|
||||||
|
|
||||||
mondays[week][i] = day;
|
mondays[week][i] = day;
|
||||||
});
|
});
|
||||||
@@ -239,20 +235,7 @@ const NewCalenderContextProvider = ({
|
|||||||
const [selectedMonthInfo, setSelectedMonthInfo] = useState<MonthContext>({
|
const [selectedMonthInfo, setSelectedMonthInfo] = useState<MonthContext>({
|
||||||
date: selectedDate,
|
date: selectedDate,
|
||||||
title: format(selectedDate, "LLLL uuuu"),
|
title: format(selectedDate, "LLLL uuuu"),
|
||||||
startDay: format(startOfMonth(selectedDate), "iii"), // TODO Update to use the ISOToIndex dynamically with the user's start day preferences.
|
layout: populateMonth(selectedDate)
|
||||||
endDay: format(endOfMonth(selectedDate), "iii"), // TODO Update to use the ISOToIndex dynamically with the user's start day preferences.
|
|
||||||
days: getDate(endOfMonth(selectedDate)),
|
|
||||||
prevMonth: {
|
|
||||||
date: prevMonth,
|
|
||||||
endDay: getDate(endOfMonth(prevMonth))
|
|
||||||
},
|
|
||||||
layout: populateMonth(
|
|
||||||
selectedDate,
|
|
||||||
format(startOfMonth(selectedDate), "iii"),
|
|
||||||
{
|
|
||||||
endDay: getDate(endOfMonth(prevMonth))
|
|
||||||
}
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO: Update the MonthInfo to use the new month population function on first render.
|
//TODO: Update the MonthInfo to use the new month population function on first render.
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ const DateRoute: React.FC<unknown> = () => {
|
|||||||
const parsedSlug = slug.map((e) => {
|
const parsedSlug = slug.map((e) => {
|
||||||
return parseInt(e);
|
return parseInt(e);
|
||||||
});
|
});
|
||||||
setDate({ ...validateDateInput(parsedSlug) });
|
setDate({
|
||||||
|
...validateDateInput(parsedSlug)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [slug]);
|
}, [slug]);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ const BackToTopButton: FC<BackToTopButtonProps> = ({
|
|||||||
d={show ? "flex" : "none"}
|
d={show ? "flex" : "none"}
|
||||||
pos="fixed"
|
pos="fixed"
|
||||||
top="85vh"
|
top="85vh"
|
||||||
right={{ base: "1.25rem", sm: "2rem", md: "3rem" }}
|
right={{
|
||||||
|
base: "1.25rem",
|
||||||
|
sm: "2rem",
|
||||||
|
md: "3rem"
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Link href="/#top">
|
<Link href="/#top">
|
||||||
<Button variant="backToTop">
|
<Button variant="backToTop">
|
||||||
|
|||||||
@@ -98,7 +98,10 @@ const Header = (): JSX.Element => {
|
|||||||
{/* Logo | Site Name */}
|
{/* Logo | Site Name */}
|
||||||
<HStack
|
<HStack
|
||||||
width="100%"
|
width="100%"
|
||||||
justifyContent={{ base: "flex-start", sm: "center" }}
|
justifyContent={{
|
||||||
|
base: "flex-start",
|
||||||
|
sm: "center"
|
||||||
|
}}
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
height={12}
|
height={12}
|
||||||
top={0}
|
top={0}
|
||||||
@@ -161,7 +164,10 @@ const Header = (): JSX.Element => {
|
|||||||
onClick={() => setOpen(!open)}
|
onClick={() => setOpen(!open)}
|
||||||
onMouseEnter={() => setHover(true)}
|
onMouseEnter={() => setHover(true)}
|
||||||
onMouseLeave={() => setHover(false)}
|
onMouseLeave={() => setHover(false)}
|
||||||
d={{ base: "inline-flex", lg: "none" }}
|
d={{
|
||||||
|
base: "inline-flex",
|
||||||
|
lg: "none"
|
||||||
|
}}
|
||||||
variant="mobileNav"
|
variant="mobileNav"
|
||||||
bg={transparentNavbar ? "transparent" : "rgba(255, 255, 255, .15)"}
|
bg={transparentNavbar ? "transparent" : "rgba(255, 255, 255, .15)"}
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
Reference in New Issue
Block a user