2023-01-25 13:45:33 -08:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { Textarea } from 'soapbox/components/ui';
|
|
|
|
import { Attachment } from 'soapbox/types/entities';
|
|
|
|
|
2023-01-26 10:30:26 -08:00
|
|
|
import ChatUpload from './chat-upload';
|
|
|
|
|
2023-01-25 13:45:33 -08:00
|
|
|
interface IChatTextarea extends React.ComponentProps<typeof Textarea> {
|
|
|
|
attachments?: Attachment[]
|
2023-01-26 10:30:26 -08:00
|
|
|
onDeleteAttachment?: () => void
|
2023-01-25 13:45:33 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Custom textarea for chats. */
|
2023-01-26 10:30:26 -08:00
|
|
|
const ChatTextarea: React.FC<IChatTextarea> = ({ attachments, onDeleteAttachment, ...rest }) => {
|
2023-01-25 13:45:33 -08:00
|
|
|
return (
|
|
|
|
<div className={`
|
|
|
|
bg-white
|
|
|
|
dark:bg-transparent
|
|
|
|
shadow-sm block w-full
|
|
|
|
sm:text-sm rounded-md
|
|
|
|
text-gray-900 dark:text-gray-100
|
2023-02-02 11:27:38 -08:00
|
|
|
border
|
2023-01-25 13:45:33 -08:00
|
|
|
placeholder:text-gray-600 dark:placeholder:text-gray-600 border-gray-400 dark:border-gray-800
|
2023-02-02 11:27:38 -08:00
|
|
|
dark:ring-1 focus-within:ring-1 dark:ring-gray-800 focus-within:ring-primary-500 focus-within:border-primary-500
|
2023-01-25 13:45:33 -08:00
|
|
|
dark:focus-within:ring-primary-500 dark:focus-within:border-primary-500
|
|
|
|
`}
|
|
|
|
>
|
2023-01-26 10:30:26 -08:00
|
|
|
{(!!attachments?.length) && (
|
|
|
|
<div className='p-3 pb-0'>
|
|
|
|
{attachments?.map(attachment => (
|
|
|
|
<ChatUpload
|
|
|
|
key={attachment.id}
|
|
|
|
attachment={attachment}
|
|
|
|
onDelete={onDeleteAttachment}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)}
|
2023-01-25 13:45:33 -08:00
|
|
|
|
|
|
|
<Textarea theme='transparent' {...rest} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ChatTextarea;
|