Skip to content

Instantly share code, notes, and snippets.

@michaltakac
Created November 20, 2015 22:50
Show Gist options
  • Save michaltakac/44d27c3c4066f5b8fc88 to your computer and use it in GitHub Desktop.
Save michaltakac/44d27c3c4066f5b8fc88 to your computer and use it in GitHub Desktop.
Meteorboard - sidebar changing
import Component from 'react-pure-render/component';
import React, {PropTypes} from 'react';
import SidebarMenu from './SidebarMenu.react';
import {Image} from 'react-bootstrap';
import {Link} from 'react-router';
export default class Sidebar extends Component {
static propTypes = {
location: PropTypes.string.isRequired,
mainMenu: PropTypes.object.isRequired,
profileMenu: PropTypes.object.isRequired,
ui: PropTypes.object.isRequired
}
render() {
const pathname = this.props.location;
const sidebarOpen = this.props.ui.isSideMenuOpen;
const miniMenu = sidebarOpen ? 'sidebar mini-menu' : 'sidebar';
const mainMenu = this.props.mainMenu.children()
.map((menu, i) => <SidebarMenu key={i} location={pathname} menu={menu} />);
const profileMenu = this.props.profileMenu.children()
.map((menu, i) => <SidebarMenu key={i} location={pathname} menu={menu} />);
return (
<div className={miniMenu} id="sidebar">
<Link to='/'>
<Image circle className='profile-pic' src="img/profile/twitter-avatar.png" />
</Link>
<div className="sidebar-menu nav-collapse">
<div className="divide-20"></div>
<ul>
{profileMenu}
<div className='divide-20'></div> // small space between menus
{mainMenu}
<div className='divide-20'></div>
</ul>
</div>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment