11import * as React from "react" ;
22import { ChevronLeft , ChevronRight } from "lucide-react" ;
3+ import { motion } from "framer-motion" ;
34
45import { cn } from "@/lib/utils" ;
56
@@ -58,7 +59,10 @@ const DatePicker = React.forwardRef<HTMLDivElement, DatePickerProps>(
5859
5960 for ( let day = 1 ; day <= daysInCurrentMonth ; day ++ ) {
6061 days . push (
61- < div
62+ < motion . div
63+ initial = { { opacity : 0 } }
64+ animate = { { opacity : 1 } }
65+ transition = { { delay : 0.01 * day } }
6266 key = { day }
6367 className = { cn (
6468 "grid-item place-self-center cursor-pointer rounded-lg w-[30px] h-[30px] flex items-center justify-center hover:bg-primary/30 transition-colors" ,
@@ -72,7 +76,7 @@ const DatePicker = React.forwardRef<HTMLDivElement, DatePickerProps>(
7276 onClick = { ( ) => handleDateClick ( day ) }
7377 >
7478 { day }
75- </ div >
79+ </ motion . div >
7680 ) ;
7781 }
7882
@@ -89,24 +93,47 @@ const DatePicker = React.forwardRef<HTMLDivElement, DatePickerProps>(
8993 { ...props }
9094 >
9195 < div className = "flex flex-row items-center gap-2 mb-2" >
92- < ChevronLeft
93- onClick = { handlePrevMonth }
94- className = "cursor-pointer rounded-md border-2 hover:bg-primary/30 hover:border-0 transition-colors"
95- />
96- < span className = "flex text-lg font-bold text-center" >
96+ < motion . div
97+ initial = { { opacity : 0 , x : - 10 } }
98+ animate = { { opacity : 1 , x : 0 } }
99+ transition = { { delay : 0.01 } }
100+ >
101+ < ChevronLeft
102+ onClick = { handlePrevMonth }
103+ className = "cursor-pointer rounded-md border-2 hover:bg-primary/30 hover:border-0 transition-colors"
104+ />
105+ </ motion . div >
106+ < motion . span
107+ initial = { { opacity : 0 , y : - 10 } }
108+ animate = { { opacity : 1 , y : 0 } }
109+ transition = { { delay : 0.01 } }
110+ className = "flex text-lg font-bold text-center"
111+ >
97112 { currentDate . toLocaleString ( "default" , { month : "long" } ) } { " " }
98113 { currentDate . getFullYear ( ) }
99- </ span >
100- < ChevronRight
101- onClick = { handleNextMonth }
102- className = "cursor-pointer rounded-md border-2 hover:bg-primary/30 hover:border-0 transition-colors"
103- />
114+ </ motion . span >
115+ < motion . div
116+ initial = { { opacity : 0 , x : 10 } }
117+ animate = { { opacity : 1 , x : 0 } }
118+ transition = { { delay : 0.01 } }
119+ >
120+ < ChevronRight
121+ onClick = { handleNextMonth }
122+ className = "cursor-pointer rounded-md border-2 hover:bg-primary/30 hover:border-0 transition-colors"
123+ />
124+ </ motion . div >
104125 </ div >
105126 < div className = "h-full w-full grid grid-cols-7 gap-1 p-2" >
106127 { [ "S" , "M" , "T" , "W" , "T" , "F" , "S" ] . map ( ( date , index ) => (
107- < div key = { `${ date } -${ index } ` } className = "grid-item place-self-center" >
128+ < motion . div
129+ initial = { { opacity : 0 } }
130+ animate = { { opacity : 1 } }
131+ transition = { { delay : 0.01 * index } }
132+ className = "grid-item place-self-center"
133+ key = { `${ date } -${ index } ` }
134+ >
108135 { date }
109- </ div >
136+ </ motion . div >
110137 ) ) }
111138 { renderDays ( ) }
112139 </ div >
0 commit comments