mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 04:56:18 +08:00
FEATURE: Add more class names to latest-topic-list-item (#12933)
This commit is contained in:
parent
5794787300
commit
f57878f20f
|
@ -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(" ");
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user