toggle-expand-btn.tsx 634 B

12345678910111213141516171819202122232425262728
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React, { useCallback } from 'react'
  4. import {
  5. RiCollapseDiagonalLine,
  6. RiExpandDiagonalLine,
  7. } from '@remixicon/react'
  8. type Props = {
  9. isExpand: boolean
  10. onExpandChange: (isExpand: boolean) => void
  11. }
  12. const ExpandBtn: FC<Props> = ({
  13. isExpand,
  14. onExpandChange,
  15. }) => {
  16. const handleToggle = useCallback(() => {
  17. onExpandChange(!isExpand)
  18. }, [isExpand])
  19. const Icon = isExpand ? RiCollapseDiagonalLine : RiExpandDiagonalLine
  20. return (
  21. <Icon className='w-3.5 h-3.5 text-gray-500 cursor-pointer' onClick={handleToggle} />
  22. )
  23. }
  24. export default React.memo(ExpandBtn)