diff --git a/docs/navbar/api.md b/docs/navbar/api.md
index 3e7887b..dccd269 100644
--- a/docs/navbar/api.md
+++ b/docs/navbar/api.md
@@ -28,6 +28,7 @@ const leftNav = [
component: 'a', // 默认为 `a`
title: 'Left',
href: '',
+ isCloning: false, // 可选,如果 component 为 OffCanvas 之类的组件时,设为 true
props: {
}, // 其他要传递的属性
},
diff --git a/kitchen-sink/pages/NavBarExample.js b/kitchen-sink/pages/NavBarExample.js
index 7ecee47..cedd879 100644
--- a/kitchen-sink/pages/NavBarExample.js
+++ b/kitchen-sink/pages/NavBarExample.js
@@ -4,6 +4,8 @@ import {
Group,
NavBar,
amStyles,
+ OffCanvas,
+ OffCanvasTrigger,
} from 'amazeui-touch';
const clickHandler = (item, e) => {
@@ -40,6 +42,19 @@ const dataRight = {
onAction: clickHandler,
};
+var withOffCanvas = {
+ title: 'With OffCanvas',
+ rightNav: [{
+ icon: 'bars',
+ title: 'Menu',
+ component: OffCanvasTrigger,
+ isCloning: true, // IMPORTANT
+ props: {
+ offCanvas: OffCanvas 内容
,
+ }
+ }],
+};
+
const NavBarExample = React.createClass({
renderStyles(style, index) {
return (
@@ -87,6 +102,15 @@ const NavBarExample = React.createClass({
titleOnLeft
/>
+
+
+
+
);
}
diff --git a/src/js/NavBar.js b/src/js/NavBar.js
index eaa6828..651bb85 100644
--- a/src/js/NavBar.js
+++ b/src/js/NavBar.js
@@ -55,14 +55,17 @@ const NavBar = React.createClass({
renderNavItem(item, index) {
let Component = item.component || 'a';
let itemProps = item.props || {};
- let navTitle = item.title ? (
+ let children = [];
+
+ item.title && children.push(
{item.title}
- ) : null;
+ );
+
let navIconKey = 'icon';
let navIcon = item.customIcon ? (
) : null;
+ navIcon && children.push(navIcon);
+
+ let {
+ itemClassName,
+ ...otherProps
+ } = itemProps;
+ let props = {
+ href: item.href,
+ key: 'navbarNavItem' + index,
+ onClick: this.props.onAction.bind(this, item),
+ ...otherProps,
+ className: classNames(this.prefixClass('nav-item'), itemClassName),
+ };
+ let renderChildren = () => {
+ // #40
+ // if `Component` is a cloning type like OffCanvasTrigger,
+ // this should return a element with the className.
+ // TBC: should other props be transferred to the span element?
+ return item.isCloning ? (
+
+ {children}
+
+ ) : children;
+ };
+
return (
-
- {[navTitle, navIcon]}
+
+ {renderChildren()}
);
},