feat: Folder column size adjustment (#384)

This commit is contained in:
CY
2026-01-29 07:53:24 +08:00
committed by GitHub
parent 34135209d9
commit fe8983e212
3 changed files with 21 additions and 11 deletions

View File

@@ -4,16 +4,22 @@ import { useState, useRef, useEffect, ReactNode } from 'react';
type Props = {
leftPane: ReactNode;
rightPane: ReactNode;
minLeftWidth?: number;
minRightWidth?: number;
defaultLeftWidth?: number;
};
export default function ResizablePanes({ leftPane, rightPane }: Props) {
const [leftWidth, setLeftWidth] = useState(70); // default 70%
export default function ResizablePanes({
leftPane,
rightPane,
minLeftWidth = 40,
minRightWidth = 15,
defaultLeftWidth = 70,
}: Props) {
const [leftWidth, setLeftWidth] = useState(defaultLeftWidth); // default 70%
const [isDragging, setIsDragging] = useState(false);
const containerRef = useRef<HTMLDivElement>(null);
const minLeftWidth = 40; // left panel min width 40%
const minRightWidth = 15; // right panel min width 15%
const handleMouseDown = () => {
setIsDragging(true);
};
@@ -45,7 +51,7 @@ export default function ResizablePanes({ leftPane, rightPane }: Props) {
document.removeEventListener('mousemove', handleMouseMove);
document.removeEventListener('mouseup', handleMouseUp);
};
}, [isDragging]);
}, [isDragging, minLeftWidth, minRightWidth]);
return (
<div ref={containerRef} className="flex h-full" style={{ userSelect: isDragging ? 'none' : 'auto' }}>