mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 20:31:12 -05:00
feat: Implement year grid navigation
This commit is contained in:
@@ -4,14 +4,18 @@ import { DayPicker } from "react-day-picker";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { CustomCalendarCaption } from "@/components/ui/calendar-custom-caption";
|
||||
|
||||
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
||||
export type CalendarProps = React.ComponentProps<typeof DayPicker> & {
|
||||
enableYearGrid?: boolean;
|
||||
};
|
||||
|
||||
function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) {
|
||||
function Calendar({ className, classNames, showOutsideDays = true, enableYearGrid = false, ...props }: CalendarProps) {
|
||||
const captionLayout = enableYearGrid ? undefined : (props.captionLayout || "dropdown-buttons");
|
||||
return (
|
||||
<DayPicker
|
||||
showOutsideDays={showOutsideDays}
|
||||
captionLayout="dropdown-buttons"
|
||||
captionLayout={captionLayout}
|
||||
fromYear={props.fromYear || 1800}
|
||||
toYear={props.toYear || new Date().getFullYear() + 10}
|
||||
className={cn("p-3", className)}
|
||||
@@ -45,6 +49,15 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }: C
|
||||
...classNames,
|
||||
}}
|
||||
components={{
|
||||
Caption: enableYearGrid
|
||||
? (captionProps) => (
|
||||
<CustomCalendarCaption
|
||||
{...captionProps}
|
||||
fromYear={props.fromYear || 1800}
|
||||
toYear={props.toYear || new Date().getFullYear() + 10}
|
||||
/>
|
||||
)
|
||||
: undefined,
|
||||
IconLeft: ({ ..._props }) => <ChevronLeft className="h-4 w-4" />,
|
||||
IconRight: ({ ..._props }) => <ChevronRight className="h-4 w-4" />,
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user