Skip to content

Commit

Permalink
fix: defaultSizes needs to be used (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
NomadBin committed Dec 5, 2021
1 parent 11206d7 commit cd2eae1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/allotment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ const Allotment = forwardRef<AllotmentHandle, AllotmentProps>(
const options: SplitViewOptions = {
orientation: vertical ? Orientation.Vertical : Orientation.Horizontal,
...(initializeSizes &&
sizes && {
defaultSizes && {
descriptor: {
size: sizes.reduce((a, b) => a + b, 0),
views: sizes.map((size, index) => ({
size: defaultSizes.reduce((a, b) => a + b, 0),
views: defaultSizes.map((size, index) => ({
container: [...splitViewViewRef.current.values()][index],
size: size,
view: {
Expand Down
12 changes: 12 additions & 0 deletions stories/allotment.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,15 @@ export const Reset: Story<AllotmentProps> = (args) => {
);
};
Reset.args = {};

export const DefaultSize: Story = () => {
return (
<div className={styles.container}>
<Allotment defaultSizes={[200, 400]}>
<div className={styles.content}>div1</div>
<div className={styles.content}>div2</div>
</Allotment>
</div>
);
};
DefaultSize.args = {};

0 comments on commit cd2eae1

Please sign in to comment.