-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
399fb38
commit f55c523
Showing
16 changed files
with
124 additions
and
64 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
13 changes: 4 additions & 9 deletions
13
...nts/ChatInput/components/ChatBar/components/MentionInput/components/AddNewBrainButton.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 |
---|---|---|
@@ -1,22 +1,17 @@ | ||
import Link from "next/link"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import Button from "@/lib/components/ui/Button"; | ||
import { MdAdd } from "react-icons/md"; | ||
|
||
export const AddNewBrainButton = (): JSX.Element => { | ||
const { t } = useTranslation(["chat"]); | ||
|
||
return ( | ||
<Link | ||
href={"/brains-management"} | ||
onClick={(event) => { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
}} | ||
className="flex px-5 py-3 text-sm decoration-none text-center w-full justify-between items-center" | ||
> | ||
<Button className="px-5 py-2 text-sm" variant={"tertiary"}> | ||
{t("new_brain")} | ||
</Button> | ||
{t("new_brain")} | ||
<MdAdd /> | ||
</Link> | ||
); | ||
}; |
17 changes: 17 additions & 0 deletions
17
...ts/ChatInput/components/ChatBar/components/MentionInput/components/AddNewPromptButton.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,17 @@ | ||
import Link from "next/link"; | ||
import { useTranslation } from "react-i18next"; | ||
import { MdAdd } from "react-icons/md"; | ||
|
||
export const AddNewPromptButton = (): JSX.Element => { | ||
const { t } = useTranslation(["chat"]); | ||
|
||
return ( | ||
<Link | ||
href={"/brains-management"} | ||
className="flex px-5 py-3 text-sm decoration-none text-center w-full justify-between items-center" | ||
> | ||
{t("new_prompt")} | ||
<MdAdd /> | ||
</Link> | ||
); | ||
}; |
17 changes: 1 addition & 16 deletions
17
...nents/ChatInput/components/ChatBar/components/MentionInput/components/BrainSuggestion.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 |
---|---|---|
@@ -1,23 +1,8 @@ | ||
type BrainSuggestionProps = { | ||
content: string; | ||
id: string; | ||
}; | ||
export const BrainSuggestion = ({ | ||
content, | ||
id, | ||
}: BrainSuggestionProps): JSX.Element => { | ||
//TODO: use this id for ShareBrain component | ||
console.log({ id }); | ||
|
||
return ( | ||
<div className="relative flex group items-center"> | ||
<div | ||
className={ | ||
"flex flex-1 items-center gap-2 w-full text-left px-5 py-2 text-sm leading-5 text-gray-900 dark:text-gray-300 group-hover:bg-gray-100 dark:group-hover:bg-gray-700 group-focus:bg-gray-100 dark:group-focus:bg-gray-700 group-focus:outline-none transition-colors" | ||
} | ||
> | ||
<span className="flex-1">{content}</span> | ||
</div> | ||
</div> | ||
); | ||
return <span>{content}</span>; | ||
}; |
16 changes: 5 additions & 11 deletions
16
...Input/components/SuggestionsContainer.tsx → .../components/BrainSuggestionsContainer.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 |
---|---|---|
@@ -1,27 +1,21 @@ | ||
import { Popover } from "@draft-js-plugins/mention"; | ||
import { PopoverProps } from "@draft-js-plugins/mention/lib/MentionSuggestions/Popover"; | ||
|
||
export const SuggestionsContainer = ({ | ||
import { AddNewBrainButton } from "./AddNewBrainButton"; | ||
|
||
export const BrainSuggestionsContainer = ({ | ||
children, | ||
...popoverProps | ||
}: PopoverProps): JSX.Element => ( | ||
<Popover {...popoverProps}> | ||
<div | ||
style={{ | ||
maxWidth: "max-content", | ||
width: "max-content", | ||
}} | ||
className="bg-white dark:bg-black border border-black/10 dark:border-white/25 rounded-md shadow-md overflow-y-auto" | ||
> | ||
{children} | ||
<button | ||
style={{ height: 30 }} | ||
onClick={() => { | ||
console.log("hellooo"); | ||
alert("Hello"); | ||
}} | ||
> | ||
Add new prompt | ||
</button> | ||
<AddNewBrainButton /> | ||
</div> | ||
</Popover> | ||
); |
14 changes: 14 additions & 0 deletions
14
...ents/ChatInput/components/ChatBar/components/MentionInput/components/PromptSuggestion.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,14 @@ | ||
type PromptSuggestionProps = { | ||
content: string; | ||
}; | ||
export const PromptSuggestion = ({ | ||
content, | ||
}: PromptSuggestionProps): JSX.Element => { | ||
return ( | ||
<div className="flex flex-1 flex-row gap-2 w-full text-left px-5 py-2 text-sm text-gray-900 dark:text-gray-300"> | ||
<div className="flex flex-1"> | ||
<span>{content}</span> | ||
</div> | ||
</div> | ||
); | ||
}; |
21 changes: 21 additions & 0 deletions
21
...nput/components/ChatBar/components/MentionInput/components/PromptSuggestionsContainer.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,21 @@ | ||
import { Popover } from "@draft-js-plugins/mention"; | ||
import { PopoverProps } from "@draft-js-plugins/mention/lib/MentionSuggestions/Popover"; | ||
|
||
import { AddNewPromptButton } from "./AddNewPromptButton"; | ||
|
||
export const PromptSuggestionsContainer = ({ | ||
children, | ||
...popoverProps | ||
}: PopoverProps): JSX.Element => ( | ||
<Popover {...popoverProps}> | ||
<div | ||
style={{ | ||
width: "max-content", | ||
}} | ||
className="bg-white dark:bg-black border border-black/10 dark:border-white/25 rounded-md shadow-md overflow-y-auto" | ||
> | ||
{children} | ||
<AddNewPromptButton /> | ||
</div> | ||
</Popover> | ||
); |
41 changes: 25 additions & 16 deletions
41
...ponents/ChatInput/components/ChatBar/components/MentionInput/components/SuggestionRow.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 |
---|---|---|
@@ -1,23 +1,32 @@ | ||
import { EntryComponentProps } from "@draft-js-plugins/mention/lib/MentionSuggestions/Entry/Entry"; | ||
import { UUID } from "crypto"; | ||
|
||
import { MentionTriggerType } from "@/app/chat/[chatId]/components/ActionsBar/types"; | ||
import { ShareBrain } from "@/lib/components/ShareBrain"; | ||
|
||
import { BrainSuggestion } from "./BrainSuggestion"; | ||
import { PromptSuggestion } from "./PromptSuggestion"; | ||
|
||
export const SuggestionRow = ({ | ||
mention, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
className, | ||
...otherProps | ||
}: EntryComponentProps): JSX.Element => ( | ||
<div {...otherProps}> | ||
<BrainSuggestion id={mention.id as string} content={mention.name} /> | ||
<button | ||
onClick={() => { | ||
console.log("helloo"); | ||
alert("test"); | ||
}} | ||
> | ||
{" "} | ||
test | ||
</button> | ||
</div> | ||
); | ||
}: EntryComponentProps): JSX.Element => { | ||
if ((mention.trigger as MentionTriggerType) === "@") { | ||
return ( | ||
<div {...otherProps}> | ||
<div className="relative flex group px-4"> | ||
<BrainSuggestion content={mention.name} /> | ||
<div className="absolute right-0 flex flex-row"> | ||
<ShareBrain brainId={mention.id as UUID} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div {...otherProps}> | ||
<PromptSuggestion content={mention.name} /> | ||
</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
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
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
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