Skip to content

Commit

Permalink
Remember width of down panel when it's displayed on right 🎨
Browse files Browse the repository at this point in the history
- fix a typo error in example readme
  • Loading branch information
willowcheng committed Apr 15, 2017
1 parent dedc238 commit 30a0a2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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

0 comments on commit 30a0a2e

Please sign in to comment.