javascript - ReactJS: Sidebar with multiple views -


i try build single-page react.js app sidebar. here desired effect:

enter image description here

imagine main page (area text settings sidebar) has button. when click on button, sidebar displays list of items. when click on item view details slides on list view. imagine right sidebar works iphone settings menu. each actions changes url (react-router).

is there working example? question on how organize kind of app when using react.

update:

manuel bitto wrote example , works except url-changing. se example using react-router because sidebar holds heavy content , url must change when open sidebar , when go deeper.

here basic example start, please note it's first time try use react improved lot:

<script type="text/jsx">  var closemenubutton = react.createclass({     render: function() {         return <button onclick={this.props.onclick}>{this.props.children}</button>;     } });  var menuitem = react.createclass({     render: function() {         return <div onclick={this.props.onclick} classname="menu-item">{this.props.children}</div>;     } });  var menu = react.createclass({     getinitialstate: function() {         return {             visible: false           };     },      show: function() {         this.setstate({ visible: true });     },      hide: function() {         this.setstate({ visible: false });     },       render: function() {         return <div classname="menu">             <div classname={(this.state.visible ? "visible" : "") + " right " + this.props.type}>               <closemenubutton onclick={this.hide}>close</closemenubutton>               {this.props.children}             </div>         </div>;     } });  var app = react.createclass({      showmenu: function() {         this.refs.menu.show();     },      showdeepermenu: function() {         this.refs.deepermenu.show();     },      render: function() {         return <div>             <h1>react js sliding menu</h1>             <button onclick={this.showmenu}>show menu!</button>              <menu ref="menu" alignment="right" type="main-menu">                 <menuitem onclick={this.showdeepermenu}>option 1</menuitem>                 <menuitem onclick={this.showdeepermenu}>option 2</menuitem>                 <menuitem onclick={this.showdeepermenu}>option 3</menuitem>             </menu>              <menu ref="deepermenu" alignment="right" type="deeper-menu">                 <menuitem>deep option 1</menuitem>                 <menuitem>deep option 2</menuitem>                 <menuitem>deep option 3</menuitem>             </menu>          </div>;     } });  react.render(<app />, document.body);  </script> 

plunker: http://plnkr.co/edit/fojeyujllaj5uyejyf0m?p=preview

references:


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -