SpoilerButton.jsx 793 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import React, { useState } from 'react'
  2. import { Button, Typography } from 'antd'
  3. const { Text } = Typography
  4. export const SpoilerButton = ({ text, children, style }) => {
  5. const [opened, setOpened] = useState(false)
  6. return (
  7. <>
  8. <Button
  9. onClick={() => {
  10. setOpened(!opened)
  11. }}
  12. style={style}
  13. >
  14. {text}
  15. </Button>
  16. {opened && children}
  17. </>
  18. )
  19. }
  20. export const ReplyButton = ({ text, children, style }) => {
  21. const [opened, setOpened] = useState(false)
  22. return (
  23. <>
  24. <Text
  25. type="secondary"
  26. strong
  27. className="ButtonComment"
  28. onClick={() => {
  29. setOpened(!opened)
  30. }}
  31. style={style}
  32. >
  33. {text}
  34. </Text>
  35. {opened && children}
  36. </>
  37. )
  38. }