outline-item-toggle-button.tsx 774 B

123456789101112131415161718192021222324
  1. import { memo, type Dispatch, type SetStateAction } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import MaterialIcon from '@/shared/components/material-icon'
  4. export const OutlineItemToggleButton = memo<{
  5. expanded: boolean
  6. setExpanded: Dispatch<SetStateAction<boolean>>
  7. }>(({ expanded, setExpanded }) => {
  8. const { t } = useTranslation()
  9. return (
  10. <button
  11. className="outline-item-expand-collapse-btn"
  12. onClick={() => setExpanded(value => !value)}
  13. aria-label={expanded ? t('collapse') : t('expand')}
  14. >
  15. <MaterialIcon
  16. type={expanded ? 'keyboard_arrow_down' : 'keyboard_arrow_right'}
  17. className="outline-caret-icon"
  18. />
  19. </button>
  20. )
  21. })
  22. OutlineItemToggleButton.displayName = 'OutlineItemToggleButton'