Skip to content

Commit

Permalink
Improve navigation sub-menu and tabs effects (#2971)
Browse files Browse the repository at this point in the history
* Improve nav border and colors on active and non-active

* Remove margin-top effect on active nav

* Use opacity / bold instead of color change on nav

* Remove dropdown items label in sub-menu and add a class active

* Position sub-menu to fixed

* Autoclose dropdown sub-menu only on outside click

* Remove open dropdown on hover in sub-menu

* Show reusable h1 for dropdown item in sub-menu

* Put reusable sub-menu h1 styles to mixins

* Add icons to sub-menu dropdown-item h1

* Make all the sub-menu accessible with focus

Co-authored-by: kimsible <kimsible@users.noreply.github.com>
  • Loading branch information
kimsible and kimsible committed Jul 23, 2020
1 parent 345b4a2 commit ed5bb51
Show file tree
Hide file tree
Showing 29 changed files with 169 additions and 97 deletions.
5 changes: 5 additions & 0 deletions client/src/app/+admin/admin.component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@import '_variables';
@import '_mixins';

my-top-menu-dropdown {
flex-grow: 1;
}

@include sub-menu-h1;
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h1>
<my-global-icon iconName="follower" aria-hidden="true"></my-global-icon>
<ng-container i18n>Instances following you</ng-container>
</h1>

<p-table
[value]="followers" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions"
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" (onPage)="onPage($event)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h1>
<my-global-icon iconName="following" aria-hidden="true"></my-global-icon>
<ng-container i18n>Instances you follow</ng-container>
</h1>

<p-table
[value]="following" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions"
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" (onPage)="onPage($event)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h1>
<my-global-icon iconName="videos" aria-hidden="true"></my-global-icon>
<ng-container i18n>Videos redundancies</ng-container>
</h1>

<div class="admin-sub-header">
<div class="select-filter-block">
<label for="displayType" i18n>Display</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h1>
<my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
<ng-container i18n>Reports</ng-container>
</h1>

<p-table
[value]="abuses" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions"
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id" [resizableColumns]="true" [lazyLoadOnInit]="false"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h1>
<my-global-icon iconName="cross" aria-hidden="true"></my-global-icon>
<ng-container i18n>Video blocks</ng-container>
</h1>

<p-table
[value]="blocklist" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions"
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id"
Expand Down
2 changes: 0 additions & 2 deletions client/src/app/+admin/plugins/plugins.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<div class="admin-sub-header">
<h1 i18n class="form-sub-title">Plugins/Themes</h1>

<div class="admin-sub-nav">
<a i18n routerLink="list-installed" routerLinkActive="active">Installed</a>

Expand Down
5 changes: 0 additions & 5 deletions client/src/app/+admin/plugins/plugins.component.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
@import '_variables';
@import '_mixins';

.form-sub-title {
flex-grow: 0;
margin-right: 30px;
}

@media screen and (max-width: $small-view) {
::ng-deep .plugins .plugin .first-row {
flex-wrap: wrap;
Expand Down
2 changes: 0 additions & 2 deletions client/src/app/+admin/system/system.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<div class="admin-sub-header">
<h1 i18n class="form-sub-title">System</h1>

<div class="admin-sub-nav">
<a *ngIf="hasJobsRight()" i18n routerLink="jobs" routerLinkActive="active">Jobs</a>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<h1 class="sr-only" i18n>My channels</h1>
<h1>
<my-global-icon iconName="channel" aria-hidden="true"></my-global-icon>
<ng-container i18n>My channels</ng-container>
</h1>

<div class="video-channels-header">
<a class="create-button" routerLink="create">
<my-global-icon iconName="add" aria-hidden="true"></my-global-icon>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<h1 class="sr-only" i18n>History</h1>
<h1>
<my-global-icon iconName="history" aria-hidden="true"></my-global-icon>
<ng-container i18n>My history</ng-container>
</h1>

<div class="top-buttons">
<div class="history-switch">
<p-inputSwitch [(ngModel)]="videosHistoryEnabled" (ngModelChange)="onVideosHistoryChange()"></p-inputSwitch>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<h1 class="sr-only" i18n>Ownership changes</h1>
<h1>
<my-global-icon iconName="download" aria-hidden="true"></my-global-icon>
<ng-container i18n>My ownership changes</ng-container>
</h1>

<p-table
[value]="videoChangeOwnerships"
[lazy]="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<h1 class="sr-only" i18n>Subscriptions</h1>
<h1>
<my-global-icon iconName="subscriptions" aria-hidden="true"></my-global-icon>
<ng-container i18n>My subscriptions</ng-container>
</h1>

<div class="no-results" i18n *ngIf="pagination.totalItems === 0">You don't have any subscriptions yet.</div>

<div class="video-channels" myInfiniteScroller [autoInit]="true" (nearOfBottom)="onNearOfBottom()" [dataObservable]="onDataSubject.asObservable()">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<h1 class="sr-only" i18n>Imports</h1>
<h1>
<my-global-icon iconName="cloud-download" aria-hidden="true"></my-global-icon>
<ng-container i18n>My imports</ng-container>
</h1>

<p-table
[value]="videoImports" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions"
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<div class="video-playlists-header">
<h1 i18n>Playlists <span class="badge badge-secondary">{{ pagination.totalItems }}</span></h1>
<h1>
<my-global-icon iconName="playlists" aria-hidden="true"></my-global-icon>
<ng-container i18n>My playlists</ng-container> <span class="badge badge-secondary">{{ pagination.totalItems }}</span>
</h1>


<div class="video-playlists-header">
<input type="text" placeholder="Search your playlists" i18n-placeholder [(ngModel)]="videoPlaylistsSearch" (ngModelChange)="onVideoPlaylistSearchChanged()" />

<a class="create-button" routerLink="create">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
input[type=text] {
@include peertube-input-text(300px);
}

h1 {
font-size: 1.5rem;
}
}

@media screen and (max-width: $small-view) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<div class="videos-header">
<h1 i18n>Videos <span class="badge badge-secondary">{{ pagination.totalItems }}</span></h1>
<h1>
<my-global-icon iconName="videos" aria-hidden="true"></my-global-icon>
<ng-container i18n>My videos</ng-container><span class="badge badge-secondary"> {{ pagination.totalItems }}</span>
</h1>

<div class="videos-header">
<input type="text" placeholder="Search your videos" i18n-placeholder [(ngModel)]="videosSearch" (ngModelChange)="onVideosSearchChanged()" />

<div class="fake-element"></div>
</div>

<my-videos-selection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
justify-content: space-between;
margin: 20px 0 50px;

h1,
.fake-element {
flex: 1;
font-size: 1.5rem;
}

input[type=text] {
@include peertube-input-text(300px);
}
Expand Down
5 changes: 5 additions & 0 deletions client/src/app/+my-account/my-account.component.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
@import '_variables';
@import '_mixins';

.row {
flex-direction: column;
width: 100%;

& > my-top-menu-dropdown:nth-child(1) {
flex-grow: 1;
}

@include sub-menu-h1;
}
19 changes: 14 additions & 5 deletions client/src/app/+videos/+video-edit/video-add.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,25 @@ $nav-link-height: 40px;
padding: 0 30px !important;
font-size: 15px;

border: $border-width $border-type transparent;

span {
border-bottom: 2px solid transparent;
}

&.active {
border: $border-width $border-type $border-color;
border-bottom: none;
border-color: $border-color;
border-bottom-color: transparent;
background-color: pvar(--submenuColor) !important;

span {
border-bottom: 2px solid pvar(--mainColor);
font-weight: $font-bold;
border-bottom-color: pvar(--mainColor);
}
}

&:hover:not(.active) {
border-color: transparent;
}
}
}

Expand Down Expand Up @@ -71,7 +80,7 @@ $nav-link-height: 40px;

/* Hide active tab style to not have a moving tab effect */
a.nav-link.active {
border: none;
border-color: transparent;
background-color: pvar(--mainBackgroundColor) !important;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@
<a *ngIf="menuEntry.routerLink" [routerLink]="menuEntry.routerLink" routerLinkActive="active" class="title-page title-page-settings">{{ menuEntry.label }}</a>

<div *ngIf="!menuEntry.routerLink" ngbDropdown class="parent-entry"
#dropdown="ngbDropdown" (mouseleave)="closeDropdownIfHovered(dropdown)">
#dropdown="ngbDropdown" autoClose="outside">
<span
*ngIf="isInSmallView"
tabindex=0
[ngClass]="{ active: !!suffixLabels[menuEntry.label] }"
(click)="openModal(id)" role="button" class="title-page title-page-settings">
(click)="openModal(id)" (keydown.enter)="openModal(id)"
role="button" class="title-page title-page-settings">
<ng-container i18n>{{ menuEntry.label }}</ng-container>
<ng-container *ngIf="!!suffixLabels[menuEntry.label]"> - {{ suffixLabels[menuEntry.label] }}</ng-container>
</span>

<span
*ngIf="!isInSmallView"
(mouseenter)="openDropdownOnHover(dropdown)" [ngClass]="{ active: !!suffixLabels[menuEntry.label] }" ngbDropdownAnchor
(click)="dropdownAnchorClicked(dropdown)" role="button" class="title-page title-page-settings"
tabindex=0
[ngClass]="{ active: !!suffixLabels[menuEntry.label] }" ngbDropdownAnchor
(click)="dropdownAnchorClicked(dropdown)" (keydown.enter)="dropdownAnchorClicked(dropdown)"
role="button" class="title-page title-page-settings"
>
<ng-container i18n>{{ menuEntry.label }}</ng-container>
<ng-container *ngIf="!!suffixLabels[menuEntry.label]"> - {{ suffixLabels[menuEntry.label] }}</ng-container>
</span>

<div ngbDropdownMenu>
<a *ngFor="let menuChild of menuEntry.children" class="dropdown-item" [ngClass]="{ icon: hasIcons }" [routerLink]="menuChild.routerLink">
<a *ngFor="let menuChild of menuEntry.children" class="dropdown-item" [ngClass]="{ icon: hasIcons, active: suffixLabels[menuEntry.label] === menuChild.label }" [routerLink]="menuChild.routerLink">
<my-global-icon *ngIf="menuChild.iconName" [iconName]="menuChild.iconName" aria-hidden="true"></my-global-icon>

{{ menuChild.label }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
@import '_variables';
@import '_mixins';

:host {
display: block;
height: $sub-menu-height;
margin-bottom: $sub-menu-margin-bottom;
}

.parent-entry {
span[role=button] {
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class TopMenuDropdownComponent implements OnInit, OnDestroy {
isModalOpened = false
currentMenuEntryIndex: number

private openedOnHover = false
private routeSub: Subscription

constructor (
Expand Down Expand Up @@ -68,32 +67,10 @@ export class TopMenuDropdownComponent implements OnInit, OnDestroy {
if (this.routeSub) this.routeSub.unsubscribe()
}

openDropdownOnHover (dropdown: NgbDropdown) {
this.openedOnHover = true
dropdown.open()

// Menu was closed
dropdown.openChange
.pipe(take(1))
.subscribe(() => this.openedOnHover = false)
}

dropdownAnchorClicked (dropdown: NgbDropdown) {
if (this.openedOnHover) {
this.openedOnHover = false
return
}

return dropdown.toggle()
}

closeDropdownIfHovered (dropdown: NgbDropdown) {
if (this.openedOnHover === false) return

dropdown.close()
this.openedOnHover = false
}

openModal (index: number) {
this.currentMenuEntryIndex = index
this.isModalOpened = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h1>
<my-global-icon iconName="user" aria-hidden="true"></my-global-icon>
<ng-container i18n>Muted accounts</ng-container>
</h1>

<p-table
[value]="blockedAccounts" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions"
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" (onPage)="onPage($event)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h1>
<my-global-icon iconName="server" aria-hidden="true"></my-global-icon>
<ng-container i18n>Muted servers</ng-container>
</h1>

<p-table
[value]="blockedServers" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions"
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" (onPage)="onPage($event)"
Expand Down
Loading

1 comment on commit ed5bb51

@rigelk
Copy link
Collaborator

@rigelk rigelk commented on ed5bb51 Jul 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I took a stab at it in a previous commit but channel/account public views are impacted more than I thought

Please sign in to comment.