From 73b7631d8639741e70f2fb85b0af6ac09052cacf Mon Sep 17 00:00:00 2001 From: KANAMORI Yu Date: Mon, 18 Mar 2024 16:45:23 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Calendar=20=E3=81=AE=E6=97=A5=E4=BB=98?= =?UTF-8?q?=E9=81=B8=E6=8A=9E=E9=A0=98=E5=9F=9F=E3=81=AE=E3=82=B9=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=AA=E3=83=B3=E3=82=B0=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20(#4421)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Calendar/CalendarTable.tsx | 109 +++++++++++----------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/src/components/Calendar/CalendarTable.tsx b/src/components/Calendar/CalendarTable.tsx index af7fad8a8c..cbd28c28ef 100644 --- a/src/components/Calendar/CalendarTable.tsx +++ b/src/components/Calendar/CalendarTable.tsx @@ -22,8 +22,8 @@ type ElementProps = Omit, keyof Props> const calendarTable = tv({ slots: { - table: - 'smarthr-ui-CalendarTable shr-border-spacing-0 shr-px-0.75 shr-pb-1 shr-pt-0.25 shr-text-base shr-text-black', + wrapper: 'shr-px-0.75 shr-pb-1 shr-pt-0.25', + table: 'smarthr-ui-CalendarTable shr-border-spacing-0 shr-text-base shr-text-black', th: 'smarthr-ui-CalendarTable-headCell shr-px-0 shr-py-0.5 shr-text-center shr-align-middle shr-font-normal shr-text-grey', td: 'smarthr-ui-CalendarTable-dataCell shr-p-0 shr-align-middle', cellButton: @@ -54,15 +54,16 @@ export const CalendarTable: FC = ({ className, ...props }) => { - const { table, th, td, cellButton, dateCell } = calendarTable() - const { tableStyle, thStyle, tdStyle, cellButtonStyle } = useMemo( + const { wrapper, table, th, td, cellButton, dateCell } = calendarTable() + const { wrapperStyle, tableStyle, thStyle, tdStyle, cellButtonStyle } = useMemo( () => ({ - tableStyle: table({ className }), + wrapperStyle: wrapper({ className }), + tableStyle: table(), thStyle: th(), tdStyle: td(), cellButtonStyle: cellButton(), }), - [cellButton, className, table, td, th], + [cellButton, className, table, td, th, wrapper], ) const currentDay = dayjs(current) const selectedDay = selected ? dayjs(selected) : null @@ -73,53 +74,55 @@ export const CalendarTable: FC = ({ const array = getMonthArray(currentDay.toDate()) return ( - - - - {daysInWeek.map((day, i) => ( - - ))} - - - - {array.map((week, weekIndex) => ( - - {week.map((date, dateIndex) => { - const isOutRange = - !date || - !isBetween(currentDay.date(date).toDate(), fromDay.toDate(), toDay.toDate()) - const isSelectedDate = - !!date && !!selectedDay && currentDay.date(date).isSame(selectedDay, 'date') - return ( - - ) - })} +
+
- {day} -
- {date && ( - - !isOutRange && onSelectDate(e, currentDay.date(date).toDate()) - } - aria-pressed={isSelectedDate} - type="button" - className={cellButtonStyle} - > - - {date} - - - )} -
+ + + {daysInWeek.map((day, i) => ( + + ))} - ))} - -
+ {day} +
+ + + {array.map((week, weekIndex) => ( + + {week.map((date, dateIndex) => { + const isOutRange = + !date || + !isBetween(currentDay.date(date).toDate(), fromDay.toDate(), toDay.toDate()) + const isSelectedDate = + !!date && !!selectedDay && currentDay.date(date).isSame(selectedDay, 'date') + return ( + + {date && ( + + !isOutRange && onSelectDate(e, currentDay.date(date).toDate()) + } + aria-pressed={isSelectedDate} + type="button" + className={cellButtonStyle} + > + + {date} + + + )} + + ) + })} + + ))} + + + ) }