file-tree-folder-icons.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { useTranslation } from 'react-i18next'
  2. import Icon from '../../../shared/components/icon'
  3. import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
  4. import MaterialIcon from '@/shared/components/material-icon'
  5. import { useFeatureFlag } from '@/shared/context/split-test-context'
  6. function FileTreeFolderIcons({
  7. expanded,
  8. onExpandCollapseClick,
  9. }: {
  10. expanded: boolean
  11. onExpandCollapseClick: () => void
  12. }) {
  13. const { t } = useTranslation()
  14. const newEditor = useFeatureFlag('editor-redesign')
  15. if (newEditor) {
  16. return (
  17. <>
  18. <button
  19. className="folder-expand-collapse-button"
  20. onClick={onExpandCollapseClick}
  21. aria-label={expanded ? t('collapse') : t('expand')}
  22. >
  23. <MaterialIcon
  24. type={expanded ? 'expand_more' : 'chevron_right'}
  25. className="file-tree-expand-icon"
  26. />
  27. </button>
  28. </>
  29. )
  30. }
  31. return (
  32. <BootstrapVersionSwitcher
  33. bs3={
  34. <>
  35. <button
  36. onClick={onExpandCollapseClick}
  37. aria-label={expanded ? t('collapse') : t('expand')}
  38. >
  39. <Icon
  40. type={expanded ? 'angle-down' : 'angle-right'}
  41. fw
  42. className="file-tree-expand-icon"
  43. />
  44. </button>
  45. <Icon
  46. type={expanded ? 'folder-open' : 'folder'}
  47. fw
  48. className="file-tree-folder-icon"
  49. />
  50. </>
  51. }
  52. bs5={
  53. <>
  54. <button
  55. onClick={onExpandCollapseClick}
  56. aria-label={expanded ? t('collapse') : t('expand')}
  57. >
  58. <MaterialIcon
  59. type={expanded ? 'expand_more' : 'chevron_right'}
  60. className="file-tree-expand-icon"
  61. />
  62. </button>
  63. <MaterialIcon
  64. type={expanded ? 'folder_open' : 'folder'}
  65. className="file-tree-folder-icon"
  66. />
  67. </>
  68. }
  69. />
  70. )
  71. }
  72. export default FileTreeFolderIcons