FEATURE: Add more class names to latest-topic-list-item (#12933)

This commit is contained in:
Kris 2021-05-04 16:40:42 -04:00 committed by GitHub
parent 5794787300
commit f57878f20f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,15 +3,11 @@ import {
showEntrance,
} from "discourse/components/topic-list-item";
import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend({
attributeBindings: ["topic.id:data-topic-id"],
classNameBindings: [
":latest-topic-list-item",
"topic.archived",
"topic.visited",
"topic.pinned",
],
classNameBindings: [":latest-topic-list-item", "unboundClassNames"],
showEntrance,
navigateToTopic,
@ -27,4 +23,27 @@ export default Component.extend({
// Can be overwritten by plugins to handle clicks on other parts of the row
unhandledRowClick() {},
@discourseComputed("topic")
unboundClassNames(topic) {
let classes = [];
if (topic.get("category")) {
classes.push("category-" + topic.get("category.fullSlug"));
}
if (topic.get("tags")) {
topic.get("tags").forEach((tagName) => classes.push("tag-" + tagName));
}
["liked", "archived", "bookmarked", "pinned", "closed", "visited"].forEach(
(name) => {
if (topic.get(name)) {
classes.push(name);
}
}
);
return classes.join(" ");
},
});