🔧 chore: use framer-motion

This commit is contained in:
Andre H 2024-02-22 14:22:29 +07:00
parent c8a153ad27
commit 1cd60d84dd

View File

@ -1,6 +1,7 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import * as ToastPrimitive from '@radix-ui/react-toast'; import * as ToastPrimitive from '@radix-ui/react-toast';
import { ToastProps } from '@radix-ui/react-toast'; import { ToastProps } from '@radix-ui/react-toast';
import { motion } from 'framer-motion';
import { simpleToastTheme, type SimpleToastTheme } from './SimpleToast.theme'; import { simpleToastTheme, type SimpleToastTheme } from './SimpleToast.theme';
import { import {
LoadingIcon, LoadingIcon,
@ -11,7 +12,6 @@ import {
} from 'components/shared/CustomIcon'; } from 'components/shared/CustomIcon';
import { Button, ButtonBaseProps, ButtonTheme } from 'components/shared/Button'; import { Button, ButtonBaseProps, ButtonTheme } from 'components/shared/Button';
import { cloneIcon } from 'utils/cloneIcon'; import { cloneIcon } from 'utils/cloneIcon';
import { cn } from 'utils/classnames';
interface CtaProps extends ButtonBaseProps, ButtonTheme { interface CtaProps extends ButtonBaseProps, ButtonTheme {
buttonLabel: string; buttonLabel: string;
@ -72,14 +72,22 @@ export const SimpleToast = ({
return ( return (
<ToastPrimitive.Root {...props} asChild> <ToastPrimitive.Root {...props} asChild>
<div className={wrapperCls({ class: cn(className) })}> <motion.li
animate={{
y: 'var(--radix-toast-swipe-move-y, 0)',
opacity: 1,
}}
className={wrapperCls({ class: className })}
exit={{ y: '100%', opacity: 0 }}
initial={{ y: '100%', opacity: 0 }}
>
{cloneIcon(Icon, { className: iconCls() })} {cloneIcon(Icon, { className: iconCls() })}
<ToastPrimitive.Title asChild> <ToastPrimitive.Title asChild>
<p className={titleCls()}>{title}</p> <p className={titleCls()}>{title}</p>
</ToastPrimitive.Title> </ToastPrimitive.Title>
{renderCta} {renderCta}
{renderCloseButton} {renderCloseButton}
</div> </motion.li>
</ToastPrimitive.Root> </ToastPrimitive.Root>
); );
}; };