Skip to content

Commit

Permalink
Merge pull request #74 from wcastand/master
Browse files Browse the repository at this point in the history
save height of down panel in local storage #62
  • Loading branch information
benediktvaldez authored Apr 5, 2017
2 parents ff5d73d + 03c28f7 commit e01f169
Show file tree
Hide file tree
Showing 6 changed files with 938 additions and 914 deletions.
6 changes: 3 additions & 3 deletions dist/modules/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ exports.default = {
defaultState: {
uiOptions: {
name: 'REACT STORYBOOK',
sortStoriesByKind: false,
url: 'https://github.com/storybooks/react-storybook'
url: 'https://github.com/storybooks/react-storybook',
sortStoriesByKind: false
}
},
load: function load(_ref, _actions) {
Expand All @@ -29,4 +29,4 @@ exports.default = {

(0, _init_api2.default)(provider, clientStore, _actions);
}
};
};
14 changes: 13 additions & 1 deletion dist/modules/ui/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ var Layout = function (_React$Component) {
downPanelDefaultSize = downPanelInRight ? 400 : 200;
}

if (typeof localStorage !== 'undefined') {
var savedSize = localStorage.getItem('splitPos');
if (typeof savedSize !== 'undefined') {
downPanelDefaultSize = savedSize;
}
}

return _react2.default.createElement(
'div',
{ style: rootStyle },
Expand Down Expand Up @@ -164,7 +171,12 @@ var Layout = function (_React$Component) {
defaultSize: downPanelDefaultSize,
resizerChildren: downPanelInRight ? vsplit : hsplit,
onDragStarted: onDragStart,
onDragFinished: onDragEnd
onDragFinished: onDragEnd,
onChange: function onChange(size) {
if (typeof localStorage !== 'undefined') {
localStorage.setItem('splitPos', size);
}
}
},
_react2.default.createElement(
'div',
Expand Down
2 changes: 1 addition & 1 deletion dist/modules/ui/components/left_panel/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var Header = function Header(_ref) {
),
_react2.default.createElement(
'a',
{ style: linkStyle, href: url, target: '_blank' },
{ style: linkStyle, href: url, target: '_blank', rel: 'noopener noreferrer' },
_react2.default.createElement(
'h3',
{ style: headingStyle },
Expand Down
27 changes: 26 additions & 1 deletion src/modules/ui/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ const onDragEnd = function () {
document.body.classList.remove('dragging');
};

const saveHeightPanel = h => {
try {
localStorage.setItem('splitPos', h);
return true;
} catch (e) {
return false;
}
};

const getSavedHeight = h => {
try {
return localStorage.getItem('splitPos');
} catch (e) {
return h;
}
};

class Layout extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -124,6 +141,9 @@ class Layout extends React.Component {
downPanelDefaultSize = downPanelInRight ? 400 : 200;
}

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

return (
<div style={rootStyle}>
<SplitPane
Expand All @@ -147,7 +167,12 @@ class Layout extends React.Component {
resizerChildren={downPanelInRight ? vsplit : hsplit}
onDragStarted={onDragStart}
onDragFinished={onDragEnd}
onChange={this.onResize}
onChange={
size => {
saveHeightPanel(size);
this.onResize();
}
}
>
<div style={contentPanelStyle}>
<div
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ui/components/shortcuts_help.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const ShortcutsHelp = ({ isOpen, onClose, platform }) => (
isOpen = {isOpen}
onRequestClose = {onClose}
style = {modalStyles}
contentLabel = 'Shortcuts'
contentLabel = "Shortcuts"
>
<Shortcuts appShortcuts = {getShortcuts(platform)} />
</ReactModal>
Expand Down
Loading

0 comments on commit e01f169

Please sign in to comment.