mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 17:57:04 +08:00
22 lines
608 B
JavaScript
22 lines
608 B
JavaScript
import Component from 'flarum/component'
|
|
import icon from 'flarum/helpers/icon'
|
|
|
|
export default class NavItem extends Component {
|
|
view() {
|
|
var active = this.constructor.active(this.props);
|
|
return m('li'+(active ? '.active' : ''), m('a', {
|
|
href: this.props.href,
|
|
onclick: this.props.onclick,
|
|
config: m.route
|
|
}, [
|
|
icon(this.props.icon+' icon'),
|
|
this.props.label, ' ',
|
|
this.props.badge ? m('span.count', this.props.badge) : ''
|
|
]))
|
|
}
|
|
|
|
static active(props) {
|
|
return typeof props.active !== 'undefined' ? props.active : m.route() === props.href;
|
|
}
|
|
}
|