toggle-expand-btn.tsx 705 B

12345678910111213141516171819202122232425262728293031
  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. import ActionButton from '@/app/components/base/action-button'
  9. type Props = {
  10. isExpand: boolean
  11. onExpandChange: (isExpand: boolean) => void
  12. }
  13. const ExpandBtn: FC<Props> = ({
  14. isExpand,
  15. onExpandChange,
  16. }) => {
  17. const handleToggle = useCallback(() => {
  18. onExpandChange(!isExpand)
  19. }, [isExpand])
  20. const Icon = isExpand ? RiCollapseDiagonalLine : RiExpandDiagonalLine
  21. return (
  22. <ActionButton onClick={handleToggle}>
  23. <Icon className='w-4 h-4' />
  24. </ActionButton>
  25. )
  26. }
  27. export default React.memo(ExpandBtn)