-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
532 uiux add slash command modal (#555)
* WIP slash commands * add slash command image * WIP slash commands * slash command menu feature complete * move icons to slash command local * update how slash command component works * relint with new linter * Finalize slash command input Change empty workspace text layout Patch dev unmount issues on Chatworkspace/index.jsx --------- Co-authored-by: timothycarambat <[email protected]>
- Loading branch information
1 parent
58971e8
commit 5c3bb4b
Showing
7 changed files
with
148 additions
and
38 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
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
4 changes: 4 additions & 0 deletions
4
...spaceChat/ChatContainer/PromptInput/SlashCommands/icons/slash-commands-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions
68
frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SlashCommands/index.jsx
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,68 @@ | ||
import { useEffect, useRef, useState } from "react"; | ||
import SlashCommandIcon from "./icons/slash-commands-icon.svg"; | ||
|
||
export default function SlashCommandsButton({ showing, setShowSlashCommand }) { | ||
return ( | ||
<div | ||
id="slash-cmd-btn" | ||
onClick={() => setShowSlashCommand(!showing)} | ||
className={`flex justify-center items-center opacity-60 hover:opacity-100 cursor-pointer ${ | ||
showing ? "!opacity-100" : "" | ||
}`} | ||
> | ||
<img | ||
src={SlashCommandIcon} | ||
className="w-6 h-6 pointer-events-none" | ||
alt="Slash commands button" | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export function SlashCommands({ showing, setShowing, sendCommand }) { | ||
const cmdRef = useRef(null); | ||
useEffect(() => { | ||
function listenForOutsideClick() { | ||
if (!showing || !cmdRef.current) return false; | ||
document.addEventListener("click", closeIfOutside); | ||
} | ||
listenForOutsideClick(); | ||
}, [showing, cmdRef.current]); | ||
|
||
if (!showing) return null; | ||
const closeIfOutside = ({ target }) => { | ||
if (target.id === "slash-cmd-btn") return; | ||
const isOutside = !cmdRef?.current?.contains(target); | ||
if (!isOutside) return; | ||
setShowing(false); | ||
}; | ||
|
||
return ( | ||
<div className="w-full flex justify-center absolute bottom-[130px] md:bottom-[150px] left-0 z-10 px-4"> | ||
<div | ||
ref={cmdRef} | ||
className="w-[600px] p-2 bg-zinc-800 rounded-2xl shadow flex-col justify-center items-start gap-2.5 inline-flex" | ||
> | ||
<button | ||
onClick={() => { | ||
setShowing(false); | ||
sendCommand("/reset", true); | ||
}} | ||
className="w-full hover:cursor-pointer hover:bg-zinc-700 px-2 py-2 rounded-xl flex flex-col justify-start" | ||
> | ||
<div className="w-full flex-col text-left flex pointer-events-none"> | ||
<div className="text-white text-sm font-bold">/reset</div> | ||
<div className="text-white text-opacity-60 text-sm"> | ||
Clear your chat history and begin a new chat | ||
</div> | ||
</div> | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export function useSlashCommands() { | ||
const [showSlashCommand, setShowSlashCommand] = useState(false); | ||
return { showSlashCommand, setShowSlashCommand }; | ||
} |
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
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
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