-
-
Notifications
You must be signed in to change notification settings - Fork 218
Introduced autoResize prop in Panel component #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3152786
Introduced autoResize prop in Panel component to control automatic re…
SabbeAndres 677bd84
Add autoResize feature and examples for fixed sidebar panel
SabbeAndres d8aef52
Add fixed sidebar panel example and routing
SabbeAndres b95d86d
Add autoResize prop documentation and examples for sidebar panels
SabbeAndres dc1eff8
Refactor formatting and improve readability in AutoResizeSidebarRoute…
SabbeAndres f25c426
Moved preserveNonAutoResizingPanelSizes utility function to lib/globa…
SabbeAndres 1b3665a
Removed PersistentFixedSidebar example
SabbeAndres 3715203
Add test for preserving pixel size in Group when autoResize is false
SabbeAndres 544df50
Refactor panel resizing behavior: replace autoResize prop with groupR…
SabbeAndres 1776548
Add tests. Update docs. Make a few stylistic changes.
bvaughn 57de6f4
Update CHANGELOG with pending release changes
bvaughn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { describe, expect, test } from "vitest"; | ||
| import { mountGroup } from "./mountGroup"; | ||
| import { getMountedGroupState } from "./mutable-state/groups"; | ||
| import { mockGroup } from "./test/mockGroup"; | ||
| import { setElementBounds } from "../utils/test/mockBoundingClientRect"; | ||
|
|
||
| describe("mountGroup autoResize", () => { | ||
| test("preserves pixel size for panels with autoResize=false when group size changes", () => { | ||
| const group = mockGroup(new DOMRect(0, 0, 1000, 50), { | ||
| id: "group", | ||
| orientation: "horizontal" | ||
| }); | ||
|
|
||
| group.addPanel(new DOMRect(0, 0, 200, 50), "left", { | ||
| autoResize: false, | ||
| defaultSize: 200 | ||
| }); | ||
| group.addPanel(new DOMRect(200, 0, 800, 50), "right", { | ||
| defaultSize: 800 | ||
| }); | ||
|
|
||
| const unmountGroup = mountGroup(group); | ||
|
|
||
| try { | ||
| const initialState = getMountedGroupState("group", true); | ||
| expect(initialState.layout).toEqual({ | ||
| "group-left": 20, | ||
| "group-right": 80 | ||
| }); | ||
|
|
||
| setElementBounds(group.panels[0].element, new DOMRect(0, 0, 200, 50)); | ||
| setElementBounds(group.panels[1].element, new DOMRect(200, 0, 1000, 50)); | ||
| setElementBounds(group.element, new DOMRect(0, 0, 1200, 50)); | ||
|
|
||
| const nextState = getMountedGroupState("group", true); | ||
|
|
||
| expect(nextState.groupSize).toBe(1200); | ||
|
|
||
| const leftSizeInPixels = (nextState.layout["group-left"] / 100) * 1200; | ||
| const rightSizeInPixels = (nextState.layout["group-right"] / 100) * 1200; | ||
|
|
||
| expect(leftSizeInPixels).toBeCloseTo(200, 2); | ||
| expect(rightSizeInPixels).toBeCloseTo(1000, 2); | ||
| } finally { | ||
| unmountGroup(); | ||
| } | ||
| }); | ||
|
SabbeAndres marked this conversation as resolved.
Outdated
|
||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "html": "<div><span class=\"tok-punctuation\"><</span><span class=\"tok-typeName\">Group</span><span class=\"tok-punctuation\">></span><span class=\"\"></span></div>\n<div><span class=\"\"> </span><span class=\"tok-punctuation\"><</span><span class=\"tok-typeName\">Panel</span><span class=\"\"> </span><span class=\"tok-propertyName\">autoResize</span><span class=\"tok-operator\">=</span><span class=\"tok-punctuation\">{</span><span class=\"tok-bool\">false</span><span class=\"tok-punctuation\">}</span><span class=\"\"> </span><span class=\"tok-propertyName\">defaultSize</span><span class=\"tok-operator\">=</span><span class=\"tok-punctuation\">{</span><span class=\"tok-number\">280</span><span class=\"tok-punctuation\">}</span><span class=\"\"> </span><span class=\"tok-propertyName\">minSize</span><span class=\"tok-operator\">=</span><span class=\"tok-punctuation\">{</span><span class=\"tok-number\">200</span><span class=\"tok-punctuation\">}</span><span class=\"\"> </span><span class=\"tok-propertyName\">maxSize</span><span class=\"tok-operator\">=</span><span class=\"tok-punctuation\">{</span><span class=\"tok-number\">420</span><span class=\"tok-punctuation\">}</span><span class=\"tok-punctuation\">></span><span class=\"\"></span></div>\n<div><span class=\"\"> left sidebar</span></div>\n<div><span class=\"\"> </span><span class=\"tok-punctuation\"></</span><span class=\"tok-typeName\">Panel</span><span class=\"tok-punctuation\">></span><span class=\"\"></span></div>\n<div><span class=\"\"> </span><span class=\"tok-punctuation\"><</span><span class=\"tok-typeName\">Separator</span><span class=\"\"> </span><span class=\"tok-punctuation\">/></span><span class=\"\"></span></div>\n<div><span class=\"\"> </span><span class=\"tok-punctuation\"><</span><span class=\"tok-typeName\">Panel</span><span class=\"tok-punctuation\">></span><span class=\"\">main content</span><span class=\"tok-punctuation\"></</span><span class=\"tok-typeName\">Panel</span><span class=\"tok-punctuation\">></span><span class=\"\"></span></div>\n<div><span class=\"\"></span><span class=\"tok-punctuation\"></</span><span class=\"tok-typeName\">Group</span><span class=\"tok-punctuation\">></span></div>" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.