index.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { makeStyles } from "@material-ui/core/styles";
  2. import ListItemText from '@mui/material/ListItemText';
  3. import { CopyToClipboard } from 'react-copy-to-clipboard';
  4. import { firstLetter, slicedWord, timeStampMessage,copied } from '../../../../../../helpers'
  5. const useStyles = makeStyles({
  6. container: {
  7. display: "flex",
  8. justifyContent: "flex-end",
  9. width:'auto',
  10. maxWidth: '80%',
  11. marginBottom:10
  12. },
  13. wrapper: {
  14. position: 'relative',
  15. maxWidth: 450
  16. },
  17. message: {
  18. position: "relative",
  19. marginRight: 5,
  20. padding: "10px",
  21. paddingBottom:18,
  22. backgroundColor: "#deffa9",
  23. wordBreak:'break-word',
  24. textAlign: "left",
  25. font: "400 .9em 'Open Sans', sans-serif",
  26. border: "1px solid #d5ff91",
  27. borderRadius: 7,
  28. "&:after": {
  29. content: "''",
  30. position: "absolute",
  31. width: "0",
  32. height: "0",
  33. borderBottom: "15px solid #deffa9",
  34. borderLeft: "15px solid transparent",
  35. borderRight: "15px solid transparent",
  36. bottom: "0",
  37. right: "-15px"
  38. },
  39. "&:before": {
  40. content: "''",
  41. position: "absolute",
  42. width: "0",
  43. height: "0",
  44. borderBottom: "17px solid #deffa9",
  45. borderLeft: "16px solid transparent",
  46. borderRight: "16px solid transparent",
  47. bottom: "-1px",
  48. right: "-17px"
  49. }
  50. },
  51. time: {
  52. position: "absolute",
  53. fontSize: ".65em",
  54. fontWeight:600,
  55. bottom: 6,
  56. right: 6,
  57. color: '#414141',
  58. padding: 3,
  59. borderRadius: 5,
  60. },
  61. });
  62. interface IMessageRightText {
  63. message:string,
  64. name:string,
  65. lastName:string,
  66. updatedAt:string,
  67. }
  68. const MessageRightText = ({message,name,lastName,updatedAt}:IMessageRightText) => {
  69. const classes = useStyles();
  70. return (
  71. <div className={classes.container}>
  72. <CopyToClipboard onCopy={() => copied()} text={message}>
  73. <div className={classes.wrapper}>
  74. <ListItemText className={classes.message}
  75. primary={`${firstLetter(name)}${slicedWord(name, 15, 1)}
  76. ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}
  77. primaryTypographyProps={{color: "#42aee0"}}
  78. secondary={message}
  79. secondaryTypographyProps={{ color: "#0e0d0d" }} />
  80. <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
  81. </div>
  82. </CopyToClipboard>
  83. </div>
  84. )};
  85. export default MessageRightText