From 85256feada3cff22b38d614a0350b4d739685135 Mon Sep 17 00:00:00 2001 From: Ty Date: Fri, 23 Oct 2015 18:28:05 +0100 Subject: [PATCH] LeftNav support nested children (w/o menuItems) --- .../components/pages/components/left-nav.jsx | 20 +++++++--- .../app/components/raw-code/left-nav-code.txt | 6 +++ src/left-nav.jsx | 38 +++++++++++-------- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/docs/src/app/components/pages/components/left-nav.jsx b/docs/src/app/components/pages/components/left-nav.jsx index 534612fc2736b1..a1052f9d8a8077 100644 --- a/docs/src/app/components/pages/components/left-nav.jsx +++ b/docs/src/app/components/pages/components/left-nav.jsx @@ -11,7 +11,7 @@ export default class LeftNavPage extends React.Component { super(); this._showLeftNavClick = this._showLeftNavClick.bind(this); this._toggleDockedLeftNavClick = this._toggleDockedLeftNavClick.bind(this); - + this._showLeftNavChildrenClick = this._showLeftNavChildrenClick.bind(this); this.state = { isDocked: false, }; @@ -56,7 +56,7 @@ export default class LeftNavPage extends React.Component { { name: 'menuItems', type: 'array', - header: 'required', + header: 'optional', desc: 'JSON data representing all menu items to render.', }, { @@ -143,10 +143,18 @@ export default class LeftNavPage extends React.Component { componentInfo={componentInfo}>
-

- +
+

+

+

+
+ + + Menu Item + Link +
@@ -156,7 +164,9 @@ export default class LeftNavPage extends React.Component { _showLeftNavClick() { this.refs.leftNav.toggle(); } - + _showLeftNavChildrenClick() { + this.refs.leftNavChildren.toggle(); + } _toggleDockedLeftNavClick() { this.refs.dockedLeftNav.toggle(); this.setState({ diff --git a/docs/src/app/components/raw-code/left-nav-code.txt b/docs/src/app/components/raw-code/left-nav-code.txt index 12ff19d6023893..4e77ce37e73da3 100644 --- a/docs/src/app/components/raw-code/left-nav-code.txt +++ b/docs/src/app/components/raw-code/left-nav-code.txt @@ -28,3 +28,9 @@ this.refs.leftNav.toggle(); //Hideable Left Nav + +//Hideable Left Nav with Nested Children + + Menu Item + Link + diff --git a/src/left-nav.jsx b/src/left-nav.jsx index afac394473c5bd..4178fc29841c2c 100644 --- a/src/left-nav.jsx +++ b/src/left-nav.jsx @@ -42,7 +42,7 @@ const LeftNav = React.createClass({ disableSwipeToOpen: React.PropTypes.bool, docked: React.PropTypes.bool, header: React.PropTypes.element, - menuItems: React.PropTypes.array.isRequired, + menuItems: React.PropTypes.array, onChange: React.PropTypes.func, onNavOpen: React.PropTypes.func, onNavClose: React.PropTypes.func, @@ -181,7 +181,27 @@ const LeftNav = React.createClass({ onTouchTap={this._onOverlayTouchTap} /> ); } - + let children; + if (this.props.menuItems === undefined) { + children = this.props.children; + } + else { + children = ( + + ); + } return (
{overlay} @@ -195,19 +215,7 @@ const LeftNav = React.createClass({ this.props.openRight && styles.rootWhenOpenRight, this.props.style)}> {this.props.header} - + {children}
);