mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
99aceefb9e
react-bootstrap → migrate to shadcn/ui + Tailwind (or HeroUI) Legacy, ~250KB bundle, dated API, inconsistent with CMS stack react-transition-group → use framer-motion (already installed!) De-facto deprecated, duplicate animation lib
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { AnimatePresence, motion, Variants } from 'framer-motion';
|
|
import { FC, ReactNode } from 'react';
|
|
import { getTransitionVariants } from './TransitionAnimationStyles';
|
|
|
|
interface TransitionAnimationProps
|
|
{
|
|
type: string;
|
|
inProp: boolean;
|
|
timeout?: number;
|
|
className?: string;
|
|
children?: ReactNode;
|
|
}
|
|
|
|
export const TransitionAnimation: FC<TransitionAnimationProps> = props =>
|
|
{
|
|
const { type = null, inProp = false, timeout = 300, className = null, children = null } = props;
|
|
|
|
const variants: Variants = getTransitionVariants(type);
|
|
const duration = timeout / 1000;
|
|
|
|
return (
|
|
<AnimatePresence initial={ false }>
|
|
{ inProp && (
|
|
<motion.div
|
|
className={ className ?? '' }
|
|
variants={ variants }
|
|
initial="hidden"
|
|
animate="visible"
|
|
exit="exit"
|
|
transition={ { duration } }>
|
|
{ children }
|
|
</motion.div>
|
|
) }
|
|
</AnimatePresence>
|
|
);
|
|
};
|