file-tree-folder-icons.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { useTranslation } from 'react-i18next'
  2. import MaterialIcon from '@/shared/components/material-icon'
  3. import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
  4. function FileTreeFolderIcons({
  5. expanded,
  6. onExpandCollapseClick,
  7. }: {
  8. expanded: boolean
  9. onExpandCollapseClick: () => void
  10. }) {
  11. const { t } = useTranslation()
  12. const newEditor = useIsNewEditorEnabled()
  13. if (newEditor) {
  14. return (
  15. <>
  16. <button
  17. className="folder-expand-collapse-button"
  18. onClick={onExpandCollapseClick}
  19. aria-label={expanded ? t('collapse') : t('expand')}
  20. >
  21. <MaterialIcon
  22. type={expanded ? 'expand_more' : 'chevron_right'}
  23. className="file-tree-expand-icon"
  24. />
  25. </button>
  26. </>
  27. )
  28. }
  29. return (
  30. <>
  31. <button
  32. onClick={onExpandCollapseClick}
  33. aria-label={expanded ? t('collapse') : t('expand')}
  34. >
  35. <MaterialIcon
  36. type={expanded ? 'expand_more' : 'chevron_right'}
  37. className="file-tree-expand-icon"
  38. />
  39. </button>
  40. <MaterialIcon
  41. type={expanded ? 'folder_open' : 'folder'}
  42. className="file-tree-folder-icon"
  43. />
  44. </>
  45. )
  46. }
  47. export default FileTreeFolderIcons