Skip to content
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

Remember width of down panel when it's displayed on right #780

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/storybook-ui/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ npm install

### Running the App

Run the app with `npm start`. Then you'll be able to a cess the app via <http://localhost:9999>.
Run the app with `npm start`. Then you'll be able to access the app via <http://localhost:9999>.

Once you made a change to the example app or in the root module, the client app will reload again.

Expand Down
16 changes: 8 additions & 8 deletions packages/storybook-ui/src/modules/ui/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ const onDragEnd = function() {
document.body.classList.remove('dragging');
};

const saveHeightPanel = h => {
const savePanelPosition = (downPanelInRight, pos) => {
try {
localStorage.setItem('splitPos', h);
localStorage.setItem(downPanelInRight ? 'verticalSplitPos' : 'horizontalSplitPos', pos);
return true;
} catch (e) {
return false;
}
};

const getSavedHeight = h => {
const getSavedPosition = (downPanelInRight, pos) => {
try {
return localStorage.getItem('splitPos');
return localStorage.getItem(downPanelInRight ? 'verticalSplitPos' : 'horizontalSplitPos');
} catch (e) {
return h;
return pos;
}
};

Expand Down Expand Up @@ -143,7 +143,7 @@ class Layout extends React.Component {
}

// Get the value from localStorage or user downPanelDefaultSize
downPanelDefaultSize = getSavedHeight(downPanelDefaultSize);
downPanelDefaultSize = getSavedPosition(downPanelInRight, downPanelDefaultSize);

return (
<div style={rootStyle}>
Expand All @@ -168,8 +168,8 @@ class Layout extends React.Component {
resizerChildren={downPanelInRight ? vsplit : hsplit}
onDragStarted={onDragStart}
onDragFinished={onDragEnd}
onChange={size => {
saveHeightPanel(size);
onChange={position => {
savePanelPosition(downPanelInRight, position);
this.onResize();
}}
>
Expand Down