-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Panel visibility can be toggled on/off
- Loading branch information
Showing
26 changed files
with
674 additions
and
101 deletions.
There are no files selected for viewing
This file contains 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,10 @@ | ||
# Changelog | ||
|
||
## 0.0.3 | ||
* [#3](https://github.com/bvaughn/react-resizable-panels/issues/3): `Panel` visibility can be toggled on/off. `PanelGroup` will persist separate layouts for each combination of visible panels. | ||
|
||
## 0.0.2 | ||
* Documentation-only update. | ||
|
||
## 0.0.1 | ||
* Initial release. |
This file contains 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 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,4 @@ | ||
declare module "*.module.css" { | ||
const content: Record<string, string>; | ||
export default content; | ||
} |
This file contains 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 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,7 @@ | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { StrictMode } from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import App from "./src/App"; | ||
var rootElement = document.getElementById("root"); | ||
var root = createRoot(rootElement); | ||
root.render(_jsx(StrictMode, { children: _jsx(App, {}) })); |
This file contains 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,29 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { useCallback, useState } from "react"; | ||
import HorizontalGroup from "./HorizontalGroup"; | ||
import styles from "./styles.module.css"; | ||
export default function DemoApp() { | ||
var _a = useState(0), key = _a[0], setKey = _a[1]; | ||
var clearSavedSizes = useCallback(function () { | ||
var groupIds = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
groupIds[_i] = arguments[_i]; | ||
} | ||
groupIds.forEach(function (groupId) { | ||
localStorage.removeItem("PanelGroup:sizes:".concat(groupId)); | ||
}); | ||
setKey(function (prevKey) { return prevKey + 1; }); | ||
}, []); | ||
return (_jsx("div", __assign({ className: styles.FullHeightAndWidth }, { children: _jsx(HorizontalGroup, { clearSavedSizes: clearSavedSizes }, key) }))); | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/react-resizable-panels-website/src/AutoSizedPanelGroup.js
This file contains 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,4 @@ | ||
import { PanelGroup } from "react-resizable-panels"; | ||
import withAutoSizer from "./withAutoSizer"; | ||
var AutoSizedPanelGroup = withAutoSizer(PanelGroup); | ||
export default AutoSizedPanelGroup; |
21 changes: 21 additions & 0 deletions
21
packages/react-resizable-panels-website/src/HorizontalGroup.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
23 changes: 23 additions & 0 deletions
23
packages/react-resizable-panels-website/src/VerticalGroup.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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
22 changes: 22 additions & 0 deletions
22
packages/react-resizable-panels-website/src/withAutoSizer.js
This file contains 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,22 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import { createElement } from "react"; | ||
import AutoSizer from "react-virtualized-auto-sizer"; | ||
export default function withAutoSizer(Component, autoSizerProps) { | ||
var AutoSizerWrapper = function (props) { | ||
return createElement(AutoSizer, __assign(__assign({}, autoSizerProps), { children: function (_a) { | ||
var height = _a.height, width = _a.width; | ||
return createElement(Component, __assign(__assign({}, props), { height: height, width: width })); | ||
} })); | ||
}; | ||
return AutoSizerWrapper; | ||
} |
This file contains 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,42 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { useContext, useLayoutEffect } from "react"; | ||
import { PanelGroupContext } from "./PanelContexts"; | ||
// TODO [panels] | ||
// Support min pixel size too. | ||
// PanelGroup should warn if total width is less min pixel widths. | ||
export default function Panel(_a) { | ||
var _b = _a.children, children = _b === void 0 ? null : _b, _c = _a.className, className = _c === void 0 ? "" : _c, _d = _a.defaultSize, defaultSize = _d === void 0 ? 0.1 : _d, id = _a.id, _e = _a.minSize, minSize = _e === void 0 ? 0.1 : _e; | ||
var context = useContext(PanelGroupContext); | ||
if (context === null) { | ||
throw Error("Panel components must be rendered within a PanelGroup container"); | ||
} | ||
if (minSize > defaultSize) { | ||
console.error("Panel minSize ".concat(minSize, " cannot be greater than defaultSize ").concat(defaultSize)); | ||
defaultSize = minSize; | ||
} | ||
var getPanelStyle = context.getPanelStyle, registerPanel = context.registerPanel, unregisterPanel = context.unregisterPanel; | ||
useLayoutEffect(function () { | ||
var panel = { | ||
defaultSize: defaultSize, | ||
id: id, | ||
minSize: minSize | ||
}; | ||
registerPanel(id, panel); | ||
return function () { | ||
unregisterPanel(id); | ||
}; | ||
}, [defaultSize, id, minSize, registerPanel, unregisterPanel]); | ||
var style = getPanelStyle(id); | ||
return (_jsx("div", __assign({ className: className, style: style }, { children: children }))); | ||
} |
This file contains 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 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,2 @@ | ||
import { createContext } from "react"; | ||
export var PanelGroupContext = createContext(null); |
Oops, something went wrong.
9a31799
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-resizable-panels – ./
react-resizable-panels-git-main-bvaughn.vercel.app
react-resizable-panels.vercel.app
react-resizable-panels-bvaughn.vercel.app