Skip to content

Commit deac886

Browse files
committed
feature: add inline send icon
1 parent d345d5e commit deac886

4 files changed

Lines changed: 30 additions & 10 deletions

File tree

clients/search-component/src/TrieveModal/Chat/ChatMode.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,21 @@ export const ChatMode = () => {
3939

4040
return (
4141
<Suspense>
42-
{(props.inline) && (currentQuestion || messages.length) ? <div className="inline-chat-header">
42+
{props.inline && messages.length ? <div className="inline-chat-header">
4343
<div>
4444
<p>
4545
{props.inlineHeader}
4646
</p>
4747
</div>
4848
<button
4949
onClick={() =>
50-
currentQuestion
51-
? askQuestion(currentQuestion)
52-
: isDoneReading
50+
isDoneReading
5351
? clearConversation()
5452
: stopGeneratingMessage()
5553
}
5654
className="clear-button"
5755
>
58-
{currentQuestion ? "Enter" : isDoneReading ? "Clear" : "Stop"}
56+
{isDoneReading ? "Clear" : "Stop"}
5957
</button>
6058
</div>: null}
6159
<div className={`chat-outer-wrapper ${props.inline ? "": "chat-outer-popup"}`} ref={modalRef}>
@@ -140,6 +138,7 @@ export const ChatMode = () => {
140138
</div>
141139
)}
142140
<div className="input-wrapper chat">
141+
{!props.inline ?
143142
<button
144143
onClick={() => {
145144
if (currentGroup) {
@@ -150,7 +149,7 @@ export const ChatMode = () => {
150149
className="back-icon"
151150
>
152151
<i className="fa-solid fa-chevron-left"></i>
153-
</button>
152+
</button> : null}
154153
<form
155154
onSubmit={(e) => {
156155
e.preventDefault();
@@ -162,12 +161,24 @@ export const ChatMode = () => {
162161
<input
163162
ref={chatInput}
164163
value={currentQuestion}
164+
className={`${props.inline ? "inline-input": ""}`}
165165
onChange={(e) => setCurrentQuestion(e.target.value)}
166166
placeholder={`Ask me anything about${
167167
props.brandName ? ` ${props.brandName}` : ""
168168
}`}
169169
/>
170170
</form>
171+
{props.inline ?
172+
<button
173+
onClick={() => {
174+
if (currentQuestion) {
175+
askQuestion(currentQuestion)
176+
}
177+
}}
178+
className="inline-submit-icon"
179+
>
180+
<i className="fa-solid fa-paper-plane"></i>
181+
</button> : null}
171182
</div>
172183
<div className={`trieve-footer chat ${props.type}`}>
173184
{(!props.inline) && (currentQuestion || messages.length) ? (

clients/search-component/src/TrieveModal/index.css

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ body {
214214
}
215215

216216
.inline-chat-header {
217-
@apply flex justify-between px-4 py-4 rounded-t-lg;
218-
background-color: var(--tv-zinc-400);
217+
@apply flex justify-between px-4 py-4 rounded-t-lg border-b-2;
218+
219+
background-color: var(--tv-zinc-100);
219220
}
220221

221222
.chat-footer-wrapper {
@@ -228,6 +229,10 @@ body {
228229
background-color: var(--tv-prop-brand-color);
229230
}
230231

232+
.inline-submit-icon {
233+
@apply top-[0.825rem] right-7 absolute z-20;
234+
}
235+
231236
.trieve-footer {
232237
@apply sticky px-3 items-center bottom-[1px] flex flex-col;
233238
background-color: var(--tv-zinc-50);
@@ -796,6 +801,10 @@ body {
796801
color: var(--tv-zinc-400);
797802
}
798803

804+
&.inline-input {
805+
@apply pl-2;
806+
}
807+
799808
&:focus {
800809
border: 1px solid var(--tv-prop-brand-color);
801810
}

clients/search-component/src/utils/hooks/chat-context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const ChatContext = createContext<{
6060
});
6161

6262
function ChatProvider({ children }: { children: React.ReactNode }) {
63-
const { query, trieveSDK, modalRef, setMode, setCurrentGroup } =
63+
const { query, trieveSDK, setMode, setCurrentGroup } =
6464
useModalState();
6565
const [currentQuestion, setCurrentQuestion] = useState(query);
6666
const [currentTopic, setCurrentTopic] = useState("");

frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ const PublicPageControls = () => {
917917
</div>
918918
<input
919919
type="number"
920-
placeholder="1000"
920+
placeholder="3"
921921
value={extraParams.numberOfSuggestions ?? 3}
922922
onInput={(e) => {
923923
setExtraParams("numberOfSuggestions", parseInt(e.currentTarget.value));

0 commit comments

Comments
 (0)