Open folder on click of folder item GitOrigin-RevId: 4af71533951ef183eec9dec4b4940470695f2f1d
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
|
|
|
|
function FileTreeFolderIcons({
|
|
expanded,
|
|
onExpandCollapseClick,
|
|
}: {
|
|
expanded: boolean
|
|
onExpandCollapseClick?: () => void
|
|
}) {
|
|
const { t } = useTranslation()
|
|
const newEditor = useIsNewEditorEnabled()
|
|
|
|
if (newEditor) {
|
|
return (
|
|
<>
|
|
<div
|
|
// TODO ide-redesign-cleanup: rename the class now its no longer a button
|
|
className="folder-expand-collapse-button"
|
|
aria-label={expanded ? t('collapse') : t('expand')}
|
|
>
|
|
<MaterialIcon
|
|
type={expanded ? 'expand_more' : 'chevron_right'}
|
|
className="file-tree-expand-icon"
|
|
/>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<button
|
|
onClick={onExpandCollapseClick}
|
|
aria-label={expanded ? t('collapse') : t('expand')}
|
|
>
|
|
<MaterialIcon
|
|
type={expanded ? 'expand_more' : 'chevron_right'}
|
|
className="file-tree-expand-icon"
|
|
/>
|
|
</button>
|
|
<MaterialIcon
|
|
type={expanded ? 'folder_open' : 'folder'}
|
|
className="file-tree-folder-icon"
|
|
/>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default FileTreeFolderIcons
|