allotment icon indicating copy to clipboard operation
allotment copied to clipboard

Allotment.Pane add prop defaultSize

Open NomadBin opened this issue 4 years ago • 4 comments

The Allotment.Pane seem to use the maxSize to as a default size. But I want to controll the default pane size. so. I think that is great to add prop defaultSize.

example code:

<Allotment.Pane maxSize={200} minSize={100} defaultSize={100}>
  <div>div1</div>
</Allotment.Pane>

NomadBin avatar Dec 27 '21 03:12 NomadBin

I tried using the defaultSizes property of Allotment, but it seemed to clash with the minSize and maxSize of the Allotment.Pane

NomadBin avatar Dec 27 '21 03:12 NomadBin

That makes sense. I'll have a go at implementing something and let you know when it's ready to test.

A particular use case I have in mind is for an editor like VS Code where you'd have two panes side by side. The left one being the directory tree view and the right one being the file editor. You'd want to fix the initial size of the left pane.

The reason it's not completely trivial is that you could imagine implementing a full-on flexbox-like layout algorithm (which is close to what VS Code does). Perhaps a simple starting point would be to attempt to give the panes with a specified size that size and allocate the remaining space evenly between the panes without a specified size. I say 'attempt' because if you ask for sizes which sum to more than the available space then we can't satisfy that requirement. Similarly, minSize would interact with this too.

johnwalley avatar Dec 27 '21 22:12 johnwalley

A particular use case

Yes, my application scenario is similar to vscode.

Thank you for your hard work, waiting for your progress.

NomadBin avatar Dec 28 '21 10:12 NomadBin

I tried using the defaultSizes property of Allotment, but it seemed to clash with the minSize and maxSize of the Allotment.Pane

I have this issue too. Shouldn't is be possible to use defaultSizes and minSize together @johnwalley ?

pahen avatar Feb 22 '22 14:02 pahen