fix: format sender text change and mobile styling

This commit is contained in:
Daniel Avila 2023-03-11 17:36:10 -05:00
parent 3b1d6aaa79
commit 4fa599e97a
4 changed files with 25 additions and 30 deletions

View file

@ -17,7 +17,7 @@ const customClient = async ({ text, progressCallback, convo, promptPrefix, chatG
clientOptions.chatGptLabel = chatGptLabel;
if (promptPrefix.length > 0) {
if (promptPrefix?.length > 0) {
clientOptions.promptPrefix = promptPrefix;
}

View file

@ -4,16 +4,16 @@ import EditIcon from '../svg/EditIcon';
export default function HoverButtons({ user }) {
return (
<div className="visible mt-2 flex justify-center gap-3 self-end text-gray-400 md:gap-4 lg:absolute lg:top-0 lg:right-0 lg:mt-0 lg:translate-x-full lg:gap-1 lg:self-center lg:pl-2">
{user && (
<button className="rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400">
<EditIcon />
</button>
)}
{/* <button className="rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400">
<div className="visible mt-2 flex justify-center gap-3 self-end text-gray-400 md:gap-4 lg:absolute lg:top-0 lg:right-0 lg:mt-0 lg:translate-x-full lg:gap-1 lg:self-center lg:pl-2">
{user && (
<button className="rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible">
{/* <button className="rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"> */}
<EditIcon />
</button>
)}
{/* <button className="rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400">
<Clipboard />
</button> */}
</div>
</div>
);
}

View file

@ -14,7 +14,6 @@ export default function Message({
}) {
const { isSubmitting } = useSelector((state) => state.submit);
const [abortScroll, setAbort] = useState(false);
const [isHovering, setIsHovering] = useState(false);
const notUser = sender.toLowerCase() !== 'user';
const blinker = isSubmitting && last && notUser;
@ -32,14 +31,6 @@ export default function Message({
}
};
const handleMouseOver = () => {
setIsHovering(true);
};
const handleMouseOut = () => {
setIsHovering(false);
};
const props = {
className:
'w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 bg-white dark:text-gray-100 group dark:bg-gray-800'
@ -49,7 +40,7 @@ export default function Message({
chatgpt: 'rgb(16, 163, 127)',
chatgptBrowser: 'rgb(25, 207, 207)',
bingai: '',
sydney: '',
sydney: ''
};
const isBing = sender === 'bingai' || sender === 'sydney';
@ -65,7 +56,11 @@ export default function Message({
if ((notUser && backgroundColor) || isBing) {
icon = (
<div
style={isBing ? { background: 'radial-gradient(circle at 90% 110%, #F0F0FA, #D0E0F9)' } : { backgroundColor }}
style={
isBing
? { background: 'radial-gradient(circle at 90% 110%, #F0F0FA, #D0E0F9)' }
: { backgroundColor }
}
className="relative flex h-[30px] w-[30px] items-center justify-center rounded-sm p-1 text-white"
>
{isBing ? <BingIcon /> : <GPTIcon />}
@ -84,12 +79,14 @@ export default function Message({
<div
{...props}
onWheel={handleWheel}
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
>
<div className="m-auto flex gap-4 p-4 text-base md:max-w-2xl md:gap-6 md:py-6 lg:max-w-2xl lg:px-0 xl:max-w-3xl">
<strong className="relative flex w-[30px] flex-col items-end text-right">
{icon}
<strong className="relative flex w-[30px] flex-col items-end text-right text-xs md:text-sm">
{typeof icon === 'string' && icon.match(/[^\u0000-\u007F]+/) ? (
<span className=" direction-rtl w-40 overflow-x-scroll">{icon}</span>
) : (
icon
)}
</strong>
<div className="relative flex w-[calc(100%-50px)] flex-col gap-1 whitespace-pre-wrap md:gap-3 lg:w-[calc(100%-115px)]">
<div className="flex flex-grow flex-col gap-3">
@ -109,9 +106,7 @@ export default function Message({
</div>
)}
</div>
<div className="flex justify-between">
{isHovering && <HoverButtons user={!notUser} />}
</div>
<HoverButtons user={!notUser} />
</div>
</div>
</div>

View file

@ -36,7 +36,7 @@
left: calc(-100%);;
top: 0;
bottom: 0;
max-width: 400px;
max-width: 320px;
width: calc(100% - 60px);
opacity: 0;
}