UX: extend horizontal user nav to all user pages (#18674)

This commit is contained in:
Kris 2022-10-19 21:05:51 -04:00 committed by GitHub
parent 09e4eb4137
commit f1f2c1acd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 249 additions and 225 deletions

View File

@ -4,7 +4,7 @@ import { bind } from "discourse-common/utils/decorators";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { tracked } from "@glimmer/tracking"; import { tracked } from "@glimmer/tracking";
export default class UserNavPreferencesNav extends Component { export default class HorizontalOverflowNav extends Component {
@service site; @service site;
@tracked hasScroll; @tracked hasScroll;
@tracked hideRightScroll = false; @tracked hideRightScroll = false;
@ -13,9 +13,14 @@ export default class UserNavPreferencesNav extends Component {
@bind @bind
scrollToActive() { scrollToActive() {
document const activeElement = document.querySelector(
.querySelector(".user-navigation-secondary a.active") ".user-navigation-secondary a.active"
.scrollIntoView({ inline: "center" }); );
activeElement?.scrollIntoView({
block: "nearest",
inline: "center",
});
} }
@bind @bind
@ -60,7 +65,7 @@ export default class UserNavPreferencesNav extends Component {
@action @action
horizScroll(element) { horizScroll(element) {
let scrollSpeed = 50; let scrollSpeed = 100;
let siblingTarget = element.target.previousElementSibling; let siblingTarget = element.target.previousElementSibling;
if (element.target.dataset.direction === "left") { if (element.target.dataset.direction === "left") {
@ -72,8 +77,6 @@ export default class UserNavPreferencesNav extends Component {
siblingTarget.scrollLeft += scrollSpeed; siblingTarget.scrollLeft += scrollSpeed;
}, 50); }, 50);
this.scrollTimer;
element.target.addEventListener("mouseup", this.stopScroll); element.target.addEventListener("mouseup", this.stopScroll);
element.target.addEventListener("mouseleave", this.stopScroll); element.target.addEventListener("mouseleave", this.stopScroll);
} }

View File

@ -0,0 +1,47 @@
<DNavigationItem @route="userActivity.index">
{{d-icon "stream"}}
<span>{{i18n "user.filters.all"}}</span>
</DNavigationItem>
<DNavigationItem @route="userActivity.topics">
{{d-icon "list-ul"}}
<span>{{i18n "user_action_groups.4"}}</span>
</DNavigationItem>
<DNavigationItem @route="userActivity.replies">
{{d-icon "reply"}}
<span>{{i18n "user_action_groups.5"}}</span>
</DNavigationItem>
{{#if @user.showRead}}
<DNavigationItem @route="userActivity.read" @title={{i18n "user.read_help"}}>
{{d-icon "history"}}
<span>{{i18n "user.read"}}</span>
</DNavigationItem>
{{/if}}
{{#if @user.showDrafts}}
<DNavigationItem @route="userActivity.drafts">
{{d-icon "pencil-alt"}}
<span>{{@draftLabel}}</span>
</DNavigationItem>
{{/if}}
{{#if (gt @model.pending_posts_count 0)}}
<DNavigationItem @route="userActivity.pending">
{{d-icon "clock"}}
<span>{{@pendingLabel}}</span>
</DNavigationItem>
{{/if}}
<DNavigationItem @route="userActivity.likesGiven">
{{d-icon "heart"}}
<span>{{i18n "user_action_groups.1"}}</span>
</DNavigationItem>
{{#if @user.showBookmarks}}
<DNavigationItem @route="userActivity.bookmarks">
{{d-icon "bookmark"}}
<span>{{i18n "user_action_groups.3"}}</span>
</DNavigationItem>
{{/if}}
<PluginOutlet @name="user-activity-bottom" @connectorTagName="li" @args={{hash model=@model}} />

View File

@ -7,7 +7,7 @@
</ol> </ol>
{{/if}} {{/if}}
<ul class="messages-nav nav-pills action-list"> <HorizontalOverflowNav>
{{#if @isPersonal}} {{#if @isPersonal}}
<li class="messages-latest"> <li class="messages-latest">
<LinkTo @route="userPrivateMessages.index" @model={{@user}}> <LinkTo @route="userPrivateMessages.index" @model={{@user}}>
@ -99,7 +99,7 @@
{{/if}} {{/if}}
<PluginOutlet @name="user-messages-nav" @connectorTagName="li" @args={{hash model=@user}} /> <PluginOutlet @name="user-messages-nav" @connectorTagName="li" @args={{hash model=@user}} />
</ul> </HorizontalOverflowNav>
{{#if this.site.desktopView}} {{#if this.site.desktopView}}
<div class="navigation-controls"> <div class="navigation-controls">

View File

@ -0,0 +1,38 @@
<li>
<LinkTo @route="userNotifications.index">
{{d-icon "bell"}}
<span>{{i18n "user.filters.all"}}</span>
</LinkTo>
</li>
<li>
<LinkTo @route="userNotifications.responses">
{{d-icon "reply"}}
<span>{{i18n "user_action_groups.6"}}</span>
</LinkTo>
</li>
<li>
<LinkTo @route="userNotifications.likesReceived">
{{d-icon "heart"}}
<span>{{i18n "user_action_groups.2"}}</span>
</LinkTo>
</li>
{{#if this.siteSettings.enable_mentions}}
<li>
<LinkTo @route="userNotifications.mentions">
{{d-icon "at"}}
<span>{{i18n "user_action_groups.7"}}</span>
</LinkTo>
</li>
{{/if}}
<li>
<LinkTo @route="userNotifications.edits">
{{d-icon "pencil-alt"}}
<span>{{i18n "user_action_groups.11"}}</span>
</LinkTo>
</li>
<PluginOutlet @name="user-notifications-bottom" @connectorTagName="li" @args={{hash model=@model}} />

View File

@ -1,23 +1,3 @@
{{!-- template-lint-disable no-down-event-binding --}}
<div class="user-navigation user-navigation-secondary {{if this.hasScroll "has-scroll"}}">
{{#if this.hasScroll}}
<a
role="button"
{{on "mousedown" this.horizScroll}}
data-direction="left"
class="nav-overflow__scroll-left btn-flat {{if this.hideLeftScroll "transparent"}}"
>
{{d-icon "chevron-left"}}
</a>
{{/if}}
<ul
{{did-insert this.scrollToActive}}
{{on-resize this.checkScroll}}
{{on "scroll" this.watchScroll}}
class="nav-pills action-list"
>
<li class="nav-account"> <li class="nav-account">
<LinkTo @route="preferences.account"> <LinkTo @route="preferences.account">
{{d-icon "user"}} {{d-icon "user"}}
@ -92,15 +72,3 @@
</LinkTo> </LinkTo>
</li> </li>
<PluginOutlet @name="user-preferences-nav" @connectorTagName="li" @args={{hash model=@model}} /> <PluginOutlet @name="user-preferences-nav" @connectorTagName="li" @args={{hash model=@model}} />
</ul>
{{#if this.hasScroll}}
<a
role="button"
{{on "mousedown" this.horizScroll}}
class="nav-overflow__scroll-right btn-flat {{if this.hideRightScroll "transparent"}}"
>
{{d-icon "chevron-right"}}
</a>
{{/if}}
</div>

View File

@ -0,0 +1,33 @@
{{!-- template-lint-disable no-down-event-binding --}}
<div class="horizontal-overflow-nav {{if this.hasScroll "has-scroll"}}">
{{#if this.hasScroll}}
<a
role="button"
{{on "mousedown" this.horizScroll}}
data-direction="left"
class="nav-overflow__scroll-left btn-flat {{if this.hideLeftScroll "transparent"}}"
>
{{d-icon "chevron-left"}}
</a>
{{/if}}
<ul
{{on-resize this.checkScroll}}
{{on "scroll" this.watchScroll}}
{{did-insert this.scrollToActive}}
class="nav-pills action-list"
>
{{yield}}
</ul>
{{#if this.hasScroll}}
<a
role="button"
{{on "mousedown" this.horizScroll}}
class="nav-overflow__scroll-right btn-flat {{if this.hideRightScroll "transparent"}}"
>
{{d-icon "chevron-right"}}
</a>
{{/if}}
</div>

View File

@ -1,12 +1,14 @@
{{#if this.currentUser.redesigned_user_page_nav_enabled}} {{#if this.currentUser.redesigned_user_page_nav_enabled}}
<DSection @pageClass="user-preferences" /> <DSection @pageClass="user-preferences" />
<div class="user-navigation user-navigation-secondary">
<HorizontalOverflowNav>
<UserNav::PreferencesNav <UserNav::PreferencesNav
@user={{this.model}} @user={{this.model}}
@viewingSelf={{this.viewingSelf}} @viewingSelf={{this.viewingSelf}}
@model={{this.model}} @model={{this.model}}
@siteSettings={{this.siteSettings}} @siteSettings={{this.siteSettings}}/>
/> </HorizontalOverflowNav>
</div>
{{else}} {{else}}
<DSection @pageClass="user-preferences" @class="user-secondary-navigation"> <DSection @pageClass="user-preferences" @class="user-secondary-navigation">
<MobileNav @class="preferences-nav" @desktopClass="preferences-list action-list nav-stacked"> <MobileNav @class="preferences-nav" @desktopClass="preferences-list action-list nav-stacked">

View File

@ -3,11 +3,11 @@
<DSection @pageClass="user-invites" /> <DSection @pageClass="user-invites" />
<div class="user-navigation user-navigation-secondary"> <div class="user-navigation user-navigation-secondary">
<ul id="navigation-bar" class="nav-pills action-list"> <HorizontalOverflowNav>
<NavItem @route="userInvited.show" @routeParam="pending" @i18nLabel={{this.pendingLabel}} /> <NavItem @route="userInvited.show" @routeParam="pending" @i18nLabel={{this.pendingLabel}} />
<NavItem @route="userInvited.show" @routeParam="expired" @i18nLabel={{this.expiredLabel}} /> <NavItem @route="userInvited.show" @routeParam="expired" @i18nLabel={{this.expiredLabel}} />
<NavItem @route="userInvited.show" @routeParam="redeemed" @i18nLabel={{this.redeemedLabel}} /> <NavItem @route="userInvited.show" @routeParam="redeemed" @i18nLabel={{this.redeemedLabel}} />
</ul> </HorizontalOverflowNav>
</div> </div>
{{else}} {{else}}
<DSection @class="user-secondary-navigation" @pageClass="user-invites"> <DSection @class="user-secondary-navigation" @pageClass="user-invites">

View File

@ -2,56 +2,17 @@
<DSection @pageClass="user-activity" /> <DSection @pageClass="user-activity" />
<div class="user-navigation user-navigation-secondary"> <div class="user-navigation user-navigation-secondary">
<ul class="nav-pills action-list"> <HorizontalOverflowNav>
<DNavigationItem @route="userActivity.index"> <UserNav::ActivityNav
{{d-icon "stream"}} @user={{this.user}}
<span>{{i18n "user.filters.all"}}</span> @viewingSelf={{this.viewingSelf}}
</DNavigationItem> @model={{this.model}}
<DNavigationItem @route="userActivity.topics"> @siteSettings={{this.siteSettings}}
{{d-icon "list-ul"}} @draftLabel={{this.draftLabel}}
<span>{{i18n "user_action_groups.4"}}</span> @pendingLabel={{this.pendingLabel}}/>
</DNavigationItem> </HorizontalOverflowNav>
<DNavigationItem @route="userActivity.replies">
{{d-icon "reply"}}
<span>{{i18n "user_action_groups.5"}}</span>
</DNavigationItem>
{{#if this.user.showRead}}
<DNavigationItem @route="userActivity.read" @title={{i18n "user.read_help"}}>
{{d-icon "history"}}
<span>{{i18n "user.read"}}</span>
</DNavigationItem>
{{/if}}
{{#if this.user.showDrafts}}
<DNavigationItem @route="userActivity.drafts">
{{d-icon "pencil-alt"}}
<span>{{this.draftLabel}}</span>
</DNavigationItem>
{{/if}}
{{#if (gt this.model.pending_posts_count 0)}}
<DNavigationItem @route="userActivity.pending">
{{d-icon "clock"}}
<span>{{this.pendingLabel}}</span>
</DNavigationItem>
{{/if}}
<DNavigationItem @route="userActivity.likesGiven">
{{d-icon "heart"}}
<span>{{i18n "user_action_groups.1"}}</span>
</DNavigationItem>
{{#if this.user.showBookmarks}}
<DNavigationItem @route="userActivity.bookmarks">
{{d-icon "bookmark"}}
<span>{{i18n "user_action_groups.3"}}</span>
</DNavigationItem>
{{/if}}
<PluginOutlet @name="user-activity-bottom" @connectorTagName="li" @args={{hash model=this.model}} />
</ul>
</div> </div>
{{else}} {{else}}
<DSection @pageClass="user-activity" @class="user-secondary-navigation" @scrollTop={{false}}> <DSection @pageClass="user-activity" @class="user-secondary-navigation" @scrollTop={{false}}>
<nav role="navigation"> <nav role="navigation">

View File

@ -1,54 +1,18 @@
{{#if this.currentUser.redesigned_user_page_nav_enabled}} {{#if this.currentUser.redesigned_user_page_nav_enabled}}
<DSection @pageClass="user-notifications" /> <DSection @pageClass="user-notifications" />
<div class="user-navigation user-navigation-secondary"> <div class="user-navigation user-navigation-secondary">
<ul id="navigation-bar" class="notifications-nav nav-pills action-list"> <HorizontalOverflowNav>
<li> <UserNav::NotificationsNav
<LinkTo @route="userNotifications.index"> @model={{this.model}}
{{d-icon "bell"}} @siteSettings={{this.siteSettings}}/>
<span>{{i18n "user.filters.all"}}</span> </HorizontalOverflowNav>
</LinkTo> </div>
</li>
<li>
<LinkTo @route="userNotifications.responses">
{{d-icon "reply"}}
<span>{{i18n "user_action_groups.6"}}</span>
</LinkTo>
</li>
<li>
<LinkTo @route="userNotifications.likesReceived">
{{d-icon "heart"}}
<span>{{i18n "user_action_groups.2"}}</span>
</LinkTo>
</li>
{{#if this.siteSettings.enable_mentions}}
<li>
<LinkTo @route="userNotifications.mentions">
{{d-icon "at"}}
<span>{{i18n "user_action_groups.7"}}</span>
</LinkTo>
</li>
{{/if}}
<li>
<LinkTo @route="userNotifications.edits">
{{d-icon "pencil-alt"}}
<span>{{i18n "user_action_groups.11"}}</span>
</LinkTo>
</li>
<PluginOutlet @name="user-notifications-bottom" @connectorTagName="li" @args={{hash model=this.model}} />
</ul>
{{#if this.model}} {{#if this.model}}
<div class="navigation-controls"> <div class="navigation-controls">
<DButton @title="user.dismiss_notifications_tooltip" @class="btn btn-default dismiss-notifications" @action={{action "resetNew"}} @label="user.dismiss_notifications" @icon="check" @disabled={{this.allNotificationsRead}} /> <DButton @title="user.dismiss_notifications_tooltip" @class="btn btn-default dismiss-notifications" @action={{action "resetNew"}} @label="user.dismiss_notifications" @icon="check" @disabled={{this.allNotificationsRead}} />
</div> </div>
{{/if}} {{/if}}
</div>
{{else}} {{else}}
<DSection @pageClass="user-notifications" @class="user-secondary-navigation"> <DSection @pageClass="user-notifications" @class="user-secondary-navigation">
<MobileNav @class="notifications-nav" @desktopClass="notification-list action-list nav-stacked"> <MobileNav @class="notifications-nav" @desktopClass="notification-list action-list nav-stacked">

View File

@ -89,17 +89,25 @@
gap: 0 0.5em; gap: 0 0.5em;
border-bottom: 1px solid var(--primary-low); border-bottom: 1px solid var(--primary-low);
.horizontal-overflow-nav {
position: relative;
min-width: 0;
width: 100%;
}
.select-kit .select-kit-header { .select-kit .select-kit-header {
height: 100%; height: 100%;
padding: 0.5em 1em; padding: 0.5em 1em;
}
.category-breadcrumb {
@include breakpoint(large) { @include breakpoint(large) {
font-size: var(--font-down-1); font-size: var(--font-down-1);
} }
} > li {
.category-breadcrumb > li {
margin: 0; margin: 0;
} }
}
.navigation-controls { .navigation-controls {
flex-wrap: nowrap; flex-wrap: nowrap;
@ -123,7 +131,7 @@
.d-icon { .d-icon {
pointer-events: none; pointer-events: none;
margin-bottom: 0.2em; margin-bottom: 0.2em;
color: var(--tertiary); color: var(--quaternary);
} }
&.transparent { &.transparent {
// hiding with opacity so we can transition visibility // hiding with opacity so we can transition visibility