import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { withStyles } from '@material-ui/core/styles'; import DOMPurify from 'dompurify'; import marked from 'marked'; import Paper from '@material-ui/core/Paper'; import Typography from '@material-ui/core/Typography'; import { useIntl } from 'react-intl'; const linkRenderer = new marked.Renderer(); linkRenderer.link = (href, title, text) => { title = title ? title : href; text = text ? text : href; return `${ text }`; }; const styles = (theme) => ({ root : { display : 'flex', marginBottom : theme.spacing(1), padding : theme.spacing(1), flexShrink : 0 }, selfMessage : { marginLeft : 'auto' }, remoteMessage : { marginRight : 'auto' }, text : { '& p' : { margin : 0 } }, content : { marginLeft : theme.spacing(1) }, avatar : { borderRadius : '50%', height : '2rem', alignSelf : 'center' } }); const Message = (props) => { const intl = useIntl(); const { self, picture, text, time, name, classes } = props; return ( Avatar
{ self ? intl.formatMessage({ id : 'room.me', defaultMessage : 'Me' }) : name } - {time}
); }; Message.propTypes = { self : PropTypes.bool, picture : PropTypes.string, text : PropTypes.string, time : PropTypes.object, name : PropTypes.string, classes : PropTypes.object.isRequired }; export default withStyles(styles)(Message);