DEV: add title class name, prefix username class (#19482)

This commit is contained in:
Kris 2022-12-15 17:18:08 -05:00 committed by GitHub
parent 983a56e3bd
commit b1e08364ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -17,6 +17,23 @@ export function disableNameSuppression() {
createWidget("poster-name-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) {
let titleContents = attrs.title;
if (attrs.primaryGroupName && attrs.titleIsGroup) {
@ -111,7 +128,7 @@ export default createWidget("poster-name", {
const primaryGroupName = attrs.primary_group_name;
if (primaryGroupName && primaryGroupName.length) {
classNames.push(primaryGroupName);
classNames.push(`group--${primaryGroupName}`);
}
let nameContents = [this.userLink(attrs, nameFirst ? name : username)];

View File

@ -46,7 +46,7 @@ module("Integration | Component | Widget | poster-name", function (hooks) {
assert.ok(exists("span.moderator"));
assert.ok(exists(".d-icon-shield-alt"));
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) {