aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/menu/menu.component.ts
diff options
context:
space:
mode:
authorKimsible <1877318+kimsible@users.noreply.github.com>2020-12-13 14:54:12 +0100
committerGitHub <noreply@github.com>2020-12-13 14:54:12 +0100
commit51a83970061b4005343d2bfc4edb883318ef2ca6 (patch)
treec33753d0dc51bc534706b0839cf567d673294f29 /client/src/app/menu/menu.component.ts
parent75594f474a3e04086b37a014d23e89780ca67458 (diff)
downloadPeerTube-51a83970061b4005343d2bfc4edb883318ef2ca6.tar.gz
PeerTube-51a83970061b4005343d2bfc4edb883318ef2ca6.tar.zst
PeerTube-51a83970061b4005343d2bfc4edb883318ef2ca6.zip
User dropdown and notifications popover improvements (#3344)
* hove user dropdown on avatar and username * rename avatar-notification to notification component * use a link on mobile for notification component * add profile user dropdown and mobile notifications link as reusable active link * replace markAllAsRead inbox glyphicon to ok in notification popover * remove keyboard shortcuts from user dropdown on mobile * use common bell icon instead of inbox-full for notifications * remove duplicated notification in user dropdown since the bell appears on the right * adjust sensitive icon in user dropdown * align vertically user buttons popover and dropdown * adjust ellipsis on user display name and username in menu * adjust notification bell for mobile in menu * display background of user dropdown avatar and username for touchscreens * add right arrow indicator on mobile Co-authored-by: kimsible <kimsible@users.noreply.github.com> Co-authored-by: Rigel Kent <sendmemail@rigelk.eu>
Diffstat (limited to 'client/src/app/menu/menu.component.ts')
-rw-r--r--client/src/app/menu/menu.component.ts52
1 files changed, 45 insertions, 7 deletions
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index bdc95127b..50ff0e2b3 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -9,6 +9,7 @@ import { AuthService, AuthStatus, AuthUser, MenuService, RedirectService, Screen
9import { LanguageChooserComponent } from '@app/menu/language-chooser.component' 9import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
10import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component' 10import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component'
11import { ServerConfig, UserRight, VideoConstant } from '@shared/models' 11import { ServerConfig, UserRight, VideoConstant } from '@shared/models'
12import { NgbDropdown, NgbDropdownConfig } from '@ng-bootstrap/ng-bootstrap'
12 13
13const logger = debug('peertube:menu:MenuComponent') 14const logger = debug('peertube:menu:MenuComponent')
14 15
@@ -20,6 +21,7 @@ const logger = debug('peertube:menu:MenuComponent')
20export class MenuComponent implements OnInit { 21export class MenuComponent implements OnInit {
21 @ViewChild('languageChooserModal', { static: true }) languageChooserModal: LanguageChooserComponent 22 @ViewChild('languageChooserModal', { static: true }) languageChooserModal: LanguageChooserComponent
22 @ViewChild('quickSettingsModal', { static: true }) quickSettingsModal: QuickSettingsModalComponent 23 @ViewChild('quickSettingsModal', { static: true }) quickSettingsModal: QuickSettingsModalComponent
24 @ViewChild('dropdown') dropdown: NgbDropdown
23 25
24 user: AuthUser 26 user: AuthUser
25 isLoggedIn: boolean 27 isLoggedIn: boolean
@@ -30,8 +32,6 @@ export class MenuComponent implements OnInit {
30 videoLanguages: string[] = [] 32 videoLanguages: string[] = []
31 nsfwPolicy: string 33 nsfwPolicy: string
32 34
33 loggedInMorePlacement: string
34
35 currentInterfaceLanguage: string 35 currentInterfaceLanguage: string
36 36
37 private languages: VideoConstant<string>[] = [] 37 private languages: VideoConstant<string>[] = []
@@ -54,8 +54,27 @@ export class MenuComponent implements OnInit {
54 private hotkeysService: HotkeysService, 54 private hotkeysService: HotkeysService,
55 private screenService: ScreenService, 55 private screenService: ScreenService,
56 private menuService: MenuService, 56 private menuService: MenuService,
57 private dropdownConfig: NgbDropdownConfig,
57 private router: Router 58 private router: Router
58 ) { } 59 ) {
60 this.dropdownConfig.container = 'body'
61 }
62
63 get isInMobileView () {
64 return this.screenService.isInMobileView()
65 }
66
67 get dropdownContainer () {
68 if (this.isInMobileView) {
69 return null
70 } else {
71 return this.dropdownConfig.container
72 }
73 }
74
75 get language () {
76 return this.languageChooserModal.getCurrentLanguage()
77 }
59 78
60 get instanceName () { 79 get instanceName () {
61 return this.serverConfig.instance.name 80 return this.serverConfig.instance.name
@@ -76,10 +95,6 @@ export class MenuComponent implements OnInit {
76 95
77 this.computeAdminAccess() 96 this.computeAdminAccess()
78 97
79 this.loggedInMorePlacement = this.screenService.isInMobileView()
80 ? 'left-top auto'
81 : 'right-top auto'
82
83 this.currentInterfaceLanguage = this.languageChooserModal.getCurrentLanguage() 98 this.currentInterfaceLanguage = this.languageChooserModal.getCurrentLanguage()
84 99
85 this.authService.loginChangedSource.subscribe( 100 this.authService.loginChangedSource.subscribe(
@@ -203,6 +218,29 @@ export class MenuComponent implements OnInit {
203 } 218 }
204 } 219 }
205 220
221 // Lock menu scroll when menu scroll to avoid fleeing / detached dropdown
222 onMenuScrollEvent () {
223 document.querySelector('menu').scrollTo(0, 0)
224 }
225
226 onDropdownOpenChange (opened: boolean) {
227 if (this.screenService.isInMobileView()) return
228
229 // Close dropdown when window scroll to avoid dropdown quick jump for re-position
230 const onWindowScroll = () => {
231 this.dropdown.close()
232 window.removeEventListener('scroll', onWindowScroll)
233 }
234
235 if (opened) {
236 window.addEventListener('scroll', onWindowScroll)
237 document.querySelector('menu').scrollTo(0, 0) // Reset menu scroll to easy lock
238 document.querySelector('menu').addEventListener('scroll', this.onMenuScrollEvent)
239 } else {
240 document.querySelector('menu').removeEventListener('scroll', this.onMenuScrollEvent)
241 }
242 }
243
206 private buildUserLanguages () { 244 private buildUserLanguages () {
207 if (!this.user) { 245 if (!this.user) {
208 this.videoLanguages = [] 246 this.videoLanguages = []