SpoilerButton.jsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React, { useState } from 'react'
  2. import { Button, Typography } from 'antd'
  3. const { Text } = Typography
  4. const { Title } = Typography
  5. export const SpoilerButton = ({ text, children, style }) => {
  6. const [opened, setOpened] = useState(false)
  7. return (
  8. <>
  9. <Button
  10. onClick={() => {
  11. setOpened(!opened)
  12. }}
  13. style={style}
  14. >
  15. {text}
  16. </Button>
  17. {opened && children}
  18. </>
  19. )
  20. }
  21. export const ReplyButton = ({ text, children, style }) => {
  22. const [opened, setOpened] = useState(false)
  23. return (
  24. <>
  25. <Text
  26. type="secondary"
  27. strong
  28. className="ButtonComment"
  29. onClick={() => {
  30. setOpened(!opened)
  31. }}
  32. style={style}
  33. >
  34. {text}
  35. </Text>
  36. {opened && children}
  37. </>
  38. )
  39. }
  40. export const ViewComment = ({ text, count, children, style,textClosed }) => {
  41. const [opened, setOpened] = useState(false)
  42. return (
  43. <>
  44. <Text
  45. type="secondary"
  46. strong
  47. // level={1}
  48. style={{fontSize:'14px'}}
  49. className="ButtonComment"
  50. onClick={() => {
  51. setOpened(!opened)
  52. }}
  53. // style={style}
  54. >
  55. { !opened ? text + count + ' comments' : textClosed}
  56. </Text>
  57. {<div className={opened && children ? 'ScrollForFeed' : 'WithOutScroll'}>
  58. {opened && children}
  59. </div>
  60. }
  61. </>
  62. )
  63. }