From e963fa625bfe93624e00f068a5df68cc49ca4d64 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 25 Aug 2020 17:53:00 +0200 Subject: [PATCH] Calendar day next (#3513) --- packages/page-calendar/src/Day.tsx | 21 +++-- packages/page-calendar/src/Month.tsx | 114 +++------------------------ packages/page-calendar/src/index.tsx | 85 +++++++++++++++++++- packages/page-calendar/src/types.ts | 8 ++ packages/page-calendar/src/util.ts | 57 ++++++++++++++ 5 files changed, 168 insertions(+), 117 deletions(-) create mode 100644 packages/page-calendar/src/util.ts diff --git a/packages/page-calendar/src/Day.tsx b/packages/page-calendar/src/Day.tsx index 7977055602..ad5a8c68dc 100644 --- a/packages/page-calendar/src/Day.tsx +++ b/packages/page-calendar/src/Day.tsx @@ -16,8 +16,11 @@ import { useTranslation } from './translate'; interface Props { className?: string; date: Date; + hasNextDay: boolean; now: Date; scheduled: EntryInfo[]; + setNextDay: () => void; + setPrevDay: () => void; } const HOURS = ((): number[] => { @@ -30,16 +33,14 @@ const HOURS = ((): number[] => { return hours; })(); -const NOOP = () => undefined; - -function Day ({ className, date, now, scheduled }: Props): React.ReactElement { +function Day ({ className, date, hasNextDay, now, scheduled, setNextDay, setPrevDay }: Props): React.ReactElement { const { t } = useTranslation(); const monthRef = useRef(MONTHS.map((m) => t(m))); const [isToday, nowHours, nowMinutes] = useMemo( () => [ - date.getDate() === now.getDate() && date.getMonth() === now.getMonth() && date.getFullYear() === now.getFullYear(), + date.getMonth() === now.getMonth() && date.getFullYear() === now.getFullYear() && date.getDate() === now.getDate(), now.getHours(), now.getMinutes() ], @@ -51,14 +52,14 @@ function Day ({ className, date, now, scheduled }: Props): React.ReactElement