-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6907233
commit 24e209b
Showing
6 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from "react"; | ||
|
||
export function StopIcon() { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="16" | ||
height="16" | ||
fill="currentColor" | ||
className="bi bi-stop-fill" | ||
viewBox="0 0 16 16" | ||
> | ||
<path d="M5 3.5h6A1.5 1.5 0 0 1 12.5 5v6a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 11V5A1.5 1.5 0 0 1 5 3.5" /> | ||
</svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
zettelkasten-front/src/components/chat/AssistantMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from "react"; | ||
|
||
interface AssistantMessageProps { | ||
message: string; | ||
} | ||
export function AssistantMessage({ message }: AssistantMessageProps) { | ||
return ( | ||
<div> | ||
<div className="flex flex-col gap-1 p-4 mx-20"> | ||
<div className="flex items-center gap-2"> | ||
<h2 className="text-lg font-semibold text-gray-800">Zettelgarden</h2> | ||
</div> | ||
<div className="text-gray-600 mx-4"> | ||
{message} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useState, useEffect, KeyboardEvent, ChangeEvent } from "react"; | ||
import { StopIcon } from "../../assets/icons/StopIcon"; | ||
|
||
import { AssistantMessage } from "./AssistantMessage"; | ||
import { UserMessage } from "./UserMessage"; | ||
|
||
interface ChatPageProps {} | ||
|
||
export function ChatPage({}: ChatPageProps) { | ||
const [query, setQuery] = useState(""); | ||
const [isLoading, setIsLoading] = useState<boolean>(false); | ||
|
||
function handleSearchUpdate(e: ChangeEvent<HTMLInputElement>) { | ||
setQuery(e.target.value); | ||
} | ||
function handleQuery() { | ||
setIsLoading(true); | ||
} | ||
|
||
function handleStop() {} | ||
|
||
return ( | ||
<div> | ||
<AssistantMessage message="hello world" /> | ||
<UserMessage | ||
message={ | ||
"I want you to work on another component now. it should look something" | ||
} | ||
/> | ||
<div className="flex items-center gap-2 bg-gray-50 rounded-lg px-4 py-3"> | ||
<button | ||
className="text-gray-400 hover:text-gray-600" | ||
onClick={handleQuery} | ||
> | ||
+ | ||
</button> | ||
<input | ||
className="w-full bg-transparent border-none outline-none text-gray-700 placeholder-gray-500" | ||
type="text" | ||
id="title" | ||
value={query} | ||
placeholder="How can I help you today?" | ||
onChange={handleSearchUpdate} | ||
onKeyPress={(event: KeyboardEvent<HTMLInputElement>) => { | ||
if (event.key === "Enter") { | ||
handleQuery(); | ||
} | ||
}} | ||
/> | ||
{isLoading && ( | ||
<button | ||
className="bg-black text-white rounded-full h-8 w-8 flex items-center justify-center text-sm font-medium hover:bg-gray-800" | ||
onClick={handleStop} | ||
> | ||
<StopIcon /> | ||
</button> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from "react"; | ||
|
||
interface UserMessageProps { | ||
message: string; | ||
} | ||
|
||
export function UserMessage({ message }: UserMessageProps) { | ||
return ( | ||
<div> | ||
<div className="bg-gray-50 rounded-lg p-4 my-4 ml-40"> | ||
<p className="text-gray-700">{message}</p> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters