AddComment.jsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { Picker } from 'emoji-mart'
  2. import 'emoji-mart/css/emoji-mart.css'
  3. import React, { useState } from 'react'
  4. import { Input,Col,Button } from 'antd'
  5. import { SmileOutlined, SmileFilled,SendOutlined } from '@ant-design/icons'
  6. import { Link } from 'react-router-dom'
  7. const AddComment = ({ addComment, postId, style, width }) => {
  8. const [text, setComment] = useState('')
  9. const [showEmojiPicker, setShowEmojiPicker] = useState(false)
  10. const handleOK = () => setShowEmojiPicker(!showEmojiPicker)
  11. const addEmoji = ({ native }) => setComment((text + ' ' + native).trim())
  12. return (
  13. <>
  14. {showEmojiPicker && (
  15. <Picker
  16. style={style}
  17. theme="light"
  18. native={true}
  19. showPreview={false}
  20. showSkinTones={false}
  21. onSelect={(native) => addEmoji(native)}
  22. />
  23. )}
  24. <Col xl={{ span: 10, offset: 1 }}
  25. lg={{ span: 14, offset: 1 }}
  26. md={{ offset: 1, span: 14 }}
  27. sm={{ offset: 1, span: 10 }}
  28. xs={{ offset: 1, span: 10 }}
  29. >
  30. <Input
  31. style={{
  32. display:'flex',
  33. // display: 'flex',
  34. // width,
  35. // margin: '5px 10px',
  36. // padding:'5px'
  37. }}
  38. xl={{ size: "large" }}
  39. xs={{ size:'small'}}
  40. placeholder="Add a comment..."
  41. value={text}
  42. onChange={(e) => {
  43. setComment(e.target.value)
  44. }}
  45. onPressEnter={(e) => setComment(e.target.value)}
  46. />
  47. </Col>
  48. <Col xl={{ offset: 1, span: 1 }}
  49. sm={{ offset: 1, span: 1 }}
  50. xs={{offset: 1, span: 1 }}
  51. >
  52. {!showEmojiPicker ? (
  53. <SmileOutlined className="SmileBtn" onClick={handleOK} />
  54. ) : (
  55. <SmileFilled className="SmileBtnFilled" onClick={handleOK} />
  56. )}
  57. </Col>
  58. <Col xl={{ offset: 1, span: 1 }}
  59. sm={{offset: 1, span: 1 }}
  60. xs={{offset: 1 }}
  61. >
  62. <Button type="text"
  63. className="Send"
  64. disabled={text.length < 1}
  65. onClick={(e) => {
  66. addComment(postId, text) &&
  67. setComment((e.target.value = ''))
  68. }}
  69. >
  70. <SendOutlined
  71. className="Send"
  72. type="primary"
  73. />
  74. </Button>
  75. {/* <Button
  76. xl={{ size: 'large' }}
  77. xs={{ size: 'small' }}
  78. disabled={text.length < 1}
  79. type="primary"
  80. onClick={(e) => {
  81. addComment(postId, text) &&
  82. setComment((e.target.value = ''))
  83. }}
  84. >
  85. {' '}
  86. Publish{' '}
  87. </Button> */}
  88. </Col>
  89. </>
  90. )
  91. }
  92. export default AddComment