Created
July 20, 2017 05:32
-
-
Save leefsmp/28ceb226d119d179d1e94466d2dd1a8b to your computer and use it in GitHub Desktop.
Storage Re-Flex Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////// | |
// Re-Flex Storage demo | |
// | |
///////////////////////////////////////////////////////// | |
class ReflexStorageDemo | |
extends React.Component { | |
constructor (props) { | |
super (props) | |
this.onResizePane = this.onResizePane.bind(this) | |
this.layoutState = this.getLayoutState() | |
} | |
getLayoutState () { | |
const item = window.localStorage.getItem( | |
"re-flex-storage-demo") | |
if (item) { | |
return JSON.parse(item) | |
} | |
return { | |
appPane: { | |
flex: 0.8 | |
}, | |
rightPane: { | |
flex: 0.2 | |
} | |
} | |
} | |
onResizePane (event) { | |
const { name, flex } = event.component.props | |
this.layoutState[name].flex = flex | |
window.localStorage.setItem( | |
"re-flex-storage-demo", | |
JSON.stringify(this.layoutState)) | |
} | |
render () { | |
return ( | |
<ReflexContainer orientation="vertical"> | |
<ReflexElement> | |
<ReflexContainer orientation="horizontal"> | |
<ReflexElement flex={this.layoutState.appPane.flex} | |
onResize={this.onResizePane} | |
name="appPane"> | |
<div className="pane-content"> | |
<label> | |
App Pane | |
</label> | |
</div> | |
</ReflexElement> | |
<ReflexSplitter/> | |
<ReflexElement className="bottom-pane"> | |
<div className="pane-content"> | |
<label> | |
Bottom Pane | |
</label> | |
</div> | |
</ReflexElement> | |
</ReflexContainer> | |
</ReflexElement> | |
<ReflexSplitter/> | |
<ReflexElement flex={this.layoutState.rightPane.flex} | |
onResize={this.onResizePane} | |
className="right-pane" | |
name="rightPane"> | |
<div className="pane-content"> | |
<label> | |
Right Pane | |
</label> | |
</div> | |
</ReflexElement> | |
</ReflexContainer> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment