feat: Folder column size adjustment (#384)
This commit is contained in:
@@ -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' }}>
|
||||
|
||||
Reference in New Issue
Block a user