framework/js/lib/components/nav-item.js
2015-04-25 22:28:39 +09:30

18 lines
514 B
JavaScript

import Component from 'flarum/component'
import icon from 'flarum/helpers/icon'
export default class NavItem extends Component {
view() {
var active = NavItem.active(this.props);
return m('li'+(active ? '.active' : ''), m('a', {href: this.props.href, config: m.route}, [
icon(this.props.icon),
this.props.label, ' ',
m('span.count', this.props.badge)
]))
}
static active(props) {
return typeof props.active !== 'undefined' ? props.active : m.route() === props.href;
}
}