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}, [
|
2015-05-02 07:02:45 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|