From f1f2c1acd48293b481fd327b20cda066762d4ae0 Mon Sep 17 00:00:00 2001 From: Kris Date: Wed, 19 Oct 2022 21:05:51 -0400 Subject: [PATCH] UX: extend horizontal user nav to all user pages (#18674) --- ...nces-nav.js => horizontal-overflow-nav.js} | 17 +- .../app/components/user-nav/activity-nav.hbs | 47 +++++ .../app/components/user-nav/messages-nav.hbs | 4 +- .../components/user-nav/notifications-nav.hbs | 38 ++++ .../components/user-nav/preferences-nav.hbs | 180 +++++++----------- .../components/horizontal-overflow-nav.hbs | 33 ++++ .../discourse/app/templates/preferences.hbs | 16 +- .../discourse/app/templates/user-invited.hbs | 4 +- .../discourse/app/templates/user/activity.hbs | 59 +----- .../app/templates/user/notifications.hbs | 58 ++---- .../stylesheets/common/base/new-user.scss | 18 +- 11 files changed, 249 insertions(+), 225 deletions(-) rename app/assets/javascripts/discourse/app/components/{user-nav/preferences-nav.js => horizontal-overflow-nav.js} (85%) create mode 100644 app/assets/javascripts/discourse/app/components/user-nav/activity-nav.hbs create mode 100644 app/assets/javascripts/discourse/app/components/user-nav/notifications-nav.hbs create mode 100644 app/assets/javascripts/discourse/app/templates/components/horizontal-overflow-nav.hbs diff --git a/app/assets/javascripts/discourse/app/components/user-nav/preferences-nav.js b/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.js similarity index 85% rename from app/assets/javascripts/discourse/app/components/user-nav/preferences-nav.js rename to app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.js index 1c013766bd1..79d0a065190 100644 --- a/app/assets/javascripts/discourse/app/components/user-nav/preferences-nav.js +++ b/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.js @@ -4,7 +4,7 @@ import { bind } from "discourse-common/utils/decorators"; import { inject as service } from "@ember/service"; import { tracked } from "@glimmer/tracking"; -export default class UserNavPreferencesNav extends Component { +export default class HorizontalOverflowNav extends Component { @service site; @tracked hasScroll; @tracked hideRightScroll = false; @@ -13,9 +13,14 @@ export default class UserNavPreferencesNav extends Component { @bind scrollToActive() { - document - .querySelector(".user-navigation-secondary a.active") - .scrollIntoView({ inline: "center" }); + const activeElement = document.querySelector( + ".user-navigation-secondary a.active" + ); + + activeElement?.scrollIntoView({ + block: "nearest", + inline: "center", + }); } @bind @@ -60,7 +65,7 @@ export default class UserNavPreferencesNav extends Component { @action horizScroll(element) { - let scrollSpeed = 50; + let scrollSpeed = 100; let siblingTarget = element.target.previousElementSibling; if (element.target.dataset.direction === "left") { @@ -72,8 +77,6 @@ export default class UserNavPreferencesNav extends Component { siblingTarget.scrollLeft += scrollSpeed; }, 50); - this.scrollTimer; - element.target.addEventListener("mouseup", this.stopScroll); element.target.addEventListener("mouseleave", this.stopScroll); } diff --git a/app/assets/javascripts/discourse/app/components/user-nav/activity-nav.hbs b/app/assets/javascripts/discourse/app/components/user-nav/activity-nav.hbs new file mode 100644 index 00000000000..0e641e33c40 --- /dev/null +++ b/app/assets/javascripts/discourse/app/components/user-nav/activity-nav.hbs @@ -0,0 +1,47 @@ + + {{d-icon "stream"}} + {{i18n "user.filters.all"}} + + + {{d-icon "list-ul"}} + {{i18n "user_action_groups.4"}} + + + {{d-icon "reply"}} + {{i18n "user_action_groups.5"}} + + +{{#if @user.showRead}} + + {{d-icon "history"}} + {{i18n "user.read"}} + +{{/if}} + +{{#if @user.showDrafts}} + + {{d-icon "pencil-alt"}} + {{@draftLabel}} + +{{/if}} + +{{#if (gt @model.pending_posts_count 0)}} + + {{d-icon "clock"}} + {{@pendingLabel}} + +{{/if}} + + + {{d-icon "heart"}} + {{i18n "user_action_groups.1"}} + + +{{#if @user.showBookmarks}} + + {{d-icon "bookmark"}} + {{i18n "user_action_groups.3"}} + +{{/if}} + + diff --git a/app/assets/javascripts/discourse/app/components/user-nav/messages-nav.hbs b/app/assets/javascripts/discourse/app/components/user-nav/messages-nav.hbs index d88d8089b23..565e6c336c9 100644 --- a/app/assets/javascripts/discourse/app/components/user-nav/messages-nav.hbs +++ b/app/assets/javascripts/discourse/app/components/user-nav/messages-nav.hbs @@ -7,7 +7,7 @@ {{/if}} - + {{#if this.site.desktopView}}