DEV: allows to decorate topic header class (#9427)

This commit is contained in:
Joffrey JAFFEUX 2020-04-15 12:41:01 +02:00 committed by GitHub
parent f1b844ba88
commit 8c58319992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -57,6 +57,18 @@ createWidget("topic-header-participant", {
export default createWidget("header-topic-info", {
tagName: "div.extra-info-wrapper",
buildFancyTitleClass() {
const baseClass = ["topic-link"];
const flatten = array => [].concat.apply([], array);
const extraClass = flatten(
applyDecorators(this, "fancyTitleClass", this.attrs, this.state)
);
return baseClass
.concat(extraClass)
.filter(Boolean)
.join(" ");
},
html(attrs, state) {
const topic = attrs.topic;
@ -87,7 +99,7 @@ export default createWidget("header-topic-info", {
const titleHTML = new RawHtml({ html: `<span>${fancyTitle}</span>` });
heading.push(
this.attach("link", {
className: "topic-link",
className: this.buildFancyTitleClass(),
action: "jumpToTopPost",
href,
attributes: { "data-topic-id": topic.get("id") },