mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-03-11 17:07:40 +00:00
Replace the previous monolithic MainContent.jsx with a typed one and extract focused subcomponents/hooks to improve readability, local state ownership, and maintainability while keeping runtime behavior unchanged. Key changes: - Replace `src/components/MainContent.jsx` with `src/components/MainContent.tsx`. - Add typed contracts for main-content domain in `src/components/main-content/types.ts`. - Extract header composition into: - `MainContentHeader.tsx` - `MainContentTitle.tsx` - `MainContentTabSwitcher.tsx` - `MobileMenuButton.tsx` - Extract loading/empty project views into `MainContentStateView.tsx`. - Extract editor presentation into `EditorSidebar.tsx`. - Move editor file-open + resize behavior into `useEditorSidebar.ts`. - Move mobile menu touch/click suppression logic into `useMobileMenuHandlers.ts`. - Extract TaskMaster-specific concerns into `TaskMasterPanel.tsx`: - task detail modal state - PRD editor modal state - PRD list loading/refresh - PRD save notification lifecycle Behavior/compatibility notes: - Preserve existing tab behavior, session passthrough props, and Chat/Git/File flows. - Keep interop with existing JS components via boundary `as any` casts where needed. - No intentional functional changes; this commit is structural/type-oriented refactor. Validation: - `npm run typecheck` passes. - `npm run build` passes (existing unrelated CSS minify warnings remain).
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import CodeEditor from '../CodeEditor';
|
|
import type { EditorSidebarProps } from './types';
|
|
|
|
const AnyCodeEditor = CodeEditor as any;
|
|
|
|
export default function EditorSidebar({
|
|
editingFile,
|
|
isMobile,
|
|
editorExpanded,
|
|
editorWidth,
|
|
resizeHandleRef,
|
|
onResizeStart,
|
|
onCloseEditor,
|
|
onToggleEditorExpand,
|
|
projectPath,
|
|
}: EditorSidebarProps) {
|
|
if (!editingFile) {
|
|
return null;
|
|
}
|
|
|
|
if (isMobile) {
|
|
return (
|
|
<AnyCodeEditor
|
|
file={editingFile}
|
|
onClose={onCloseEditor}
|
|
projectPath={projectPath}
|
|
isSidebar={false}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{!editorExpanded && (
|
|
<div
|
|
ref={resizeHandleRef}
|
|
onMouseDown={onResizeStart}
|
|
className="flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group"
|
|
title="Drag to resize"
|
|
>
|
|
<div className="absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity" />
|
|
</div>
|
|
)}
|
|
|
|
<div
|
|
className={`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${editorExpanded ? 'flex-1' : ''}`}
|
|
style={editorExpanded ? undefined : { width: `${editorWidth}px` }}
|
|
>
|
|
<AnyCodeEditor
|
|
file={editingFile}
|
|
onClose={onCloseEditor}
|
|
projectPath={projectPath}
|
|
isSidebar
|
|
isExpanded={editorExpanded}
|
|
onToggleExpand={onToggleEditorExpand}
|
|
/>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|