diff --git a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.html b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.html index a60ed885d..f0e9f4010 100644 --- a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.html +++ b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.html @@ -15,7 +15,7 @@ - + See all your notifications diff --git a/client/src/app/menu/avatar-notification.component.scss b/client/src/app/menu/notification.component.scss similarity index 61% rename from client/src/app/menu/avatar-notification.component.scss rename to client/src/app/menu/notification.component.scss index 88f2b6296..40feb9e66 100644 --- a/client/src/app/menu/avatar-notification.component.scss +++ b/client/src/app/menu/notification.component.scss @@ -1,17 +1,62 @@ @import '_variables'; @import '_mixins'; + +.notification-inbox-popover { + padding: 10px; +} + +.notification-inbox-link a { + padding: 13px 10px; +} + +.notification-inbox-popover, +.notification-inbox-link a { + @include apply-svg-color(#808080); + ::ng-deep { + svg { + transition: color .1s ease-in-out; + } + } + + transition: all .1s ease-in-out; + border-radius: 25px; + cursor: pointer; + + &:hover, &:active { + background-color: rgba(255, 255, 255, 0.15); + @include apply-svg-color(#fff); + } +} + +.notification-inbox-popover.shown, +.notification-inbox-link a.active { + @include apply-svg-color(#fff); + + background-color: rgba(255, 255, 255, 0.28); + box-shadow: inset 0 3px 5px rgba(0, 0, 0, .325); +} + +.notification-inbox-popover.hidden { + display: none; +} + ::ng-deep { .popover-notifications.popover { max-width: none; + top: -6px !important; left: 7px !important; + .arrow { + display: none; + } + .popover-body { padding: 0; font-size: 14px; font-family: $main-fonts; width: 400px; - box-shadow: 0 6px 14px rgba(0, 0, 0, 0.30); + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.30); .loader { display: flex; @@ -42,19 +87,22 @@ display: flex; justify-content: space-between; - background-color: rgba(0, 0, 0, 0.10); + border-bottom: 1px solid rgba(0, 0, 0, 0.1); align-items: center; - padding: 0 10px; - font-size: 16px; - min-height: 50px; + padding: 0 12px; + font-size: 14px; + font-weight: bold; + color: rgba(0, 0, 0, 0.5); + text-transform: uppercase; + min-height: 40px; a { @include disable-default-a-behaviour; } - + button { @include peertube-button; - + padding: 0; background: transparent; } @@ -82,25 +130,23 @@ } } -.notification-avatar { +.notification-inbox-popover, .notification-inbox-link { cursor: pointer; position: relative; - img, .unread-notifications { margin-left: 20px; } - img { - @include avatar(34px); - - margin-right: 10px; - } - .unread-notifications { position: absolute; - top: -5px; - left: -5px; + top: 6px; + left: 0; + + @media screen and (max-width: $mobile-view) { + top: -4px; + left: -2px; + } display: flex; align-items: center; @@ -116,19 +162,3 @@ height: 15px; } } - -@media screen and (max-width: $mobile-view) { - ::ng-deep { - .popover-notifications.popover { - left: unset !important; - - .arrow { - left: calc(2em + 7px); - } - - .popover-body { - width: 100vw; - } - } - } -} diff --git a/client/src/app/menu/avatar-notification.component.ts b/client/src/app/menu/notification.component.ts similarity index 67% rename from client/src/app/menu/avatar-notification.component.ts rename to client/src/app/menu/notification.component.ts index ed3ffc2d8..b7d9e9abb 100644 --- a/client/src/app/menu/avatar-notification.component.ts +++ b/client/src/app/menu/notification.component.ts @@ -1,24 +1,24 @@ import { Subject, Subscription } from 'rxjs' import { filter } from 'rxjs/operators' -import { Component, EventEmitter, Input, Output, OnDestroy, OnInit, ViewChild } from '@angular/core' +import { Component, EventEmitter, Output, OnDestroy, OnInit, ViewChild } from '@angular/core' import { NavigationEnd, Router } from '@angular/router' -import { Notifier, User, PeerTubeSocket } from '@app/core' +import { Notifier, PeerTubeSocket, ScreenService } from '@app/core' import { UserNotificationService } from '@app/shared/shared-main' import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' @Component({ - selector: 'my-avatar-notification', - templateUrl: './avatar-notification.component.html', - styleUrls: [ './avatar-notification.component.scss' ] + selector: 'my-notification', + templateUrl: './notification.component.html', + styleUrls: [ './notification.component.scss' ] }) -export class AvatarNotificationComponent implements OnInit, OnDestroy { +export class NotificationComponent implements OnInit, OnDestroy { @ViewChild('popover', { static: true }) popover: NgbPopover - @Input() user: User @Output() navigate = new EventEmitter() unreadNotifications = 0 loaded = false + opened = false markAllAsReadSubject = new Subject() @@ -27,6 +27,7 @@ export class AvatarNotificationComponent implements OnInit, OnDestroy { constructor ( private userNotificationService: UserNotificationService, + private screenService: ScreenService, private peertubeSocket: PeerTubeSocket, private notifier: Notifier, private router: Router @@ -54,12 +55,31 @@ export class AvatarNotificationComponent implements OnInit, OnDestroy { if (this.routeSub) this.routeSub.unsubscribe() } + get isInMobileView () { + return this.screenService.isInMobileView() + } + closePopover () { this.popover.close() } + onPopoverShown () { + this.opened = true + + document.querySelector('menu').scrollTo(0, 0) // Reset menu scroll to easy lock + document.querySelector('menu').addEventListener('scroll', this.onMenuScrollEvent) + } + onPopoverHidden () { this.loaded = false + this.opened = false + + document.querySelector('menu').removeEventListener('scroll', this.onMenuScrollEvent) + } + + // Lock menu scroll when menu scroll to avoid fleeing / detached dropdown + onMenuScrollEvent () { + document.querySelector('menu').scrollTo(0, 0) } onNotificationLoaded () { @@ -67,6 +87,7 @@ export class AvatarNotificationComponent implements OnInit, OnDestroy { } onNavigate (link: HTMLAnchorElement) { + this.closePopover() this.navigate.emit(link) } @@ -83,5 +104,4 @@ export class AvatarNotificationComponent implements OnInit, OnDestroy { if (data.type === 'read-all') return this.unreadNotifications = 0 }) } - } diff --git a/client/src/app/shared/shared-icons/global-icon.component.ts b/client/src/app/shared/shared-icons/global-icon.component.ts index 53a2aee9a..0924b8119 100644 --- a/client/src/app/shared/shared-icons/global-icon.component.ts +++ b/client/src/app/shared/shared-icons/global-icon.component.ts @@ -36,7 +36,7 @@ const icons = { 'clock': require('!!raw-loader?!../../../assets/images/feather/clock.svg').default, 'cog': require('!!raw-loader?!../../../assets/images/feather/cog.svg').default, 'delete': require('!!raw-loader?!../../../assets/images/feather/delete.svg').default, - 'inbox-full': require('!!raw-loader?!../../../assets/images/feather/inbox-full.svg').default, + 'bell': require('!!raw-loader?!../../../assets/images/feather/bell.svg').default, 'sign-out': require('!!raw-loader?!../../../assets/images/feather/log-out.svg').default, 'sign-in': require('!!raw-loader?!../../../assets/images/feather/log-in.svg').default, 'download': require('!!raw-loader?!../../../assets/images/feather/download.svg').default, diff --git a/client/src/assets/images/feather/bell.svg b/client/src/assets/images/feather/bell.svg new file mode 100644 index 000000000..bba561c19 --- /dev/null +++ b/client/src/assets/images/feather/bell.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/src/assets/images/feather/inbox-full.svg b/client/src/assets/images/feather/inbox-full.svg deleted file mode 100644 index 03a13b4e4..000000000 --- a/client/src/assets/images/feather/inbox-full.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file