From f2ae2ff1a4d6ebd72b1b236c1811c7e7d3c75fb7 Mon Sep 17 00:00:00 2001 From: m7he4rt Date: Thu, 15 May 2025 23:27:10 -0300 Subject: [PATCH] refactor: improve calendar component styling and structure --- components/ui/calendar.tsx | 100 +++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 43 deletions(-) diff --git a/components/ui/calendar.tsx b/components/ui/calendar.tsx index 9fbf80c3..067c2805 100644 --- a/components/ui/calendar.tsx +++ b/components/ui/calendar.tsx @@ -1,65 +1,79 @@ -import * as React from "react"; -import { ChevronLeft, ChevronRight } from "lucide-react"; -import { DayPicker } from "react-day-picker"; - -import { cn } from "@/lib/utils"; -import { buttonVariants } from "@/components/ui/button"; - -export type CalendarProps = React.ComponentProps; +import { buttonVariants } from '@/components/ui/button' +import { cn } from '@/lib/utils' +import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react' +import type { ComponentProps } from 'react' +import { DayPicker } from 'react-day-picker' function Calendar({ className, classNames, showOutsideDays = true, ...props -}: CalendarProps) { +}: ComponentProps) { return ( button]:bg-primary [&>button]:text-primary-foreground [&>button]:hover:bg-primary [&>button]:hover:text-primary-foreground', + range_end: + 'day-range-end !bg-accent rounded-r-md [&>button]:bg-primary [&>button]:text-primary-foreground [&>button]:hover:bg-primary [&>button]:hover:text-primary-foreground', + range_middle: + 'aria-selected:bg-accent aria-selected:text-accent-foreground', day_selected: - "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground", - day_today: "bg-accent text-accent-foreground", + 'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground', + day_today: 'bg-accent text-accent-foreground', day_outside: - "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30", - day_disabled: "text-muted-foreground opacity-50", - day_range_middle: - "aria-selected:bg-accent aria-selected:text-accent-foreground", - day_hidden: "invisible", + 'day-outside text-muted-foreground aria-selected:text-muted-foreground', + day_disabled: 'text-muted-foreground opacity-50', + day_hidden: 'invisible', + selected: + 'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground', + today: 'bg-accent text-accent-foreground', + outside: + 'day-outside text-muted-foreground opacity-50 !aria-selected:bg-accent/50 !aria-selected:text-muted-foreground !aria-selected:opacity-30', + disabled: 'text-muted-foreground opacity-50', + hidden: 'invisible', ...classNames, }} components={{ - // @ts-expect-error: owned by shadcn - IconLeft: ({ ..._props }) => , - IconRight: ({ ..._props }) => , + Chevron: ({ ...props }) => + props.orientation === 'left' ? ( + + ) : ( + + ), }} {...props} /> - ); + ) } -Calendar.displayName = "Calendar"; +Calendar.displayName = 'Calendar' -export { Calendar }; +export { Calendar }