Skip to content

Commit 91f0a3e

Browse files
committed
Plan chat inclusion
1 parent a251bb7 commit 91f0a3e

File tree

2 files changed

+143
-1
lines changed

2 files changed

+143
-1
lines changed
Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,125 @@
1+
import HeaderTools from "@/coral/components/Header/HeaderTools";
2+
import { Send } from "@/coral/imports/bundleicons";
3+
import ChatInput from "@/coral/modules/ChatInput";
4+
import remarkGfm from "remark-gfm";
5+
import rehypePrism from "rehype-prism";
16
import { PlanChatProps } from "@/models";
7+
import { Body1, Button, Tag, ToolbarDivider } from "@fluentui/react-components";
8+
import { ChatDismiss20Regular, HeartRegular } from "@fluentui/react-icons";
9+
import { useRef, useState } from "react";
10+
import ReactMarkdown from "react-markdown";
11+
import "../../styles/Chat.css"; // Assuming you have a CSS file for additional styles
12+
import "../../styles/PlanChat.css"; // Assuming you have a CSS file for additional styles
213

314
const PlanChat: React.FC<PlanChatProps> = ({
415
planData,
516
OnChatSubmit
617
}) => {
18+
const [messages, setMessages] = useState<{ role: string; content: string }[]>([]);
19+
const [input, setInput] = useState("");
20+
const [isTyping, setIsTyping] = useState(false);
21+
const [showScrollButton, setShowScrollButton] = useState(false);
22+
const [inputHeight, setInputHeight] = useState(0);
23+
const [currentConversationId, setCurrentConversationId] = useState<string | undefined>(undefined);
724

8-
return (<> </>);
25+
const messagesContainerRef = useRef<HTMLDivElement>(null);
26+
const inputContainerRef = useRef<HTMLDivElement>(null);
27+
const sendMessage = async () => {
28+
};
29+
const scrollToBottom = () => {
30+
};
31+
const clearChat = async () => {
32+
setMessages([]);
33+
setInput("");
34+
setCurrentConversationId(undefined);
35+
};
36+
return (
37+
<div className="chat-container">
38+
<div className="messages" ref={messagesContainerRef}>
39+
<div className="message-wrapper">
40+
{messages.map((msg, index) => (<div key={index} className={`message ${msg.role}`}>
41+
<Body1>
42+
<div className="plan-chat-message-content">
43+
<ReactMarkdown remarkPlugins={[remarkGfm]} rehypePlugins={[rehypePrism]}>
44+
{msg.content}
45+
</ReactMarkdown>
46+
{/* {msg.role === "assistant" && (
47+
<div className="assistant-footer">
48+
<div className="assistant-actions">
49+
<Button
50+
onClick={() => handleCopy(msg.content)}
51+
title="Copy Response"
52+
appearance="subtle"
53+
style={{ height: 28, width: 28 }}
54+
icon={<Copy />}
55+
/>
56+
<Button
57+
onClick={() => console.log("Heart clicked for response:", msg.content)}
58+
title="Like"
59+
appearance="subtle"
60+
style={{ height: 28, width: 28 }}
61+
icon={<HeartRegular />}
62+
/>
63+
</div>
64+
</div>
65+
)} */}
66+
</div>
67+
</Body1>
68+
</div>
69+
))}</div>
70+
71+
72+
{isTyping && (
73+
<div className="typing-indicator">
74+
<span>Thinking...</span>
75+
</div>
76+
)}
77+
</div> {showScrollButton && (
78+
<Tag
79+
onClick={scrollToBottom}
80+
className="scroll-to-bottom plan-chat-scroll-button"
81+
shape="circular"
82+
style={{ bottom: inputHeight }}
83+
>
84+
Back to bottom
85+
</Tag>
86+
)} <div ref={inputContainerRef} className="plan-chat-input-container">
87+
<div className="plan-chat-input-wrapper">
88+
<ChatInput
89+
value={input}
90+
onChange={setInput}
91+
onEnter={sendMessage}
92+
93+
>
94+
<Button
95+
appearance="transparent"
96+
onClick={sendMessage}
97+
icon={<Send />}
98+
disabled={isTyping || !input.trim()}
99+
/>
100+
101+
{messages.length > 0 && (
102+
<HeaderTools>
103+
<ToolbarDivider />
104+
<Button
105+
106+
onClick={clearChat}
107+
appearance="transparent"
108+
icon={<ChatDismiss20Regular />}
109+
disabled={isTyping || messages.length === 0} />
110+
111+
</HeaderTools>
112+
113+
)}
114+
115+
</ChatInput>
116+
</div>
117+
118+
</div>
119+
120+
121+
</div>
122+
);
9123
};
10124

11125
export default PlanChat;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* PlanChat Component Styles */
2+
3+
.plan-chat-message-content {
4+
display: flex;
5+
flex-direction: column;
6+
white-space: pre-wrap;
7+
width: 100%;
8+
}
9+
10+
.plan-chat-scroll-button {
11+
background-color: transparent;
12+
border: 1px solid var(--colorNeutralStroke3);
13+
backdrop-filter: saturate(180%) blur(16px);
14+
}
15+
16+
.plan-chat-input-container {
17+
display: flex;
18+
width: 100%;
19+
align-items: center;
20+
justify-content: center;
21+
}
22+
23+
.plan-chat-input-wrapper {
24+
display: flex;
25+
width: 100%;
26+
max-width: 768px;
27+
margin: 0px 16px;
28+
}

0 commit comments

Comments
 (0)