add shortcuts icon in menu

This commit is contained in:
Rigel Kent 2018-09-26 14:23:10 +02:00
parent 2e7cf5ae0c
commit 4a216666e7
No known key found for this signature in database
GPG Key ID: EA12971B0E438F36
5 changed files with 32 additions and 3 deletions

View File

@ -29,7 +29,7 @@ export class CheatSheetComponent implements OnInit, OnDestroy {
if (isOpen === false) { if (isOpen === false) {
this.helpVisible = false this.helpVisible = false
} else { } else {
this.toggleCheatSheet() this.toggleHelpVisible()
} }
}) })
} }
@ -41,6 +41,10 @@ export class CheatSheetComponent implements OnInit, OnDestroy {
} }
public toggleCheatSheet (): void { public toggleCheatSheet (): void {
this.hotkeysService.cheatSheetToggle.next(!this.helpVisible)
}
public toggleHelpVisible (): void {
this.helpVisible = !this.helpVisible this.helpVisible = !this.helpVisible
} }
} }

View File

@ -87,6 +87,9 @@
<span class="language"> <span class="language">
<span tabindex="0" (keyup.enter)="openLanguageChooser()" (click)="openLanguageChooser()" i18n-title title="Change the language" class="icon icon-language"></span> <span tabindex="0" (keyup.enter)="openLanguageChooser()" (click)="openLanguageChooser()" i18n-title title="Change the language" class="icon icon-language"></span>
</span> </span>
<span class="shortcuts">
<span tabindex="0" (keyup.enter)="openHotkeysCheatSheet()" (click)="openHotkeysCheatSheet()" i18n-title title="Show keyboard shortcuts" class="icon icon-shortcuts"></span>
</span>
<span class="color-palette"> <span class="color-palette">
<span tabindex="0" (keyup.enter)="toggleDarkTheme()" (click)="toggleDarkTheme()" i18n-title title="Toggle dark interface" class="icon icon-moonsun"></span> <span tabindex="0" (keyup.enter)="toggleDarkTheme()" (click)="toggleDarkTheme()" i18n-title title="Toggle dark interface" class="icon icon-moonsun"></span>
</span> </span>

View File

@ -196,7 +196,7 @@ menu {
padding-right: $menu-lateral-padding; padding-right: $menu-lateral-padding;
width: $menu-width; width: $menu-width;
.language, .color-palette { .language, .shortcuts, .color-palette {
display: inline-block; display: inline-block;
color: $menu-bottom-color; color: $menu-bottom-color;
cursor: pointer; cursor: pointer;
@ -217,6 +217,17 @@ menu {
background-image: url('../../assets/images/menu/language.png'); background-image: url('../../assets/images/menu/language.png');
} }
&.icon-shortcuts {
position: relative;
top: -1px;
width: 24px;
height: 24px;
background-image: url('../../assets/images/menu/keyboard.png');
background-color: #fff;
filter: invert(100%);
}
&.icon-moonsun { &.icon-moonsun {
margin-left: 10px; margin-left: 10px;
position: relative; position: relative;

View File

@ -3,6 +3,7 @@ import { UserRight } from '../../../../shared/models/users/user-right.enum'
import { AuthService, AuthStatus, RedirectService, ServerService, ThemeService } from '../core' import { AuthService, AuthStatus, RedirectService, ServerService, ThemeService } from '../core'
import { User } from '../shared/users/user.model' import { User } from '../shared/users/user.model'
import { LanguageChooserComponent } from '@app/menu/language-chooser.component' import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
import { HotkeysService } from 'angular2-hotkeys'
@Component({ @Component({
selector: 'my-menu', selector: 'my-menu',
@ -15,6 +16,7 @@ export class MenuComponent implements OnInit {
user: User user: User
isLoggedIn: boolean isLoggedIn: boolean
userHasAdminAccess = false userHasAdminAccess = false
helpVisible = false
private routesPerRight = { private routesPerRight = {
[UserRight.MANAGE_USERS]: '/admin/users', [UserRight.MANAGE_USERS]: '/admin/users',
@ -29,7 +31,8 @@ export class MenuComponent implements OnInit {
private authService: AuthService, private authService: AuthService,
private serverService: ServerService, private serverService: ServerService,
private redirectService: RedirectService, private redirectService: RedirectService,
private themeService: ThemeService private themeService: ThemeService,
private hotkeysService: HotkeysService
) {} ) {}
ngOnInit () { ngOnInit () {
@ -54,6 +57,10 @@ export class MenuComponent implements OnInit {
} }
} }
) )
this.hotkeysService.cheatSheetToggle.subscribe(isOpen => {
this.helpVisible = isOpen
})
} }
isRegistrationAllowed () { isRegistrationAllowed () {
@ -101,6 +108,10 @@ export class MenuComponent implements OnInit {
this.languageChooserModal.show() this.languageChooserModal.show()
} }
openHotkeysCheatSheet () {
this.hotkeysService.cheatSheetToggle.next(!this.helpVisible)
}
toggleDarkTheme () { toggleDarkTheme () {
this.themeService.toggleDarkTheme() this.themeService.toggleDarkTheme()
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 B