22
33import * as React from "react" ;
44import { ChevronLeftIcon , ChevronRightIcon } from "@heroicons/react/20/solid" ;
5+ import { format } from "date-fns" ;
56import { DayPicker } from "react-day-picker" ;
67import { cn } from "~/utils/cn" ;
78
89export type CalendarProps = React . ComponentProps < typeof DayPicker > ;
910
10- function Calendar ( { className, classNames, showOutsideDays = true , ...props } : CalendarProps ) {
11+ export function Calendar ( {
12+ className,
13+ classNames,
14+ showOutsideDays = true ,
15+ ...props
16+ } : CalendarProps ) {
1117 return (
1218 < DayPicker
1319 showOutsideDays = { showOutsideDays }
@@ -16,12 +22,12 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }: C
1622 months : "flex flex-col sm:flex-row gap-2" ,
1723 month : "flex flex-col gap-4" ,
1824 month_caption : "flex justify-center pt-1 relative items-center w-full" ,
19- caption_label : "text-sm font-medium text-text-bright " ,
20- nav : "flex items-center gap-1 " ,
25+ caption_label : "sr-only " ,
26+ nav : "flex items-center justify-between w-full absolute inset-x-0 top-1 px-3 " ,
2127 button_previous :
22- "absolute left-1 top-0 size-7 bg-transparent p-0 text-text-dimmed hover:text-text-bright transition-colors flex items-center justify-center" ,
28+ "size-6 rounded-[3px] bg-secondary border border-charcoal-600 text-text-bright hover:bg-charcoal-600 hover:border-charcoal-550 transition inline- flex items-center justify-center" ,
2329 button_next :
24- "absolute right-1 top-0 size-7 bg-transparent p-0 text-text-dimmed hover:text-text-bright transition-colors flex items-center justify-center" ,
30+ "size-6 rounded-[3px] bg-secondary border border-charcoal-600 text-text-bright hover:bg-charcoal-600 hover:border-charcoal-550 transition inline- flex items-center justify-center" ,
2531 month_grid : "w-full border-collapse" ,
2632 weekdays : "flex" ,
2733 weekday : "text-text-dimmed rounded-md w-8 font-normal text-[0.8rem]" ,
@@ -56,10 +62,11 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }: C
5662 return < ChevronRightIcon className = "size-4" /> ;
5763 } ,
5864 } }
65+ formatters = { {
66+ formatMonthDropdown : ( date ) => format ( date , "MMM" ) ,
67+ } }
5968 { ...props }
6069 />
6170 ) ;
6271}
6372Calendar . displayName = "Calendar" ;
64-
65- export { Calendar } ;
0 commit comments