framework/js/lib/components/nav-item.js

18 lines
555 B
JavaScript
Raw Normal View History

2015-04-25 20:58:39 +08:00
import Component from 'flarum/component'
import icon from 'flarum/helpers/icon'
export default class NavItem extends Component {
view() {
2015-05-02 07:15:52 +08:00
var active = this.constructor.active(this.props);
2015-04-25 20:58:39 +08:00
return m('li'+(active ? '.active' : ''), m('a', {href: this.props.href, config: m.route}, [
icon(this.props.icon+' icon'),
2015-04-25 20:58:39 +08:00
this.props.label, ' ',
2015-05-02 07:15:52 +08:00
this.props.badge ? m('span.count', this.props.badge) : ''
2015-04-25 20:58:39 +08:00
]))
}
static active(props) {
return typeof props.active !== 'undefined' ? props.active : m.route() === props.href;
}
}