editor-sidebar.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { Panel, PanelGroup } from 'react-resizable-panels'
  2. import { VerticalResizeHandle } from '@/features/ide-react/components/resize/vertical-resize-handle'
  3. import { FileTree } from '@/features/ide-react/components/file-tree'
  4. import classNames from 'classnames'
  5. import { useLayoutContext } from '@/shared/context/layout-context'
  6. import { OutlineContainer } from '@/features/outline/components/outline-container'
  7. import { useOutlinePane } from '@/features/ide-react/hooks/use-outline-pane'
  8. export default function EditorSidebar() {
  9. const { view } = useLayoutContext()
  10. const { outlineEnabled, outlinePanelRef } = useOutlinePane()
  11. return (
  12. <aside
  13. className={classNames('ide-react-editor-sidebar', {
  14. hidden: view === 'history',
  15. })}
  16. >
  17. <PanelGroup autoSaveId="ide-editor-sidebar-layout" direction="vertical">
  18. <Panel
  19. defaultSize={50}
  20. minSize={25}
  21. className="ide-react-file-tree-panel"
  22. id="panel-file-tree"
  23. order={1}
  24. >
  25. <FileTree />
  26. </Panel>
  27. <VerticalResizeHandle disabled={!outlineEnabled} />
  28. <Panel
  29. defaultSize={50}
  30. maxSize={75}
  31. id="panel-outline"
  32. order={2}
  33. collapsible
  34. ref={outlinePanelRef}
  35. style={{ minHeight: 32 }} // keep the header visible
  36. >
  37. <OutlineContainer />
  38. </Panel>
  39. </PanelGroup>
  40. </aside>
  41. )
  42. }