mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 00:44:14 +00:00
style: add animation to modal
This commit is contained in:
parent
37a0736a0e
commit
7823dc7ff4
1 changed files with 21 additions and 4 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import { AnimatePresence } from 'framer-motion';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import { IoClose } from 'react-icons/io5/index';
|
||||
|
||||
import { fade, mix, slideY } from '@/lib/motion';
|
||||
|
||||
import styles from './modal.module.css';
|
||||
|
||||
interface ModalProps {
|
||||
|
|
@ -10,23 +12,38 @@ interface ModalProps {
|
|||
}
|
||||
|
||||
export function Modal({ children, onClose, show }: ModalProps) {
|
||||
const variants = {
|
||||
modal: mix(fade(), slideY(20)),
|
||||
overlay: fade(),
|
||||
};
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{show && (
|
||||
<>
|
||||
<div
|
||||
<motion.div
|
||||
animate="show"
|
||||
className={styles.overlay}
|
||||
exit="hidden"
|
||||
initial="hidden"
|
||||
variants={variants.overlay}
|
||||
onClick={onClose}
|
||||
onKeyDown={onClose}
|
||||
/>
|
||||
<div className={styles.modal}>
|
||||
<div className={styles.content}>
|
||||
<motion.div
|
||||
animate="show"
|
||||
className={styles.content}
|
||||
exit="hidden"
|
||||
initial="hidden"
|
||||
variants={variants.modal}
|
||||
>
|
||||
<button className={styles.close} onClick={onClose}>
|
||||
<IoClose />
|
||||
</button>
|
||||
|
||||
{children}
|
||||
</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue