feat(components/system): implement AnimatedView
This commit is contained in:
parent
508e999a0c
commit
3ae150f448
19
src/components/system/AnimateView/AnimateView.tsx
Normal file
19
src/components/system/AnimateView/AnimateView.tsx
Normal 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>
|
||||
)
|
||||
}
|
1
src/components/system/AnimateView/index.ts
Normal file
1
src/components/system/AnimateView/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './AnimateView'
|
Loading…
Reference in New Issue
Block a user