mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 01:15:00 +08:00
UX: Restyle user menu so user links are findable (#10554)
This commit is contained in:
parent
ce1620f2ad
commit
7bba65b6f5
|
@ -55,14 +55,7 @@ createWidgetFrom(QuickAccessPanel, "quick-access-profile", {
|
||||||
className: "activity"
|
className: "activity"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
if (this.siteSettings.enable_personal_messages) {
|
|
||||||
defaultItems.push({
|
|
||||||
icon: "envelope",
|
|
||||||
href: `${this.attrs.path}/messages`,
|
|
||||||
content: I18n.t("user.private_messages"),
|
|
||||||
className: "messages"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
defaultItems.push(
|
defaultItems.push(
|
||||||
{
|
{
|
||||||
icon: "pencil-alt",
|
icon: "pencil-alt",
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { later } from "@ember/runloop";
|
import { later } from "@ember/runloop";
|
||||||
import { createWidget } from "discourse/widgets/widget";
|
import { createWidget } from "discourse/widgets/widget";
|
||||||
import { h } from "virtual-dom";
|
import { h } from "virtual-dom";
|
||||||
import { formatUsername } from "discourse/lib/utilities";
|
|
||||||
|
|
||||||
const UserMenuAction = {
|
const UserMenuAction = {
|
||||||
QUICK_ACCESS: "quickAccess"
|
QUICK_ACCESS: "quickAccess"
|
||||||
|
@ -24,23 +23,15 @@ export function addUserMenuGlyph(glyph) {
|
||||||
createWidget("user-menu-links", {
|
createWidget("user-menu-links", {
|
||||||
tagName: "div.menu-links-header",
|
tagName: "div.menu-links-header",
|
||||||
|
|
||||||
profileLink() {
|
profileGlyph() {
|
||||||
const link = {
|
return {
|
||||||
|
label: "user.preferences",
|
||||||
|
className: "user-preferences-link",
|
||||||
|
icon: "cog",
|
||||||
|
href: `${this.attrs.path}/preferences`,
|
||||||
action: UserMenuAction.QUICK_ACCESS,
|
action: UserMenuAction.QUICK_ACCESS,
|
||||||
actionParam: QuickAccess.PROFILE,
|
actionParam: QuickAccess.PROFILE
|
||||||
route: "user",
|
|
||||||
model: this.currentUser,
|
|
||||||
className: "user-activity-link",
|
|
||||||
icon: "user",
|
|
||||||
rawLabel: formatUsername(this.currentUser.username)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.currentUser.is_anonymous) {
|
|
||||||
link.label = "user.profile";
|
|
||||||
link.rawLabel = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return link;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
notificationsGlyph() {
|
notificationsGlyph() {
|
||||||
|
@ -91,7 +82,6 @@ createWidget("user-menu-links", {
|
||||||
},
|
},
|
||||||
|
|
||||||
html() {
|
html() {
|
||||||
const links = [this.profileLink()];
|
|
||||||
const glyphs = [];
|
const glyphs = [];
|
||||||
|
|
||||||
if (extraGlyphs) {
|
if (extraGlyphs) {
|
||||||
|
@ -112,8 +102,9 @@ createWidget("user-menu-links", {
|
||||||
glyphs.push(this.messagesGlyph());
|
glyphs.push(this.messagesGlyph());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glyphs.push(this.profileGlyph());
|
||||||
|
|
||||||
return h("ul.menu-links-row", [
|
return h("ul.menu-links-row", [
|
||||||
links.map(l => h("li.user", this.linkHtml(l))),
|
|
||||||
h(
|
h(
|
||||||
"li.glyphs",
|
"li.glyphs",
|
||||||
glyphs.map(l => this.glyphHtml(l))
|
glyphs.map(l => this.glyphHtml(l))
|
||||||
|
|
|
@ -196,7 +196,7 @@
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
border-top: 1px solid var(--primary-low);
|
border-top: 1px solid var(--primary-low);
|
||||||
padding-top: 0.5em;
|
padding-top: 0.75em;
|
||||||
margin-top: -1px;
|
margin-top: -1px;
|
||||||
h3 {
|
h3 {
|
||||||
padding: 0 0.4em;
|
padding: 0 0.4em;
|
||||||
|
@ -252,9 +252,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate items with more than 2 lines.
|
// Truncate items with more than 2 lines.
|
||||||
display: -webkit-box;
|
@include line-clamp(2);
|
||||||
-webkit-line-clamp: 2;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,21 +310,14 @@
|
||||||
li:not(.show-all) a {
|
li:not(.show-all) a {
|
||||||
color: var(--primary);
|
color: var(--primary);
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 0.25em 0.5em;
|
|
||||||
.d-icon {
|
|
||||||
color: var(--primary-medium);
|
|
||||||
}
|
|
||||||
|
|
||||||
// accounts for menu "ears" 4px + border 1px
|
|
||||||
padding: 0.25em calc(0.5em + 4px + 1px);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.dismiss-link {
|
.user-notifications-link {
|
||||||
display: inline-block;
|
// keep this in leftmost position consistently
|
||||||
float: right;
|
order: -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.menu-links-header {
|
div.menu-links-header {
|
||||||
|
@ -334,27 +325,25 @@ div.menu-links-header {
|
||||||
.menu-links-row {
|
.menu-links-row {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
// Tabs should have "ears".
|
|
||||||
padding: 0 4px;
|
|
||||||
|
|
||||||
li {
|
li {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
&.user {
|
|
||||||
margin-right: auto;
|
|
||||||
flex: 1 1 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
&.glyphs {
|
&.glyphs {
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
text-align: right;
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
// Expand the click area a bit.
|
display: flex;
|
||||||
padding-left: 0.6em;
|
flex: 1 1 auto;
|
||||||
padding-right: 0.6em;
|
padding: 0.65em 0.25em 0.75em;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,6 +362,10 @@ div.menu-links-header {
|
||||||
border-bottom: 1px solid var(--secondary);
|
border-bottom: 1px solid var(--secondary);
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.d-icon {
|
||||||
|
color: var(--primary-high);
|
||||||
|
}
|
||||||
|
|
||||||
&:focus,
|
&:focus,
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: inherit;
|
background-color: inherit;
|
||||||
|
@ -388,26 +381,7 @@ div.menu-links-header {
|
||||||
a {
|
a {
|
||||||
padding: 0.3em 0.5em;
|
padding: 0.3em 0.5em;
|
||||||
}
|
}
|
||||||
a.user-activity-link {
|
|
||||||
box-sizing: border-box;
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
max-width: 100%;
|
|
||||||
|
|
||||||
// `overflow: hidden` on `.user-activity-link` would hide the `::after`
|
|
||||||
// pseudo element (used to create the tab-looking effect). Sets `overflow:
|
|
||||||
// hidden` on the child username label instead.
|
|
||||||
overflow: visible;
|
|
||||||
|
|
||||||
span.d-label {
|
|
||||||
display: block;
|
|
||||||
@include ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
@include breakpoint(mobile-medium) {
|
|
||||||
max-width: 125px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
li {
|
li {
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
width: auto;
|
width: auto;
|
||||||
|
@ -424,8 +398,4 @@ div.menu-links-header {
|
||||||
a {
|
a {
|
||||||
color: var(--primary-med-or-secondary-med);
|
color: var(--primary-med-or-secondary-med);
|
||||||
}
|
}
|
||||||
|
|
||||||
.d-icon-user {
|
|
||||||
margin-right: 0.475em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ widgetTest("basics", {
|
||||||
|
|
||||||
test(assert) {
|
test(assert) {
|
||||||
assert.ok(find(".user-menu").length);
|
assert.ok(find(".user-menu").length);
|
||||||
assert.ok(find(".user-activity-link").length);
|
assert.ok(find(".user-preferences-link").length);
|
||||||
assert.ok(find(".user-notifications-link").length);
|
assert.ok(find(".user-notifications-link").length);
|
||||||
assert.ok(find(".user-bookmarks-link").length);
|
assert.ok(find(".user-bookmarks-link").length);
|
||||||
assert.ok(find(".quick-access-panel").length);
|
assert.ok(find(".quick-access-panel").length);
|
||||||
|
@ -82,7 +82,7 @@ widgetTest("log out", {
|
||||||
},
|
},
|
||||||
|
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
await click(".user-activity-link");
|
await click(".user-preferences-link");
|
||||||
assert.ok(find(".logout").length);
|
assert.ok(find(".logout").length);
|
||||||
|
|
||||||
await click(".logout");
|
await click(".logout");
|
||||||
|
@ -178,7 +178,7 @@ widgetTest("anonymous", {
|
||||||
},
|
},
|
||||||
|
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
await click(".user-activity-link");
|
await click(".user-preferences-link");
|
||||||
assert.ok(find(".enable-anonymous").length);
|
assert.ok(find(".enable-anonymous").length);
|
||||||
|
|
||||||
await click(".enable-anonymous");
|
await click(".enable-anonymous");
|
||||||
|
@ -194,7 +194,7 @@ widgetTest("anonymous - disabled", {
|
||||||
},
|
},
|
||||||
|
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
await click(".user-activity-link");
|
await click(".user-preferences-link");
|
||||||
assert.ok(!find(".enable-anonymous").length);
|
assert.ok(!find(".enable-anonymous").length);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -211,7 +211,7 @@ widgetTest("anonymous - switch back", {
|
||||||
},
|
},
|
||||||
|
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
await click(".user-activity-link");
|
await click(".user-preferences-link");
|
||||||
assert.ok(find(".disable-anonymous").length);
|
assert.ok(find(".disable-anonymous").length);
|
||||||
|
|
||||||
await click(".disable-anonymous");
|
await click(".disable-anonymous");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user