mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
import { AnimatePresence, cubicBezier, motion } from 'framer-motion';
|
|
|
|
interface SendButtonProps {
|
|
show: boolean;
|
|
fixBug: boolean;
|
|
isStreaming?: boolean;
|
|
disabled?: boolean;
|
|
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
onImagesSelected?: (images: File[]) => void;
|
|
}
|
|
|
|
const customEasingFn = cubicBezier(0.4, 0, 0.2, 1);
|
|
|
|
export const SendButton = ({ show, fixBug, isStreaming, disabled, onClick }: SendButtonProps) => {
|
|
const className = fixBug
|
|
? "absolute flex justify-center items-center top-[18px] right-[60px] p-1 bg-accent-500 hover:brightness-94 color-white rounded-md w-[34px] h-[34px] transition-theme disabled:opacity-50 disabled:cursor-not-allowed"
|
|
: "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 disabled:opacity-50 disabled:cursor-not-allowed";
|
|
|
|
// Determine tooltip text based on button state
|
|
const tooltipText = fixBug
|
|
? "Fix Bug"
|
|
: isStreaming
|
|
? "Stop Generation"
|
|
: "Make Improvement";
|
|
|
|
return (
|
|
<AnimatePresence>
|
|
{show ? (
|
|
<motion.button
|
|
className={className}
|
|
title={tooltipText}
|
|
transition={{ ease: customEasingFn, duration: 0.17 }}
|
|
initial={{ opacity: 0, y: 10 }}
|
|
animate={{ opacity: 1, y: 0 }}
|
|
exit={{ opacity: 0, y: 10 }}
|
|
disabled={disabled}
|
|
onClick={(event) => {
|
|
event.preventDefault();
|
|
|
|
if (!disabled) {
|
|
onClick?.(event);
|
|
}
|
|
}}
|
|
>
|
|
<div className="text-lg">
|
|
{fixBug
|
|
? <div className="i-ph:bug-fill"></div>
|
|
: !isStreaming
|
|
? <div className="i-ph:hand-fill"></div>
|
|
: <div className="i-ph:stop-circle-bold"></div>}
|
|
</div>
|
|
</motion.button>
|
|
) : null}
|
|
</AnimatePresence>
|
|
);
|
|
};
|