Няма описание

123456789101112131415161718192021222324252627282930
  1. import React, { useMemo, useState } from "react";
  2. import { DownOutlined, UpOutlined } from "@ant-design/icons";
  3. import styles from './CollapseBtn.less';
  4. export const CollapseBtn = ({
  5. text,
  6. onChange,
  7. }: {
  8. text: string;
  9. onChange: Function;
  10. }) => {
  11. const [isCollapse, setCollapse] = useState(false);
  12. return (
  13. <span
  14. className={styles.wrapper}
  15. onClick={() => {
  16. if (onChange(!isCollapse)) {
  17. setCollapse(!isCollapse);
  18. }
  19. }}
  20. >
  21. <span>{text}</span>
  22. <span className={styles.icon}>
  23. {isCollapse ? <UpOutlined /> : <DownOutlined />}
  24. </span>
  25. </span>
  26. );
  27. };