feat(components/system): implement AnimatedView

This commit is contained in:
Walid 2023-04-23 20:13:44 +01:00
parent 508e999a0c
commit 3ae150f448
Signed by: Walidoux
GPG Key ID: CCF21881FE8BEBAF
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import type { HTMLMotionProps } from 'framer-motion'
import { AnimatePresence, motion } from 'framer-motion'
export interface AnimateViewProps extends HTMLMotionProps<'main'> {
condition: boolean
children: React.ReactNode
}
export const AnimateView: React.FC<AnimateViewProps> = ({ condition, children, ...rest }) => {
return (
<AnimatePresence>
{condition && (
<motion.main initial={rest.initial} animate={rest.animate} exit={rest.exit} {...rest}>
{children}
</motion.main>
)}
</AnimatePresence>
)
}

View File

@ -0,0 +1 @@
export * from './AnimateView'