Merge branch 'rust-dev'
This commit is contained in:
commit
995cfbd9b0
13 changed files with 958 additions and 123 deletions
|
|
@ -3,7 +3,7 @@ import DownButton from "src/components/ui/button/down-button";
|
|||
import { motion } from "motion/react";
|
||||
import { BotMessageSquare } from "lucide-react";
|
||||
|
||||
export default function MessageInput({ onSend, onMessage }) {
|
||||
export default function MessageInput({ onSend, disabled = false }) {
|
||||
const [text, setText] = useState("");
|
||||
const textareaRef = useRef(null);
|
||||
|
||||
|
|
@ -14,9 +14,7 @@ export default function MessageInput({ onSend, onMessage }) {
|
|||
|
||||
async function handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
if (!text.trim()) return;
|
||||
|
||||
// send user message locally
|
||||
if (!text.trim() || disabled) return;
|
||||
onSend(text.trim());
|
||||
|
||||
// create query on backend
|
||||
|
|
@ -79,6 +77,7 @@ export default function MessageInput({ onSend, onMessage }) {
|
|||
ref={textareaRef}
|
||||
value={text}
|
||||
onChange={(e) => {
|
||||
if (disabled) return;
|
||||
setText(e.target.value);
|
||||
// auto-resize
|
||||
const ta = textareaRef.current;
|
||||
|
|
@ -97,12 +96,17 @@ export default function MessageInput({ onSend, onMessage }) {
|
|||
placeholder="Type a message..."
|
||||
rows={1}
|
||||
className="flex-1 mx-2 rounded-md shadow-2sx border-none focus:border-none focus:outline-none resize-none overflow-auto max-h-40"
|
||||
disabled={disabled}
|
||||
/>
|
||||
<motion.button
|
||||
type="submit"
|
||||
className="flex gap-2 px-4 py-2 bg-gray-700 rounded-xl ml-4 items-center"
|
||||
whileHover={{ scale: 1.1 }}
|
||||
whileTap={{ scale: 0.9 }}
|
||||
className={`flex gap-2 px-4 py-2 bg-gray-700 rounded-xl ml-4 items-center ${
|
||||
disabled ? "cursor-not-allowed" : ""
|
||||
}`}
|
||||
whileHover={disabled ? undefined : { scale: 1.1 }}
|
||||
whileTap={disabled ? undefined : { scale: 0.9 }}
|
||||
disabled={disabled}
|
||||
style={{ opacity: disabled ? 0.5 : 1 }}
|
||||
>
|
||||
<BotMessageSquare />
|
||||
</motion.button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue