diff --git a/src/components/chat/ChatDock.tsx b/src/components/chat/ChatDock.tsx index 374bd4f..f0a78c2 100644 --- a/src/components/chat/ChatDock.tsx +++ b/src/components/chat/ChatDock.tsx @@ -4,11 +4,11 @@ import { useState } from 'react'; import ChatPanel from './ChatPanel'; const ChatDock = () => { - const [isOpen, setIsOpen] = useState(false) + const [isOpen, setIsOpen] = useState(false); return (
- { isOpen && } + {isOpen && } - -
- { /* chat bubbles etc */ } - chat stuff here -
+ setIsOpen(false)} /> + + ); }; diff --git a/src/components/chat/components/ChatBubble.tsx b/src/components/chat/components/ChatBubble.tsx new file mode 100644 index 0000000..d23c5dc --- /dev/null +++ b/src/components/chat/components/ChatBubble.tsx @@ -0,0 +1,35 @@ +import { formatMessageTime } from '../util'; +import type { ChatMessage } from '../types'; + +interface ChatBubbleProps { + message: ChatMessage; +} + +const ChatBubble = ({ message }: ChatBubbleProps) => { + const isUser = message.sender === 'user'; + + return ( +
+
+

{message.text}

+

+ {formatMessageTime(message.sentAt)} +

+
+
+ ); +}; + +export default ChatBubble; diff --git a/src/components/chat/components/ChatHeader.tsx b/src/components/chat/components/ChatHeader.tsx new file mode 100644 index 0000000..ef696c7 --- /dev/null +++ b/src/components/chat/components/ChatHeader.tsx @@ -0,0 +1,25 @@ +import { X } from 'lucide-react'; + +interface ChatHeaderProps { + onClose: () => void; +} + +const ChatHeader = ({ onClose }: ChatHeaderProps) => { + return ( +
+
+

Chat

+

Ask questions

+
+ +
+ ); +}; + +export default ChatHeader; diff --git a/src/components/chat/components/ChatInput.tsx b/src/components/chat/components/ChatInput.tsx new file mode 100644 index 0000000..4bb2886 --- /dev/null +++ b/src/components/chat/components/ChatInput.tsx @@ -0,0 +1,59 @@ +import { useLayoutEffect, useRef } from 'react'; +import type { SubmitEventHandler } from 'react'; +import { Send } from 'lucide-react'; + +interface ChatInputProps { + draft: string; + onDraftChange: (value: string) => void; + onSend: SubmitEventHandler; +} + +const ChatInput = ({ draft, onDraftChange, onSend }: ChatInputProps) => { + const textareaRef = useRef(null); + + useLayoutEffect(() => { + if (!textareaRef.current) { + return; + } + + const maxHeight = 112; + textareaRef.current.style.height = '0px'; + const nextHeight = Math.min(textareaRef.current.scrollHeight, maxHeight); + textareaRef.current.style.height = `${nextHeight}px`; + textareaRef.current.style.overflowY = textareaRef.current.scrollHeight > maxHeight ? 'auto' : 'hidden'; + }, [draft]); + + return ( +
+
+