import React from 'react';
import NavSidebarUserPanel from './nav-sidebar-user-panel.jsx';
import PropTypes from 'prop-types';
class NavSidebar extends React.Component {
constructor(props) {
super(props);
this.getBetterChildren = this.getBetterChildren.bind(this);
}
getBetterChildren() {
Iif (this.props.children) {
return React.Children.map(this.props.children, (child, i) => {
if (child.type === NavSidebarUserPanel) {
return React.cloneElement(child, { passErr: this.props.passErr, key: i });
} else {
return React.cloneElement(child, { key: i });
}
});
}
}
render() {
const betterChildren = this.getBetterChildren();
return (
<aside className={`main-sidebar${this.props.lightTheme ? ' main-sidebar-light' : ''}`}>
<section className="sidebar">
{betterChildren}
</section>
</aside>
);
}
}
NavSidebar.propTypes = {
passErr: PropTypes.string,
lightTheme: PropTypes.bool
};
NavSidebar.defaultProps = {
lightTheme: false
};
export default NavSidebar;
|