2024-07-10 16:44:39 +00:00
|
|
|
import { AnimatePresence, cubicBezier, motion } from 'framer-motion';
|
|
|
|
|
|
|
|
interface SendButtonProps {
|
|
|
|
show: boolean;
|
2024-07-18 09:10:12 +00:00
|
|
|
isStreaming?: boolean;
|
2024-07-25 15:28:23 +00:00
|
|
|
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
2024-07-10 16:44:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const customEasingFn = cubicBezier(0.4, 0, 0.2, 1);
|
|
|
|
|
2024-07-18 09:10:12 +00:00
|
|
|
export function SendButton({ show, isStreaming, onClick }: SendButtonProps) {
|
2024-07-10 16:44:39 +00:00
|
|
|
return (
|
|
|
|
<AnimatePresence>
|
|
|
|
{show ? (
|
|
|
|
<motion.button
|
2024-08-08 13:56:36 +00:00
|
|
|
className="absolute flex justify-center items-center top-[18px] right-[22px] p-1 bg-accent-500 hover:brightness-94 color-white rounded-md w-[34px] h-[34px] transition-theme"
|
2024-07-10 16:44:39 +00:00
|
|
|
transition={{ ease: customEasingFn, duration: 0.17 }}
|
|
|
|
initial={{ opacity: 0, y: 10 }}
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
exit={{ opacity: 0, y: 10 }}
|
|
|
|
onClick={(event) => {
|
|
|
|
event.preventDefault();
|
2024-07-25 15:28:23 +00:00
|
|
|
onClick?.(event);
|
2024-07-10 16:44:39 +00:00
|
|
|
}}
|
|
|
|
>
|
2024-07-18 09:10:12 +00:00
|
|
|
<div className="text-lg">
|
|
|
|
{!isStreaming ? <div className="i-ph:arrow-right"></div> : <div className="i-ph:stop-circle-bold"></div>}
|
|
|
|
</div>
|
2024-07-10 16:44:39 +00:00
|
|
|
</motion.button>
|
|
|
|
) : null}
|
|
|
|
</AnimatePresence>
|
|
|
|
);
|
|
|
|
}
|