diff --git a/src/components/calendar/Calendar.module.scss b/src/components/calendar/Calendar.module.scss index fbc12290..ec44a8c8 100644 --- a/src/components/calendar/Calendar.module.scss +++ b/src/components/calendar/Calendar.module.scss @@ -1,4 +1,5 @@ .calendar-container { + position: relative; border: 0.1rem solid $black50; border-radius: 0.8rem; } diff --git a/src/components/calendar/index.tsx b/src/components/calendar/index.tsx index b124faa9..a2987744 100644 --- a/src/components/calendar/index.tsx +++ b/src/components/calendar/index.tsx @@ -16,7 +16,7 @@ import CalendarBody from '@/components/calendar/CalendarBody'; import CalendarHeader from '@/components/calendar/CalendarHeader'; import ListBody from '@/components/calendar/ListBody'; import ModalContents from '@/components/calendar/ModalContents'; -import { CommonModal, ConfirmModal, ModalButton } from '@/components/commons/modals'; +import { CustomCommonModal, ConfirmModal, ModalButton } from '@/components/commons/modals'; import { useDeviceType } from '@/hooks/useDeviceType'; import useMultiState from '@/hooks/useMultiState'; @@ -28,7 +28,6 @@ const cx = classNames.bind(styles); const MONTH_START = 1; const MONTH_END = 12; -const BODY_OVERFLOW_HIDDEN = 'CommonModal_body-open__a3jYd'; type CalendarProps = { gameId: number; @@ -116,16 +115,22 @@ const Calendar = ({ gameId }: CalendarProps) => { toggleClick('confirmModal'); }; + const handleCloseScheduleModal = () => { + toggleClick('scheduleModal'); + }; + + const handleCloseConfirmModal = () => { + toggleClick('confirmModal'); + }; + + const handleCloseErrorModal = () => { + toggleClick('errorModal'); + }; + useEffect(() => { if (currentDeviceType !== 'PC') setIsCalendar(false); }, [currentDeviceType]); - useEffect(() => { - if (!multiState.scheduleModal) { - document.body.classList.remove(BODY_OVERFLOW_HIDDEN); - } - }, [multiState.scheduleModal]); - return ( <>
@@ -147,29 +152,29 @@ const Calendar = ({ gameId }: CalendarProps) => { ) : ( )} + {isSuccess && ( + + } + /> + )}
- {isSuccess && ( - toggleClick('scheduleModal')} - title={'예약 정보'} - isResponsive - renderContent={ - toggleClick('scheduleModal')} - onClickCardButton={handleConfirmClick} - /> - } - /> - )} toggleClick('confirmModal')} + onClose={handleCloseConfirmModal} state='CONFIRM' title={`예약 신청을 ${MY_RESERVATIONS_STATUS[reservationStatus]}하시겠습니까?`} desc={`한번 ${MY_RESERVATIONS_STATUS[reservationStatus]}한 예약은 되돌릴 수 없습니다`} @@ -178,17 +183,17 @@ const Calendar = ({ gameId }: CalendarProps) => { 확인 - toggleClick('confirmModal')}>취소 + 취소 } /> toggleClick('errorModal')} + onClose={handleCloseErrorModal} state='ERROR' title={`예약 ${MY_RESERVATIONS_STATUS[reservationStatus]}에 실패하였습니다.`} - renderButton={ toggleClick('errorModal')}>닫기} + renderButton={닫기} > ); diff --git a/src/components/commons/modals/CommonModal.module.scss b/src/components/commons/modals/CommonModal.module.scss index 4652852b..bb50532b 100644 --- a/src/components/commons/modals/CommonModal.module.scss +++ b/src/components/commons/modals/CommonModal.module.scss @@ -21,6 +21,12 @@ height: 100vh; background-color: $opacity-black-50; + + &.calendar { + position: absolute; + z-index: inherit; + height: 100%; + } } .modal { @@ -67,7 +73,7 @@ width: 100%; } - &.responsive { + &.calendar { @include responsive(T) { position: fixed; inset: 0; @@ -100,9 +106,17 @@ height: 100%; } } + + &.open { + animation: open-modal 0.3s ease-in-out forwards; + } + + &:not(.open) { + animation: close-modal 0.3s ease-in-out forwards; + } } - &:not(.responsive) { + &:not(.calendar) { .modal-mobile-nav { display: none; } @@ -112,3 +126,27 @@ .body-open { overflow: hidden; } + +@keyframes open-modal { + 0% { + top: 1rem; + opacity: 0; + } + + 100% { + top: 0; + opacity: 1; + } +} + +@keyframes close-modal { + 0% { + top: 0; + opacity: 1; + } + + 100% { + top: 1rem; + opacity: 0; + } +} diff --git a/src/components/commons/modals/CommonModal.tsx b/src/components/commons/modals/CommonModal.tsx index 635227d0..1ac9300b 100644 --- a/src/components/commons/modals/CommonModal.tsx +++ b/src/components/commons/modals/CommonModal.tsx @@ -18,10 +18,9 @@ type CommonModalProps = { onClose: MouseEventHandler; title: string; renderContent: ReactNode; - isResponsive?: boolean; }; -export const CommonModal = ({ openModal, onClose, title, renderContent, isResponsive }: CommonModalProps) => { +export const CommonModal = ({ openModal, onClose, title, renderContent }: CommonModalProps) => { return ( ; + title: string; + renderContent: ReactNode; + isCalendar: boolean; +}; + +export const CustomCommonModal = ({ openModal, onClose, title, renderContent, isCalendar }: CustomCommonModalProps) => { + const [isOpen, setIsOpen] = useState(false); + + useEffect(() => { + if (openModal) { + setIsOpen(true); + } + }, [openModal]); + + const handleAnimationEnd = () => { + if (!openModal) { + setIsOpen(false); + } + }; + + return ( + isOpen && ( +
+
+
+
+
+ +
+

{title}

+
+
{renderContent}
+
+
+
+ ) + ); +}; diff --git a/src/components/commons/modals/index.ts b/src/components/commons/modals/index.ts index 88742fd7..79e1f4c2 100644 --- a/src/components/commons/modals/index.ts +++ b/src/components/commons/modals/index.ts @@ -1,3 +1,4 @@ export * from './CommonModal'; +export * from './CustomCommonModal'; export * from './ConfirmModal'; export * from './ModalButton';