FIX: ensures topic count is correctly showing in box category badges (#9034)

This commit is contained in:
Joffrey JAFFEUX 2020-02-24 23:41:36 +01:00 committed by GitHub
parent d6a603cc50
commit bd49368942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -86,6 +86,13 @@ export function categoryLinkHTML(category, options) {
registerUnbound("category-link", categoryLinkHTML);
function buildTopicCount(count) {
return `<span class="topic-count" aria-label="${I18n.t(
"category_row.topic_count",
{ count }
)}">&times; ${count}</span>`;
}
function defaultCategoryLinkRenderer(category, opts) {
let descriptionText = get(category, "description_text");
let restricted = get(category, "read_restricted");
@ -151,11 +158,8 @@ function defaultCategoryLinkRenderer(category, opts) {
}
html += "</span>";
if (opts.topicCount) {
html += `<span class="topic-count" aria-label="${I18n.t(
"category_row.topic_count",
{ count: opts.topicCount }
)}">&times; ${opts.topicCount}</span>`;
if (opts.topicCount && categoryStyle !== "box") {
html += buildTopicCount(opts.topicCount);
}
if (href) {
@ -163,5 +167,10 @@ function defaultCategoryLinkRenderer(category, opts) {
}
extraClasses = categoryStyle ? categoryStyle + extraClasses : extraClasses;
return `<${tagName} class="badge-wrapper ${extraClasses}" ${href}>${html}</${tagName}>`;
let afterBadgeWrapper = "";
if (opts.topicCount && categoryStyle === "box") {
afterBadgeWrapper += buildTopicCount(opts.topicCount);
}
return `<${tagName} class="badge-wrapper ${extraClasses}" ${href}>${html}</${tagName}>${afterBadgeWrapper}`;
}

View File

@ -25,7 +25,7 @@
font-size: $font-down-1;
color: $primary;
white-space: nowrap;
margin-left: 1em;
margin-left: 0.5em;
font-weight: normal;
}