-
-
Notifications
You must be signed in to change notification settings - Fork 774
Expand file tree
/
Copy pathModifiersCustom.tsx
More file actions
48 lines (43 loc) · 964 Bytes
/
ModifiersCustom.tsx
File metadata and controls
48 lines (43 loc) · 964 Bytes
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
44
45
46
47
48
import React from "react";
import { type DayEventHandler, DayPicker } from "react-day-picker";
const bookedDays = [
new Date(2024, 5, 8),
new Date(2024, 5, 9),
new Date(2024, 5, 10),
{ from: new Date(2024, 5, 15), to: new Date(2024, 5, 20) },
];
const css = `
.booked {
position: relative;
}
/* Strikeout */
.booked::before {
content: "";
position: absolute;
top: 50%;
left: 0;
right: 0;
height: 2px;
background: currentColor;
z-index: 1;
transform: rotate(-45deg);
}`;
export function ModifiersCustom() {
const handleDayClick: DayEventHandler<React.MouseEvent> = (
day,
{ booked },
) => {
alert(`Day ${day.toLocaleDateString()} is booked? ${booked}`);
};
return (
<>
<style>{css}</style>
<DayPicker
defaultMonth={new Date(2024, 5)}
modifiers={{ booked: bookedDays }}
modifiersClassNames={{ booked: "booked" }}
onDayClick={handleDayClick}
/>
</>
);
}