ChatPane: clean up, switch to the other side in RTL

This commit is contained in:
Alex Gleason 2023-10-10 17:07:02 -05:00
parent 341fd4fcea
commit 679c0feb54
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 8 additions and 13 deletions

View File

@ -80,7 +80,7 @@ const ChatPane = () => {
// Active chat // Active chat
if (screen === ChatWidgetScreens.CHAT || screen === ChatWidgetScreens.CHAT_SETTINGS) { if (screen === ChatWidgetScreens.CHAT || screen === ChatWidgetScreens.CHAT_SETTINGS) {
return ( return (
<Pane isOpen={isOpen} index={0} main> <Pane isOpen={isOpen}>
<ChatWindow /> <ChatWindow />
</Pane> </Pane>
); );
@ -88,7 +88,7 @@ const ChatPane = () => {
if (screen === ChatWidgetScreens.SEARCH) { if (screen === ChatWidgetScreens.SEARCH) {
return ( return (
<Pane isOpen={isOpen} index={0} main> <Pane isOpen={isOpen}>
<ChatSearchHeader /> <ChatSearchHeader />
{isOpen ? <ChatSearch /> : null} {isOpen ? <ChatSearch /> : null}
@ -97,7 +97,7 @@ const ChatPane = () => {
} }
return ( return (
<Pane isOpen={isOpen} index={0} main> <Pane isOpen={isOpen}>
<ChatPaneHeader <ChatPaneHeader
title={<FormattedMessage id='column.chats' defaultMessage='Chats' />} title={<FormattedMessage id='column.chats' defaultMessage='Chats' />}
unreadCount={unreadChatsCount} unreadCount={unreadChatsCount}

View File

@ -4,25 +4,18 @@ import React from 'react';
interface IPane { interface IPane {
/** Whether the pane is open or minimized. */ /** Whether the pane is open or minimized. */
isOpen: boolean; isOpen: boolean;
/** Positions the pane on the screen, with 0 at the right. */
index: number;
/** Children to display in the pane. */ /** Children to display in the pane. */
children: React.ReactNode; children: React.ReactNode;
/** Whether this is the main chat pane. */
main?: boolean;
} }
/** Chat pane UI component for desktop. */ /** Chat pane UI component for desktop. */
const Pane: React.FC<IPane> = ({ isOpen = false, index, children, main = false }) => { const Pane: React.FC<IPane> = ({ isOpen = false, children }) => {
const right = (404 * index) + 20;
return ( return (
<div <div
className={clsx('fixed bottom-0 right-1 z-[99] flex w-96 flex-col rounded-t-lg bg-white shadow-3xl dark:bg-gray-900', { className={clsx('fixed bottom-0 z-[99] flex w-96 flex-col rounded-t-lg bg-white shadow-3xl ltr:right-5 rtl:left-5 dark:bg-gray-900', {
'h-[550px] max-h-[100vh]': isOpen, 'h-[550px] max-h-[100vh]': isOpen,
'h-16': !isOpen, 'h-16': !isOpen,
})} })}
style={{ right: `${right}px` }}
data-testid='pane' data-testid='pane'
> >
{children} {children}

View File

@ -505,7 +505,9 @@ const UI: React.FC<IUI> = ({ children }) => {
{me && features.chats && ( {me && features.chats && (
<div className='hidden xl:block'> <div className='hidden xl:block'>
<Suspense fallback={<div className='fixed bottom-0 z-[99] flex h-16 w-96 animate-pulse flex-col rounded-t-lg bg-white shadow-3xl ltr:right-5 rtl:left-5 dark:bg-gray-900' />}>
<ChatWidget /> <ChatWidget />
</Suspense>
</div> </div>
)} )}