index.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { makeStyles } from "@material-ui/core/styles";
  2. import { timeStamp } from '../../../../../../helpers'
  3. const useStyles = makeStyles({
  4. container: {
  5. display: "flex",
  6. justifyContent: "flex-start",
  7. width:'auto',
  8. maxWidth: '80%',
  9. marginBottom:15
  10. },
  11. imageWrapper: {
  12. width: 300,
  13. position:'relative'
  14. },
  15. image: {
  16. borderRadius: 10,
  17. width: 300,
  18. maxHeight: 400,
  19. },
  20. time: {
  21. position: "absolute",
  22. fontSize: ".65em",
  23. fontWeight:600,
  24. bottom: -4,
  25. right: -4,
  26. color: '#ffffff',
  27. backgroundColor: '#3a3a3a',
  28. padding: 3,
  29. borderRadius:5
  30. },
  31. });
  32. interface IMessagesLeftImage {
  33. imgUrl:string,
  34. updatedAt:string,
  35. color:string
  36. }
  37. const MessagesLeftImage = ({imgUrl,updatedAt,color}:IMessagesLeftImage) => {
  38. const classes = useStyles();
  39. return (
  40. <div className={classes.container}>
  41. <div className={classes.imageWrapper}>
  42. <img className={classes.image} alt='message pic' src={`http://localhost:3000/${imgUrl}`}
  43. style={{ backgroundColor: imgUrl?'':color }} width='300' height='400' />
  44. <div className={classes.time}>{timeStamp(updatedAt)}</div>
  45. </div>
  46. </div>
  47. )};
  48. export default MessagesLeftImage