import clsx from 'clsx'; import React from 'react'; import { makeStyles } from 'tss-react/mui'; // eslint-disable-next-line lines-around-comment // @ts-ignore import Avatar from '../../../base/avatar/components/Avatar'; import { IMessage } from '../../reducer'; import ChatMessage from './ChatMessage'; interface IProps { /** * Additional CSS classes to apply to the root element. */ className: string; /** * The messages to display as a group. */ messages: Array; } const useStyles = makeStyles()(theme => { return { messageGroup: { display: 'flex', flexDirection: 'column', maxWidth: '100%' }, groupContainer: { display: 'flex', '&.local': { justifyContent: 'flex-end', '& .avatar': { display: 'none' } } }, avatar: { margin: `${theme.spacing(1)} ${theme.spacing(2)} ${theme.spacing(3)} 0`, position: 'sticky', flexShrink: 0, top: 0 } }; }); const ChatMessageGroup = ({ className = '', messages }: IProps) => { const { classes } = useStyles(); const messagesLength = messages.length; if (!messagesLength) { return null; } return (
{messages.map((message, i) => ( ))}
); }; export default ChatMessageGroup;