mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
DEV: Use classes for styling user and group cards (#8913)
Styling based on element-ids, it is impossible for themes/plugins to display multiple cards on a single page. Using classes is a more flexible approach. The element-ids are maintained for backwards compatibility with existing plugins/themes.
This commit is contained in:
parent
3875785dcc
commit
8d50f092b5
12 changed files with 30 additions and 29 deletions
|
@ -12,7 +12,7 @@ const maxMembersToDisplay = 10;
|
||||||
export default Component.extend(CardContentsBase, CleansUp, {
|
export default Component.extend(CardContentsBase, CleansUp, {
|
||||||
elementId: "group-card",
|
elementId: "group-card",
|
||||||
triggeringLinkClass: "mention-group",
|
triggeringLinkClass: "mention-group",
|
||||||
classNames: ["no-bg"],
|
classNames: ["no-bg", "group-card"],
|
||||||
classNameBindings: [
|
classNameBindings: [
|
||||||
"visible:show",
|
"visible:show",
|
||||||
"showBadges",
|
"showBadges",
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
|
export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
|
||||||
elementId: "user-card",
|
elementId: "user-card",
|
||||||
|
classNames: "user-card",
|
||||||
triggeringLinkClass: "mention",
|
triggeringLinkClass: "mention",
|
||||||
classNameBindings: [
|
classNameBindings: [
|
||||||
"visible:show",
|
"visible:show",
|
||||||
|
|
|
@ -703,7 +703,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.primary-textual .staged,
|
.primary-textual .staged,
|
||||||
#user-card .staged {
|
.user-card .staged {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ $avatar_margin: -50px; // negative margin makes avatars extend above cards
|
||||||
}
|
}
|
||||||
|
|
||||||
// shared styles for user and group cards
|
// shared styles for user and group cards
|
||||||
#user-card,
|
.user-card,
|
||||||
#group-card {
|
.group-card {
|
||||||
width: $card_width;
|
width: $card_width;
|
||||||
box-shadow: shadow("card");
|
box-shadow: shadow("card");
|
||||||
color: $primary;
|
color: $primary;
|
||||||
|
@ -137,7 +137,7 @@ $avatar_margin: -50px; // negative margin makes avatars extend above cards
|
||||||
}
|
}
|
||||||
|
|
||||||
// styles for user cards only
|
// styles for user cards only
|
||||||
#user-card {
|
.user-card {
|
||||||
// avatar - names - controls
|
// avatar - names - controls
|
||||||
.first-row {
|
.first-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -243,7 +243,7 @@ $avatar_margin: -50px; // negative margin makes avatars extend above cards
|
||||||
}
|
}
|
||||||
|
|
||||||
// styles for group cards only
|
// styles for group cards only
|
||||||
#group-card {
|
.group-card {
|
||||||
// avatar - names and controls
|
// avatar - names and controls
|
||||||
.first-row {
|
.first-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// shared styles for user and group cards
|
// shared styles for user and group cards
|
||||||
#user-card,
|
.user-card,
|
||||||
#group-card {
|
.group-card {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: z("usercard");
|
z-index: z("usercard");
|
||||||
&.fixed {
|
&.fixed {
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// styles for user cards only
|
// styles for user cards only
|
||||||
#user-card {
|
.user-card {
|
||||||
// badges
|
// badges
|
||||||
.badge-section {
|
.badge-section {
|
||||||
.user-badge {
|
.user-badge {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
$avatar_width: 120px;
|
$avatar_width: 120px;
|
||||||
|
|
||||||
// shared styles for user and group cards
|
// shared styles for user and group cards
|
||||||
#user-card,
|
.user-card,
|
||||||
#group-card {
|
.group-card {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
// mobile cards should always be on top of everything - 1102
|
// mobile cards should always be on top of everything - 1102
|
||||||
z-index: z("mobile-composer") + 2;
|
z-index: z("mobile-composer") + 2;
|
||||||
|
@ -48,7 +48,7 @@ $avatar_width: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// styles for user cards only
|
// styles for user cards only
|
||||||
#user-card {
|
.user-card {
|
||||||
// badges
|
// badges
|
||||||
.badge-section {
|
.badge-section {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
|
@ -7,9 +7,9 @@ QUnit.test("Do not track mentions", async assert => {
|
||||||
server.post("/clicks/track", () => assert.ok(false));
|
server.post("/clicks/track", () => assert.ok(false));
|
||||||
|
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
assert.ok(invisible("#user-card"), "card should not appear");
|
assert.ok(invisible(".user-card"), "card should not appear");
|
||||||
|
|
||||||
await click("article[data-post-id=3651] a.mention");
|
await click("article[data-post-id=3651] a.mention");
|
||||||
assert.ok(visible("#user-card"), "card should appear");
|
assert.ok(visible(".user-card"), "card should appear");
|
||||||
assert.equal(currentURL(), "/t/internationalization-localization/280");
|
assert.equal(currentURL(), "/t/internationalization-localization/280");
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,12 +6,12 @@ acceptance("Group Card - Mobile", { mobileView: true });
|
||||||
QUnit.skip("group card", async assert => {
|
QUnit.skip("group card", async assert => {
|
||||||
await visit("/t/-/301/1");
|
await visit("/t/-/301/1");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
invisible("#group-card"),
|
invisible(".group-card"),
|
||||||
"mobile group card is invisible by default"
|
"mobile group card is invisible by default"
|
||||||
);
|
);
|
||||||
|
|
||||||
await click("a.mention-group:first");
|
await click("a.mention-group:first");
|
||||||
assert.ok(visible("#group-card"), "mobile group card should appear");
|
assert.ok(visible(".group-card"), "mobile group card should appear");
|
||||||
|
|
||||||
sandbox.stub(DiscourseURL, "routeTo");
|
sandbox.stub(DiscourseURL, "routeTo");
|
||||||
await click(".card-content a.group-page-link");
|
await click(".card-content a.group-page-link");
|
||||||
|
|
|
@ -5,10 +5,10 @@ acceptance("Group Card");
|
||||||
|
|
||||||
QUnit.test("group card", async assert => {
|
QUnit.test("group card", async assert => {
|
||||||
await visit("/t/-/301/1");
|
await visit("/t/-/301/1");
|
||||||
assert.ok(invisible("#group-card"), "user card is invisible by default");
|
assert.ok(invisible(".group-card"), "user card is invisible by default");
|
||||||
|
|
||||||
await click("a.mention-group:first");
|
await click("a.mention-group:first");
|
||||||
assert.ok(visible("#group-card"), "card should appear");
|
assert.ok(visible(".group-card"), "card should appear");
|
||||||
|
|
||||||
sandbox.stub(DiscourseURL, "routeTo");
|
sandbox.stub(DiscourseURL, "routeTo");
|
||||||
await click(".card-content a.group-page-link");
|
await click(".card-content a.group-page-link");
|
||||||
|
|
|
@ -6,12 +6,12 @@ acceptance("User Card - Mobile", { mobileView: true });
|
||||||
QUnit.skip("user card", async assert => {
|
QUnit.skip("user card", async assert => {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
invisible("#user-card"),
|
invisible(".user-card"),
|
||||||
"mobile user card is invisible by default"
|
"mobile user card is invisible by default"
|
||||||
);
|
);
|
||||||
|
|
||||||
await click("a[data-user-card=eviltrout]:first");
|
await click("a[data-user-card=eviltrout]:first");
|
||||||
assert.ok(visible("#user-card"), "mobile user card should appear");
|
assert.ok(visible(".user-card"), "mobile user card should appear");
|
||||||
|
|
||||||
sandbox.stub(DiscourseURL, "routeTo");
|
sandbox.stub(DiscourseURL, "routeTo");
|
||||||
await click(".card-content a.user-profile-link");
|
await click(".card-content a.user-profile-link");
|
||||||
|
|
|
@ -5,12 +5,12 @@ acceptance("User Card", { loggedIn: true });
|
||||||
|
|
||||||
QUnit.test("user card", async assert => {
|
QUnit.test("user card", async assert => {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
assert.ok(invisible("#user-card"), "user card is invisible by default");
|
assert.ok(invisible(".user-card"), "user card is invisible by default");
|
||||||
|
|
||||||
await click("a[data-user-card=eviltrout]:first");
|
await click("a[data-user-card=eviltrout]:first");
|
||||||
assert.ok(visible("#user-card"), "card should appear");
|
assert.ok(visible(".user-card"), "card should appear");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find("#user-card .username")
|
find(".user-card .username")
|
||||||
.text()
|
.text()
|
||||||
.trim(),
|
.trim(),
|
||||||
"eviltrout",
|
"eviltrout",
|
||||||
|
@ -25,9 +25,9 @@ QUnit.test("user card", async assert => {
|
||||||
);
|
);
|
||||||
|
|
||||||
await click("a[data-user-card=charlie]:first");
|
await click("a[data-user-card=charlie]:first");
|
||||||
assert.ok(visible("#user-card"), "card should appear");
|
assert.ok(visible(".user-card"), "card should appear");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find("#user-card .username")
|
find(".user-card .username")
|
||||||
.text()
|
.text()
|
||||||
.trim(),
|
.trim(),
|
||||||
"charlie",
|
"charlie",
|
||||||
|
@ -36,7 +36,7 @@ QUnit.test("user card", async assert => {
|
||||||
|
|
||||||
await click(".card-content .compose-pm button");
|
await click(".card-content .compose-pm button");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
invisible("#user-card"),
|
invisible(".user-card"),
|
||||||
"user card dismissed after hitting Message button"
|
"user card dismissed after hitting Message button"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@ QUnit.test("user card", async assert => {
|
||||||
icon.classList.add("icon");
|
icon.classList.add("icon");
|
||||||
mention.append(icon);
|
mention.append(icon);
|
||||||
await click("a.mention .icon");
|
await click("a.mention .icon");
|
||||||
assert.ok(visible("#user-card"), "card should appear");
|
assert.ok(visible(".user-card"), "card should appear");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find("#user-card .username")
|
find(".user-card .username")
|
||||||
.text()
|
.text()
|
||||||
.trim(),
|
.trim(),
|
||||||
"eviltrout",
|
"eviltrout",
|
||||||
|
|
|
@ -162,7 +162,7 @@ const path = require("path");
|
||||||
});
|
});
|
||||||
|
|
||||||
await exec("user has details", () => {
|
await exec("user has details", () => {
|
||||||
return page.waitForSelector("#user-card .names", { visible: true });
|
return page.waitForSelector(".user-card .names", { visible: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!process.env.READONLY_TESTS) {
|
if (!process.env.READONLY_TESTS) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue