Comment.jsx 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React from 'react'
  2. import classnames from 'classnames'
  3. const Comment = props => {
  4. const styleSent = {
  5. color: '#fdfdfd',
  6. backgroundColor: props.customColor
  7. }
  8. const styleReceived = {
  9. color: '#333',
  10. backgroundColor: '#fdfdfd'
  11. }
  12. return (
  13. <li className={classnames(
  14. `${props.customClass}__messagelist__item`,
  15. 'timeline__body__messagelist__item', {
  16. 'sent': props.fromMe,
  17. 'received': !props.fromMe
  18. }
  19. )}>
  20. <div className={classnames(`${props.customClass}__messagelist__item__wrapper`, 'timeline__body__messagelist__item__wrapper')}>
  21. <div className={classnames(`${props.customClass}__messagelist__item__avatar`, 'timeline__body__messagelist__item__avatar')}>
  22. {props.avatar ? <img src={props.avatar} /> : ''}
  23. </div>
  24. </div>
  25. <div
  26. className={classnames(`${props.customClass}__messagelist__item__createhour`, 'timeline__body__messagelist__item__createhour')}>
  27. {props.createdAt}
  28. </div>
  29. <div
  30. className={classnames(`${props.customClass}__messagelist__item__content`, 'timeline__body__messagelist__item__content')}
  31. style={props.fromMe ? styleSent : styleReceived}
  32. dangerouslySetInnerHTML={{__html: props.text}}
  33. />
  34. </li>
  35. )
  36. }
  37. export default Comment