Skip to content

Commit 0c07250

Browse files
committed
feat: 모달 오픈 애니메이션 추가
1 parent d6e6c94 commit 0c07250

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/components/ui/Modal/Modal.module.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
inset: 0;
44
background-color: rgba(0, 0, 0, 0.3);
55
z-index: 99;
6+
7+
&.Open {
8+
animation: animation-show 300ms cubic-bezier(0.3, 0, 0, 1);
9+
}
610
}
711

812
.Modal {
@@ -13,4 +17,18 @@
1317
z-index: 100;
1418
background-color: var(--color-white);
1519
border-radius: 1.25rem;
20+
21+
&.Open {
22+
animation: animation-show 300ms cubic-bezier(0.3, 0, 0, 1);
23+
}
24+
}
25+
26+
@keyframes animation-show {
27+
from {
28+
opacity: 0;
29+
}
30+
31+
to {
32+
opacity: 1;
33+
}
1634
}

src/components/ui/Modal/Modal.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { PropsWithChildren } from "react";
22
import { useEffect } from "react";
33

4+
import classNames from "classnames";
5+
46
import styles from "@/components/ui/Modal/Modal.module.scss";
57
import Portal from "@/components/ui/Modal/Portal";
68

@@ -21,9 +23,19 @@ const Modal = ({ isOpen, children }: ModalProps) => {
2123
<>
2224
{isOpen && (
2325
<Portal elementId="modal">
24-
<div className={styles.ModalBackdrop} />
26+
<div
27+
className={classNames(styles.ModalBackdrop, {
28+
[styles.Open]: isOpen,
29+
})}
30+
/>
2531

26-
<div className={styles.Modal}>{children}</div>
32+
<div
33+
className={classNames(styles.Modal, {
34+
[styles.Open]: isOpen,
35+
})}
36+
>
37+
{children}
38+
</div>
2739
</Portal>
2840
)}
2941
</>

0 commit comments

Comments
 (0)