index.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import { makeStyles } from "@material-ui/core/styles";
  2. import { IconButton } from "@material-ui/core";
  3. import VideoFileIcon from '@mui/icons-material/VideoFile';
  4. import FileDownloadIcon from '@mui/icons-material/FileDownload';
  5. import { timeStampMessage } from '../../../../../../helpers'
  6. import poster from '../../../../../../img/videoPoster.png'
  7. const { Player } = require('video-react')
  8. const useStyles = makeStyles({
  9. container: {
  10. display: "flex",
  11. justifyContent: "flex-end",
  12. width:'auto',
  13. maxWidth: '80%',
  14. marginBottom:15
  15. },
  16. wrapper: {
  17. position: 'relative',
  18. display: 'flex',
  19. justifyContent: 'space-between',
  20. alignContent: 'center',
  21. alignItems: 'center',
  22. width: 400,
  23. padding: '12px 5px 12px 5px',
  24. backgroundColor: '#deffa9',
  25. borderRadius: 7,
  26. "&:after": {
  27. content: "''",
  28. position: "absolute",
  29. width: "0",
  30. height: "0",
  31. borderBottom: "15px solid #deffa9",
  32. borderLeft: "15px solid transparent",
  33. borderRight: "15px solid transparent",
  34. bottom: "0",
  35. right: "-15px"
  36. },
  37. "&:before": {
  38. content: "''",
  39. position: "absolute",
  40. width: "0",
  41. height: "0",
  42. borderBottom: "17px solid #deffa9",
  43. borderLeft: "16px solid transparent",
  44. borderRight: "16px solid transparent",
  45. bottom: "0px",
  46. right: "-17px"
  47. }
  48. },
  49. bntDownload: {
  50. backgroundColor: '#deffa9',
  51. color: '#54b0fc',
  52. width: 30,
  53. height: 30,
  54. marginLeft:5,
  55. '&:hover': {
  56. backgroundColor: '#54b0fc',
  57. color:'#ffffff'
  58. }
  59. },
  60. time: {
  61. position: "absolute",
  62. fontSize: ".65em",
  63. fontWeight:600,
  64. bottom: 0,
  65. right: 6,
  66. color: '#414141',
  67. padding: 3,
  68. borderRadius: 5,
  69. zIndex:10
  70. },
  71. });
  72. interface IMessageRightVideo {
  73. url:string,
  74. updatedAt: string,
  75. }
  76. const MessageRightVideo = ({ url,updatedAt }:IMessageRightVideo) => {
  77. const classes = useStyles();
  78. return (
  79. <div className={classes.container}>
  80. <div className={classes.wrapper}>
  81. <VideoFileIcon fontSize='large' style={{ color:'#03b003'}}/>
  82. <Player playsInline poster={poster}
  83. src={url}
  84. />
  85. <a href={url} target="_blank" rel="noreferrer" download>
  86. <IconButton className={classes.bntDownload} >
  87. <FileDownloadIcon fontSize='medium'/>
  88. </IconButton>
  89. </a>
  90. <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
  91. </div>
  92. </div>
  93. )};
  94. export default MessageRightVideo