Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

save height of down panel in local storage #62 #74

Merged
merged 4 commits into from
Apr 5, 2017
Merged
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
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