mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-24 04:10:15 +01:00
* feat: Add clear button to search bar This commit introduces a clear button to the SearchBar component using the X icon from Lucide-React. When the user enters a query in the input field, the clear button appears allowing them to easily remove the search term. The clear button is hidden when there is no search term entered. * Refactor SearchBar component to improve user experience Changed SearchBar's input field to add padding on the left side and an absolute positioned search icon. Also, added absolute positioned X icon on the right side when there is an input value, ensuring a better user experience. * Refactor SearchBar component to show Clear Search icon dynamically This commit makes changes to the SearchBar React component to render the Clear Search X icon only when the input field has a value. A showClearIcon state using useState hook is added and updated every time the input value changes. The useEffect hook is used to handle the case when the user clears the input value. This allows better UX by providing clear intent to the user that the icon is clickable and will clear the search query. * Improve UX: Add styling to clear button & export button This commit modifies the NavLinks component to improve user experience by removing a rounded styling to the "Clear conversations" and "Export conversations" buttons. Prior to this change, the buttons had a rounded styling. * Refactor submit button styling for improved accessibility and readability. Changed submit button styling for better accessibility and readability, including adjustments to padding and hover effects. The new styles ensure that the button is easily clickable for all users, while also improving its visual appearance. * hotfix * Improve UI styling in Conversation component Changed the background color and hover effect of the conversation link in Conversation component to make it more visually appealing. The previous background color was '#2A2B32' and now it's 'gray-800'. The 'px-4' class has also been changed to 'hover:pr-4' for better readability. --------- Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
114 lines
4 KiB
JavaScript
114 lines
4 KiB
JavaScript
import React, { useState } from 'react';
|
|
import StopGeneratingIcon from '../svg/StopGeneratingIcon';
|
|
import { Settings } from 'lucide-react';
|
|
import SetTokenDialog from './SetTokenDialog';
|
|
import store from '../../store';
|
|
|
|
export default function SubmitButton({
|
|
endpoint,
|
|
submitMessage,
|
|
handleStopGenerating,
|
|
disabled,
|
|
isSubmitting,
|
|
endpointsConfig
|
|
}) {
|
|
const [setTokenDialogOpen, setSetTokenDialogOpen] = useState(false);
|
|
const { getToken } = store.useToken(endpoint);
|
|
|
|
const isTokenProvided = endpointsConfig?.[endpoint]?.userProvide ? !!getToken() : true;
|
|
|
|
const clickHandler = (e) => {
|
|
e.preventDefault();
|
|
submitMessage();
|
|
};
|
|
|
|
const setToken = () => {
|
|
setSetTokenDialogOpen(true);
|
|
};
|
|
|
|
if (isSubmitting)
|
|
return (
|
|
<button
|
|
onClick={handleStopGenerating}
|
|
type="button"
|
|
className="group absolute bottom-0 right-0 flex h-[100%] w-[50px] items-center justify-center bg-transparent p-1 text-gray-500"
|
|
>
|
|
<div className="m-1 mr-0 rounded-md p-2 pb-[10px] pt-[10px] group-hover:bg-gray-100 group-disabled:hover:bg-transparent dark:group-hover:bg-gray-900 dark:group-hover:text-gray-400 dark:group-disabled:hover:bg-transparent">
|
|
<StopGeneratingIcon />
|
|
</div>
|
|
</button>
|
|
);
|
|
// // previous three dot animation
|
|
// return (
|
|
// <button
|
|
// className="absolute bottom-0 right-1 h-[100%] w-[40px] rounded-md p-1 text-gray-500 hover:bg-gray-100 disabled:hover:bg-transparent dark:hover:bg-gray-900 dark:hover:text-gray-400 dark:disabled:hover:bg-transparent md:right-2"
|
|
// disabled
|
|
// >
|
|
// <div className="text-2xl">
|
|
// <span style={{ maxWidth: 5.5, display: 'inline-grid' }}>·</span>
|
|
// <span
|
|
// className="blink"
|
|
// style={{ maxWidth: 5.5, display: 'inline-grid' }}
|
|
// >
|
|
// ·
|
|
// </span>
|
|
// <span
|
|
// className="blink2"
|
|
// style={{ maxWidth: 5.5, display: 'inline-grid' }}
|
|
// >
|
|
// ·
|
|
// </span>
|
|
// </div>
|
|
// </button>
|
|
// );
|
|
else if (!isTokenProvided && endpoint !== 'openAI') {
|
|
return (
|
|
<>
|
|
<button
|
|
onClick={setToken}
|
|
type="button"
|
|
className="group absolute bottom-0 right-0 flex h-[100%] w-auto items-center justify-center bg-transparent p-1 text-gray-500"
|
|
>
|
|
<div className="m-1 mr-0 rounded-md p-2 pb-[10px] pt-[10px] align-middle text-xs group-hover:bg-gray-100 group-disabled:hover:bg-transparent dark:group-hover:bg-gray-900 dark:group-hover:text-gray-400 dark:group-disabled:hover:bg-transparent">
|
|
<Settings className="mr-1 inline-block w-[18px]" />
|
|
Set Token First
|
|
</div>
|
|
</button>
|
|
<SetTokenDialog
|
|
open={setTokenDialogOpen}
|
|
onOpenChange={setSetTokenDialogOpen}
|
|
endpoint={endpoint}
|
|
/>
|
|
</>
|
|
);
|
|
} else
|
|
return (
|
|
<button
|
|
onClick={clickHandler}
|
|
disabled={disabled}
|
|
className="group absolute bottom-0 right-0 flex h-[100%] w-[50px] items-center justify-center bg-transparent p-1 text-gray-500"
|
|
>
|
|
<div className="m-1 mr-0 rounded-md pt-[11px] pb-[9px] pl-[9.5px] pr-[7px] group-hover:bg-gray-100 group-disabled:hover:bg-transparent dark:group-hover:bg-gray-900 dark:group-hover:text-gray-400 dark:group-disabled:hover:bg-transparent">
|
|
<svg
|
|
stroke="currentColor"
|
|
fill="none"
|
|
strokeWidth="2"
|
|
viewBox="0 0 24 24"
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
className="mr-1 h-4 w-4 "
|
|
height="1em"
|
|
width="1em"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<line x1="22" y1="2" x2="11" y2="13" />
|
|
<polygon points="22 2 15 22 11 13 2 9 22 2" />
|
|
</svg>
|
|
</div>
|
|
</button>
|
|
);
|
|
}
|
|
|
|
{
|
|
/* <div class="text-2xl"><span class="">·</span><span class="">·</span><span class="invisible">·</span></div> */
|
|
}
|