mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: add title class name, prefix username class (#19482)
This commit is contained in:
parent
983a56e3bd
commit
b1e08364ef
@ -17,6 +17,23 @@ export function disableNameSuppression() {
|
|||||||
createWidget("poster-name-title", {
|
createWidget("poster-name-title", {
|
||||||
tagName: "span.user-title",
|
tagName: "span.user-title",
|
||||||
|
|
||||||
|
buildClasses(attrs) {
|
||||||
|
let classNames = [];
|
||||||
|
|
||||||
|
classNames.push(attrs.title);
|
||||||
|
|
||||||
|
if (attrs.titleIsGroup) {
|
||||||
|
classNames.push(attrs.primaryGroupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
classNames = classNames.map(
|
||||||
|
(className) =>
|
||||||
|
`user-title--${className.replace(/\s+/g, "-").toLowerCase()}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return classNames;
|
||||||
|
},
|
||||||
|
|
||||||
html(attrs) {
|
html(attrs) {
|
||||||
let titleContents = attrs.title;
|
let titleContents = attrs.title;
|
||||||
if (attrs.primaryGroupName && attrs.titleIsGroup) {
|
if (attrs.primaryGroupName && attrs.titleIsGroup) {
|
||||||
@ -111,7 +128,7 @@ export default createWidget("poster-name", {
|
|||||||
|
|
||||||
const primaryGroupName = attrs.primary_group_name;
|
const primaryGroupName = attrs.primary_group_name;
|
||||||
if (primaryGroupName && primaryGroupName.length) {
|
if (primaryGroupName && primaryGroupName.length) {
|
||||||
classNames.push(primaryGroupName);
|
classNames.push(`group--${primaryGroupName}`);
|
||||||
}
|
}
|
||||||
let nameContents = [this.userLink(attrs, nameFirst ? name : username)];
|
let nameContents = [this.userLink(attrs, nameFirst ? name : username)];
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ module("Integration | Component | Widget | poster-name", function (hooks) {
|
|||||||
assert.ok(exists("span.moderator"));
|
assert.ok(exists("span.moderator"));
|
||||||
assert.ok(exists(".d-icon-shield-alt"));
|
assert.ok(exists(".d-icon-shield-alt"));
|
||||||
assert.ok(exists("span.new-user"));
|
assert.ok(exists("span.new-user"));
|
||||||
assert.ok(exists("span.fish"));
|
assert.ok(exists("span.group--fish"));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("disable display name on posts", async function (assert) {
|
test("disable display name on posts", async function (assert) {
|
||||||
|
Loading…
Reference in New Issue
Block a user