nielsr HF staff commited on
Commit
6520b36
·
1 Parent(s): 3e3e154

Only display days of a month

Browse files
src/components/ui/calendar.tsx CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import * as React from "react";
3
  import { ChevronLeft, ChevronRight } from "lucide-react";
4
  import { DayPicker } from "react-day-picker";
@@ -44,8 +43,7 @@ function Calendar({
44
  day_selected:
45
  "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
46
  day_today: "bg-accent text-accent-foreground",
47
- day_outside:
48
- "hidden",
49
  day_disabled: "text-muted-foreground opacity-50",
50
  day_range_middle:
51
  "aria-selected:bg-accent aria-selected:text-accent-foreground",
 
 
1
  import * as React from "react";
2
  import { ChevronLeft, ChevronRight } from "lucide-react";
3
  import { DayPicker } from "react-day-picker";
 
43
  day_selected:
44
  "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
45
  day_today: "bg-accent text-accent-foreground",
46
+ day_outside: "opacity-0 pointer-events-none hidden",
 
47
  day_disabled: "text-muted-foreground opacity-50",
48
  day_range_middle:
49
  "aria-selected:bg-accent aria-selected:text-accent-foreground",
src/pages/Calendar.tsx CHANGED
@@ -331,24 +331,30 @@ const CalendarPage = () => {
331
  showOutsideDays={false}
332
  className="bg-white rounded-lg p-6 shadow-sm mx-auto w-full"
333
  components={{
334
- Day: ({ date, ...props }) => (
335
- <button {...props} className="w-full h-full p-2">
336
- {renderDayContent(date)}
337
- </button>
338
- ),
 
 
 
 
 
 
339
  }}
340
  classNames={{
341
  months: `grid ${isYearView ? 'grid-cols-3 gap-4' : ''} justify-center`,
342
  month: "space-y-4",
343
  caption: "flex justify-center pt-1 relative items-center mb-4",
344
  caption_label: "text-lg font-semibold",
345
- table: "w-full border-collapse space-y-1",
346
  head_row: "flex",
347
  head_cell: "text-muted-foreground rounded-md w-10 font-normal text-[0.8rem]",
348
  row: "flex w-full mt-2",
349
  cell: "h-10 w-10 text-center text-sm p-0 relative focus-within:relative focus-within:z-20 hover:bg-neutral-50",
350
  day: "h-10 w-10 p-0 font-normal hover:bg-neutral-100 rounded-lg transition-colors",
351
  day_today: "bg-neutral-100 text-primary font-semibold",
 
352
  nav: "space-x-1 flex items-center",
353
  nav_button: "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
354
  nav_button_previous: "absolute left-1",
 
331
  showOutsideDays={false}
332
  className="bg-white rounded-lg p-6 shadow-sm mx-auto w-full"
333
  components={{
334
+ Day: ({ date, ...props }) => {
335
+ const isOutsideDay = date.getMonth() !== props.displayMonth.getMonth();
336
+ if (isOutsideDay) {
337
+ return null;
338
+ }
339
+ return (
340
+ <button {...props} className="w-full h-full p-2">
341
+ {renderDayContent(date)}
342
+ </button>
343
+ );
344
+ },
345
  }}
346
  classNames={{
347
  months: `grid ${isYearView ? 'grid-cols-3 gap-4' : ''} justify-center`,
348
  month: "space-y-4",
349
  caption: "flex justify-center pt-1 relative items-center mb-4",
350
  caption_label: "text-lg font-semibold",
 
351
  head_row: "flex",
352
  head_cell: "text-muted-foreground rounded-md w-10 font-normal text-[0.8rem]",
353
  row: "flex w-full mt-2",
354
  cell: "h-10 w-10 text-center text-sm p-0 relative focus-within:relative focus-within:z-20 hover:bg-neutral-50",
355
  day: "h-10 w-10 p-0 font-normal hover:bg-neutral-100 rounded-lg transition-colors",
356
  day_today: "bg-neutral-100 text-primary font-semibold",
357
+ day_outside: "hidden",
358
  nav: "space-x-1 flex items-center",
359
  nav_button: "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
360
  nav_button_previous: "absolute left-1",