UX: Add category & tags in mobile topic timeline

This commit is contained in:
Régis Hanol 2018-05-23 23:05:34 +02:00
parent 3db1032bfd
commit 232ed64865
2 changed files with 34 additions and 0 deletions

View File

@ -4,6 +4,8 @@ import { h } from 'virtual-dom';
import { relativeAge } from 'discourse/lib/formatter';
import { iconNode } from 'discourse-common/lib/icon-library';
import RawHtml from 'discourse/widgets/raw-html';
import renderTags from 'discourse/lib/render-tags';
import renderTopicFeaturedLink from 'discourse/lib/render-topic-featured-link';
const SCROLLER_HEIGHT = 50;
const LAST_READ_HEIGHT = 20;
@ -382,6 +384,7 @@ export default createWidget('topic-timeline', {
const createdAt = new Date(topic.created_at);
const stream = attrs.topic.get('postStream.stream');
const { currentUser } = this;
const { tagging_enabled, topic_featured_link_enabled } = this.siteSettings;
attrs["currentUser"] = currentUser;
@ -399,6 +402,34 @@ export default createWidget('topic-timeline', {
action: 'jumpTop'
}))];
// duplicate of the {{topic-category}} component
let category = [];
if (!topic.get("isPrivateMessage")) {
if (topic.category.parentCategory) {
category.push(this.attach("category-link", { category: topic.category.parentCategory }));
}
category.push(this.attach("category-link", { category: topic.category }));
}
const showTags = tagging_enabled && topic.tags && topic.tags.length > 0;
if (showTags || topic_featured_link_enabled) {
let extras = [];
if (showTags) {
const tagsHtml = new RawHtml({ html: renderTags(topic, { mode: "list" }) });
extras.push(h("div.list-tags", tagsHtml));
}
if (topic_featured_link_enabled) {
extras.push(new RawHtml({ html: renderTopicFeaturedLink(topic) }));
}
category.push(h("div.topic-header-extra", extras));
}
if (category.length > 0) {
elems.push(h("div.topic-category", category));
}
if (this.state.excerpt) {
elems.push(new RawHtml({
html: `<div class='post-excerpt'>${this.state.excerpt}</div>`

View File

@ -196,6 +196,9 @@ sup sup, sub sup, sup sub, sub sub { top: 0; }
font-size: $font-up-1;
padding: 5px;
}
.topic-category {
margin-bottom: .5rem;
}
}
.edit-topic-timer-modal {