From 55ecda902dd9b080a773d698057f5443b1f097be Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 29 Nov 2024 03:28:35 +0530 Subject: [PATCH] (fix:edit-feat): exacting the UI/UX --- frontend/src/Navigation.tsx | 16 +---- .../src/conversation/ConversationBubble.tsx | 71 ++++++++++--------- 2 files changed, 37 insertions(+), 50 deletions(-) diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index 15c9fcb9..f6d65675 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -51,21 +51,7 @@ interface NavigationProps { navOpen: boolean; setNavOpen: React.Dispatch>; } -/* const NavImage: React.FC<{ - Light: string | undefined; - Dark: string | undefined; -}> = ({ Light, Dark }) => { - return ( - <> - icon - icon - - ); -}; -NavImage.propTypes = { - Light: PropTypes.string, - Dark: PropTypes.string, -}; */ + export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { const dispatch = useDispatch(); const queries = useSelector(selectQueries); diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 324c722b..e642f5fc 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -1,6 +1,6 @@ import 'katex/dist/katex.min.css'; -import { forwardRef, useState } from 'react'; +import { forwardRef, useRef, useState } from 'react'; import ReactMarkdown from 'react-markdown'; import { useSelector } from 'react-redux'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; @@ -26,6 +26,7 @@ import { } from '../preferences/preferenceSlice'; import classes from './ConversationBubble.module.css'; import { FEEDBACK, MESSAGE_TYPE } from './conversationModels'; +import { useOutsideAlerter } from '../hooks'; const DisableSourceFE = import.meta.env.VITE_DISABLE_SOURCE_FE || false; @@ -73,7 +74,9 @@ const ConversationBubble = forwardRef< const [isDislikeClicked, setIsDislikeClicked] = useState(false); const [activeTooltip, setActiveTooltip] = useState(null); const [isSidebarOpen, setIsSidebarOpen] = useState(false); + const editableQueryRef = useRef(null); + useOutsideAlerter(editableQueryRef, () => setIsEditClicked(false), [], true); const handleEditClick = () => { setIsEditClicked(false); handleUpdatedQuestionSubmission?.(editInputBox, true, questionNumber); @@ -87,7 +90,7 @@ const ConversationBubble = forwardRef< >
{!isEditClicked && ( @@ -101,42 +104,40 @@ const ConversationBubble = forwardRef<
)} {isEditClicked && ( - setEditInputBox(e.target.value)} - value={editInputBox} - className="w-[85%] ml-2 mr-2 rounded-[28px] py-[12px] dark:border-[0.5px] dark:border-white dark:bg-raisin-black dark:text-white px-[18px] border-[1.5px] border-black" - /> +
+ setEditInputBox(e.target.value)} + value={editInputBox} + className="ml-2 mr-2 rounded-[28px] py-[12px] dark:border-[0.5px] dark:border-white dark:bg-raisin-black dark:text-white px-[18px] border-[1.5px] border-black" + /> +
+ + +
+
)} -
{ + setIsEditClicked(true); + setEditInputBox(message); + }} + className={`p-2 cursor-pointer rounded-full hover:bg-[#35363B] flex items-center ${isQuestionHovered || isEditClicked ? 'visible' : 'invisible'}`} > - Edit { - setIsEditClicked(true); - setEditInputBox(message); - }} - /> -
+ Edit + - {isEditClicked && ( -
- - -
- )} ); } else {