From 30a0a2e3e1c9d8b0e9e2cc810ba19016a8990bd7 Mon Sep 17 00:00:00 2001 From: willowcheng Date: Sat, 15 Apr 2017 11:07:58 -0400 Subject: [PATCH] Remember width of down panel when it's displayed on right :art: - fix a typo error in example readme --- packages/storybook-ui/example/README.md | 2 +- .../src/modules/ui/components/layout/index.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/storybook-ui/example/README.md b/packages/storybook-ui/example/README.md index 75e0f771a30c..895289f7170c 100644 --- a/packages/storybook-ui/example/README.md +++ b/packages/storybook-ui/example/README.md @@ -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 . +Run the app with `npm start`. Then you'll be able to access the app via . Once you made a change to the example app or in the root module, the client app will reload again. diff --git a/packages/storybook-ui/src/modules/ui/components/layout/index.js b/packages/storybook-ui/src/modules/ui/components/layout/index.js index 0271e34704c7..ca379adbf55d 100755 --- a/packages/storybook-ui/src/modules/ui/components/layout/index.js +++ b/packages/storybook-ui/src/modules/ui/components/layout/index.js @@ -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; } }; @@ -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 (
@@ -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(); }} >