This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/nav-item.js.es6
2019-05-27 10:15:39 +02:00

33 lines
826 B
JavaScript

/* You might be looking for navigation-item. */
import { iconHTML } from "discourse-common/lib/icon-library";
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
tagName: "li",
classNameBindings: ["active"],
router: Ember.inject.service(),
@computed("label", "i18nLabel", "icon")
contents(label, i18nLabel, icon) {
let text = i18nLabel || I18n.t(label);
if (icon) {
return `${iconHTML(icon)} ${text}`.htmlSafe();
}
return text;
},
@computed("route", "router.currentRoute")
active(route, currentRoute) {
if (!route) {
return;
}
const routeParam = this.routeParam;
if (routeParam && currentRoute) {
return currentRoute.params["filter"] === routeParam;
}
return this.router.isActive(route);
}
});