Skip to content

Commit

Permalink
Merge pull request #247 from DNDACADEMY/develop
Browse files Browse the repository at this point in the history
style: 모달 아래서 위로 뜨는 애니메이션 추가 (#246)
  • Loading branch information
saseungmin authored Nov 30, 2024
2 parents eb064d5 + c380c55 commit 1940583
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@
justify-content: center;
background: rgb(0 0 0 / 40%);
transition: visibility 0.2s ease-out;
visibility: hidden;
display: none;
display: flex;

@include xs {
align-items: flex-end;
}

&.open {
visibility: visible;
display: flex;
}

.modalBox {
color: color('gray09');
background-color: color('white');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ReactElement, useRef } from 'react';

import { Button } from '@dnd-academy/ui';
import clsx from 'clsx';
import { AnimatePresence, motion } from 'motion/react';
import { useOnClickOutside, useScrollLock } from 'usehooks-ts';

import GlobalPortal from '@/components/global/GlobalPortal';
Expand All @@ -25,26 +26,42 @@ function ModalContentsBase({ children: child, title, size = 'medium' } : Props)

return (
<GlobalPortal>
{open && (
<div className={clsx(styles.modalWrapper, open && styles.open)}>
<div
ref={modalContentsRef}
role="dialog"
className={clsx(styles.modalBox, styles[size])}
<AnimatePresence>
{open && (
<motion.div
className={clsx(styles.modalWrapper)}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<div className={styles.header}>
<h1 className={styles.title}>{title}</h1>
<Button
type="button"
className={styles.closeButton}
onClick={() => toggle(false)}
icon={<CloseIcon />}
/>
</div>
{child}
</div>
</div>
)}
<motion.div
ref={modalContentsRef}
role="dialog"
className={clsx(styles.modalBox, styles[size])}
initial={{ y: 50, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
exit={{ y: 50, opacity: 0 }}
transition={{
type: 'spring',
stiffness: 300,
damping: 30,
duration: 0.3,
}}
>
<div className={styles.header}>
<h1 className={styles.title}>{title}</h1>
<Button
type="button"
className={styles.closeButton}
onClick={() => toggle(false)}
icon={<CloseIcon />}
/>
</div>
{child}
</motion.div>
</motion.div>
)}
</AnimatePresence>
</GlobalPortal>
);
}
Expand Down

0 comments on commit 1940583

Please sign in to comment.