Skip to content

Commit

Permalink
feat: improve mention popover ui
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadoudicko committed Aug 21, 2023
1 parent b718be4 commit 3a60ff5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ export const MentionInput = ({
const { t } = useTranslation(["chat"]);

return (
<div
className="w-full"
onClick={() => {
mentionInputRef.current?.focus();
}}
>
<div className="w-full">
<Editor
editorKey={"editor"}
editorState={editorState}
Expand All @@ -54,6 +49,7 @@ export const MentionInput = ({
ref={mentionInputRef}
placeholder={t("actions_bar_placeholder")}
keyBindingFn={keyBindingFn}
onBlur={() => mentionInputRef.current?.blur()}
/>
<MentionSuggestions
open={open}
Expand All @@ -62,14 +58,19 @@ export const MentionInput = ({
onSearchChange={onSearchChange}
popoverContainer={({ children }) => {
return (
<div className="z-50 bg-white dark:bg-black border border-black/10 dark:border-white/25 rounded-md shadow-md overflow-y-auto min-w-32">
<div
style={{
maxWidth: "max-content",
}}
className="bg-white dark:bg-black border border-black/10 dark:border-white/25 rounded-md shadow-md overflow-y-auto"
>
{children}
<AddNewBrainButton />
</div>
);
}}
onAddMention={onAddMention}
entryComponent={({ mention, ...otherProps }) => (
entryComponent={({ mention, className, ...otherProps }) => (
<div {...otherProps}>
<BrainSuggestion id={mention.id as string} content={mention.name} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const AddNewBrainButton = (): JSX.Element => {
event.stopPropagation();
}}
>
<Button variant={"tertiary"}>{t("new_brain")}</Button>
<Button className="px-5 py-2 text-sm" variant={"tertiary"}>
{t("new_brain")}
</Button>
</Link>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const BrainSuggestion = ({
<div className="relative flex group items-center">
<div
className={
"flex flex-1 items-center gap-2 w-full text-left px-5 py-3 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"
"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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export const useMentionInput = ({
return "submit";
}

if (e.key === "ArrowUp" || e.key === "ArrowDown") {
return undefined;
}

return getDefaultKeyBinding(e);
};

Expand Down

0 comments on commit 3a60ff5

Please sign in to comment.