From 891ee85fa6e5aa109e097443df6bd0b462096677 Mon Sep 17 00:00:00 2001 From: balibabu Date: Wed, 12 Feb 2025 19:32:49 +0800 Subject: [PATCH] Feat: Add ChatInput component #3221 (#4915) ### What problem does this PR solve? Feat: Add ChatInput component #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/components/chat-input.tsx | 46 +++++++++++++++++++ web/src/components/ui/textarea.tsx | 2 +- .../next-chats/chat/app-settings/index.tsx | 11 ++++- web/src/pages/next-chats/chat/chat-box.tsx | 8 +++- web/tailwind.config.js | 1 + web/tailwind.css | 5 +- 6 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 web/src/components/chat-input.tsx diff --git a/web/src/components/chat-input.tsx b/web/src/components/chat-input.tsx new file mode 100644 index 000000000..246385b2b --- /dev/null +++ b/web/src/components/chat-input.tsx @@ -0,0 +1,46 @@ +import { useEventListener } from 'ahooks'; +import { Mic, Paperclip, Send } from 'lucide-react'; +import { useRef, useState } from 'react'; +import { Button } from './ui/button'; +import { Textarea } from './ui/textarea'; + +export function ChatInput() { + const textareaRef = useRef(null); + const [textareaHeight, setTextareaHeight] = useState(40); + + useEventListener( + 'keydown', + (ev) => { + if (ev.shiftKey && ev.code === 'Enter') { + setTextareaHeight((h) => { + return h + 10; + }); + } + }, + { + target: textareaRef, + }, + ); + + return ( +
+ +