From e83e0ff07b20d7f8c6bb2a4c43852a3e70bc7e9c Mon Sep 17 00:00:00 2001 From: Sercan Yemen Date: Sun, 20 Aug 2017 13:26:45 +0300 Subject: [PATCH] fuse shortcuts mobile behavior --- .../shortcuts/shortcuts.component.html | 136 ++++++++++-------- .../shortcuts/shortcuts.component.scss | 23 +++ .../shortcuts/shortcuts.component.ts | 45 +++++- src/app/core/services/match-media.service.ts | 1 - src/app/main/toolbar/toolbar.component.html | 4 +- 5 files changed, 145 insertions(+), 64 deletions(-) diff --git a/src/app/core/components/shortcuts/shortcuts.component.html b/src/app/core/components/shortcuts/shortcuts.component.html index c0e595e2..256dcb29 100644 --- a/src/app/core/components/shortcuts/shortcuts.component.html +++ b/src/app/core/components/shortcuts/shortcuts.component.html @@ -1,67 +1,89 @@ -
+
-
+
+ +
-
+
- - {{shortcutItem.icon}} - - {{shortcutItem.title.substr(0, 1).toUpperCase()}} - - + - + + + + + + + + + + +
+ {{shortcutItem.icon}} + + {{shortcutItem.title.substr(0, 1).toUpperCase()}} + +

{{shortcutItem.title}}

+ star +
+
+ +

+ No shortcuts yet! +

+
+
+ + + +
+ {{navigationItem.icon}} + + {{navigationItem.title.substr(0, 1).toUpperCase()}} + +

{{navigationItem.title}}

+ star +
+
+
+
- - - - - - - - - - -
- {{shortcutItem.icon}} - - {{shortcutItem.title.substr(0, 1).toUpperCase()}} - -

{{shortcutItem.title}}

- star -
-
- -

- No shortcuts yet! -

-
-
- - - -
- {{navigationItem.icon}} - - {{navigationItem.title.substr(0, 1).toUpperCase()}} - -

{{navigationItem.title}}

- star -
-
-
-
-
diff --git a/src/app/core/components/shortcuts/shortcuts.component.scss b/src/app/core/components/shortcuts/shortcuts.component.scss index 8fdbe2d4..0ee3a166 100644 --- a/src/app/core/components/shortcuts/shortcuts.component.scss +++ b/src/app/core/components/shortcuts/shortcuts.component.scss @@ -1,3 +1,26 @@ +@import 'src/app/core/scss/fuse'; + :host { + @include media-breakpoint-down('sm') { + + #fuse-shortcuts { + + &.show-mobile-panel { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 99; + padding: 0 8px; + + .shortcuts { + display: flex !important; + flex: 1; + height: 100%; + } + } + } + } } \ No newline at end of file diff --git a/src/app/core/components/shortcuts/shortcuts.component.ts b/src/app/core/components/shortcuts/shortcuts.component.ts index be1a9ab0..49581c5c 100644 --- a/src/app/core/components/shortcuts/shortcuts.component.ts +++ b/src/app/core/components/shortcuts/shortcuts.component.ts @@ -1,20 +1,32 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; +import { Component, ElementRef, OnDestroy, OnInit, Renderer2, ViewChild } from '@angular/core'; import { FuseNavigationService } from '../navigation/navigation.service'; +import { Subscription } from 'rxjs/Subscription'; +import { ObservableMedia } from '@angular/flex-layout'; +import { FuseMatchMedia } from '../../services/match-media.service'; @Component({ selector : 'fuse-shortcuts', templateUrl: './shortcuts.component.html', styleUrls : ['./shortcuts.component.scss'] }) -export class FuseShortcutsComponent implements OnInit +export class FuseShortcutsComponent implements OnInit, OnDestroy { shortcutItems: any[] = []; navigationItems: any[]; filteredNavigationItems: any[]; searching = false; - @ViewChild('searchInput') searchInputField; + mobileShortcutsPanelActive = false; + matchMediaSubscription: Subscription; - constructor(private fuseNavigationService: FuseNavigationService) + @ViewChild('searchInput') searchInputField; + @ViewChild('shortcuts') shortcutsEl: ElementRef; + + constructor( + private renderer: Renderer2, + private observableMedia: ObservableMedia, + private fuseMatchMedia: FuseMatchMedia, + private fuseNavigationService: FuseNavigationService + ) { this.filteredNavigationItems = this.navigationItems = this.fuseNavigationService.getFlatNavigation(); } @@ -48,6 +60,19 @@ export class FuseShortcutsComponent implements OnInit 'url' : '/apps/todo' } ]; + + this.matchMediaSubscription = + this.fuseMatchMedia.onMediaChange.subscribe(() => { + if ( this.observableMedia.isActive('gt-sm') ) + { + this.hideMobileShortcutsPanel(); + } + }); + } + + ngOnDestroy() + { + this.matchMediaSubscription.unsubscribe(); } search(event) @@ -97,4 +122,16 @@ export class FuseShortcutsComponent implements OnInit { this.searchInputField.nativeElement.focus(); } + + showMobileShortcutsPanel() + { + this.mobileShortcutsPanelActive = true; + this.renderer.addClass(this.shortcutsEl.nativeElement, 'show-mobile-panel'); + } + + hideMobileShortcutsPanel() + { + this.mobileShortcutsPanelActive = false; + this.renderer.removeClass(this.shortcutsEl.nativeElement, 'show-mobile-panel'); + } } diff --git a/src/app/core/services/match-media.service.ts b/src/app/core/services/match-media.service.ts index 43fcf723..6e843bc3 100644 --- a/src/app/core/services/match-media.service.ts +++ b/src/app/core/services/match-media.service.ts @@ -5,7 +5,6 @@ import { EventEmitter, Injectable } from '@angular/core'; export class FuseMatchMedia { activeMediaQuery: string; - // onMediaChange: Observable; onMediaChange: EventEmitter = new EventEmitter(); constructor(private observableMedia: ObservableMedia) diff --git a/src/app/main/toolbar/toolbar.component.html b/src/app/main/toolbar/toolbar.component.html index 3c58c96d..a6ba8ffb 100644 --- a/src/app/main/toolbar/toolbar.component.html +++ b/src/app/main/toolbar/toolbar.component.html @@ -10,11 +10,11 @@
-
+
-
+