-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcalendar-body-day-cell.tsx
More file actions
43 lines (39 loc) · 1.12 KB
/
calendar-body-day-cell.tsx
File metadata and controls
43 lines (39 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Typography } from "@mui/material";
import { cn } from "@/lib/utils";
import type { ZotDate } from "@/lib/zotdate";
interface CalendarBodyDayCellProps {
isHighlighted: boolean;
calendarDay: ZotDate;
isCurrentMonth: boolean;
}
export function CalendarBodyDayCell({
isHighlighted,
calendarDay,
isCurrentMonth,
}: CalendarBodyDayCellProps) {
const isSelected = calendarDay.isSelected;
const today = new Date();
const isToday =
calendarDay.getDay() === today.getDate() &&
calendarDay.getMonth() === today.getMonth() &&
calendarDay.getYear() === today.getFullYear();
const dayClassName = cn(
"relative aspect-square h-10 w-10 flex-center rounded-xl text-2xl",
isSelected && "bg-primary text-gray-50",
isHighlighted && "bg-slate-base text-gray-dark",
isToday && !isSelected && "ring-2 ring-primary",
);
return (
<div>
{isCurrentMonth ? (
<Typography color="textPrimary" className={dayClassName} variant="h6">
{calendarDay.getDay()}
</Typography>
) : (
<Typography color="textDisabled" className={dayClassName} variant="h6">
{calendarDay.getDay()}
</Typography>
)}
</div>
);
}