react-toolbox/docs/app/components/layout/main/components/navigation.jsx

53 lines
1.3 KiB
React
Raw Normal View History

import React from 'react';
2015-10-29 22:49:21 +03:00
import { History } from 'react-router';
import { List, ListItem } from 'react-toolbox';
2015-10-30 08:50:13 +03:00
import components from '../modules/components';
2015-10-30 22:30:56 +03:00
import style from './navigation.scss';
2015-10-30 22:30:56 +03:00
const MainNavigation = React.createClass({
2015-10-29 22:49:21 +03:00
mixins: [History],
propTypes: {
active: React.PropTypes.bool
},
2015-10-29 22:49:21 +03:00
renderDrawerItems () {
2015-10-30 08:50:13 +03:00
return Object.keys(components).map((key) => {
const ToolboxComponent = components[key];
2015-10-29 22:49:21 +03:00
const to = this.context.history.createHref(ToolboxComponent.path);
let className = style.item;
if (this.context.history.isActive(ToolboxComponent.path)) {
className += ` ${style.active}`;
}
return (
<ListItem
key={key}
caption={ToolboxComponent.name}
className={className}
selectable
to={to}
/>
);
});
},
render () {
let className = style.root;
2015-10-30 22:30:56 +03:00
if (this.props.className) className += ` ${this.props.className}`;
return (
<aside className={className}>
<List className={style.list} selectable ripple>
2015-10-29 22:49:21 +03:00
{ this.renderDrawerItems() }
</List>
<footer className={style.footer}>
<span>React Toolbox ©</span>
</footer>
</aside>
);
2015-10-29 22:49:21 +03:00
}
});
2015-10-30 22:30:56 +03:00
export default MainNavigation;