shortcuts component done

+ couple fixes in colors.scss
+ added getFlatNavigation() to the navigation service
+ tweaks in navigation files
This commit is contained in:
Sercan Yemen 2017-08-07 13:29:58 +03:00
parent e220a19b4e
commit e8aff89668
11 changed files with 250 additions and 29 deletions

View File

@ -59,7 +59,7 @@ export class FuseNavigation
{ {
'title': 'To-Do', 'title': 'To-Do',
'type' : 'nav-item', 'type' : 'nav-item',
'icon' : 'checkbox_cricle', 'icon' : 'check_box',
'url' : '/apps/todo' 'url' : '/apps/todo'
}, },
{ {

View File

@ -1,6 +1,6 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {SharedModule} from '../../modules/shared.module'; import {SharedModule} from '../../modules/shared.module';
import {RouterModule, Routes} from '@angular/router'; import {RouterModule} from '@angular/router';
import {FuseNavSubheaderComponent} from './nav-subheader/nav-subheader.component'; import {FuseNavSubheaderComponent} from './nav-subheader/nav-subheader.component';
import {FuseNavigationComponent} from './navigation.component'; import {FuseNavigationComponent} from './navigation.component';
import {FuseNavItemComponent} from './nav-item/nav-item.component'; import {FuseNavItemComponent} from './nav-item/nav-item.component';

View File

@ -1,19 +1,64 @@
import {EventEmitter, Injectable} from '@angular/core'; import { EventEmitter, Injectable } from '@angular/core';
import {FuseNavigation} from './navigation.model'; import { FuseNavigation } from './navigation.model';
@Injectable() @Injectable()
export class FuseNavigationService export class FuseNavigationService
{ {
onNavCollapseToggled = new EventEmitter<any>(); onNavCollapseToggled = new EventEmitter<any>();
navigation: object[]; navigation: any[];
flatNavigation: any[] = [];
constructor() constructor()
{ {
this.navigation = new FuseNavigation().items; this.navigation = new FuseNavigation().items;
} }
/**
* Get navigation array
* @returns {any[]}
*/
getNavigation() getNavigation()
{ {
return this.navigation; return this.navigation;
} }
/**
* Get flattened navigation array
* @param navigationItems
* @returns {any[]}
*/
getFlatNavigation(navigationItems?)
{
if ( !navigationItems )
{
navigationItems = this.navigation;
}
for ( const navItem of navigationItems )
{
if ( navItem.type === 'subheader' )
{
continue;
}
if ( navItem.type === 'nav-item' )
{
this.flatNavigation.push({
title : navItem.title,
titleAbbr: navItem.title.substr(0, 1).toUpperCase(),
icon : navItem.icon || false,
url : navItem.url
});
continue;
}
if ( navItem.type === 'nav-collapse' )
{
this.getFlatNavigation(navItem.children);
}
}
return this.flatNavigation;
}
} }

View File

@ -0,0 +1,65 @@
<div id="fuse-shortcuts">
<div fxLayout="row" fxLayoutAlign="start center">
<div class="w-40 h-40 p-4" fxLayout="row" fxLayoutAlign="center center"
*ngFor="let shortcutItem of shortcutItems">
<a md-icon-button mdTooltip="{{shortcutItem.title}}" [routerLink]="shortcutItem.url">
<md-icon *ngIf="shortcutItem.icon">{{shortcutItem.icon}}</md-icon>
<span *ngIf="!shortcutItem.icon" class="h2 secondary-text text-bold">{{shortcutItem.titleAbbr}}</span>
</a>
</div>
<button md-icon-button [mdMenuTriggerFor]="addMenu">
<md-icon>add</md-icon>
</button>
</div>
<md-menu #addMenu="mdMenu">
<md-input-container class="px-16" (click)="$event.stopPropagation()">
<input mdInput placeholder="Search for an app or a page" (input)="search($event)">
</md-input-container>
<md-divider></md-divider>
<md-nav-list *ngIf="!searching" style="max-height: 312px; overflow: auto">
<h3 md-subheader>Current Shortcuts</h3>
<md-list-item *ngFor="let shortcutItem of shortcutItems"
(click)="toggleShortcut($event, shortcutItem)">
<div class="w-100-p" fxLayout="row" fxLayoutAlign="start center">
<md-icon md-list-icon class="mr-8" *ngIf="shortcutItem.icon">{{shortcutItem.icon}}</md-icon>
<span class="h2 w-32 h-32 p-4 mr-8 secondary-text text-bold" fxLayout="row"
fxLayoutAlign="center center" *ngIf="!shortcutItem.icon">
{{shortcutItem.titleAbbr}}
</span>
<p md-line>{{shortcutItem.title}}</p>
</div>
</md-list-item>
<md-list-item *ngIf="shortcutItems.length === 0">
<p>
<small>No shortcuts yet!</small>
</p>
</md-list-item>
</md-nav-list>
<md-nav-list *ngIf="searching" style="max-height: 312px; overflow: auto">
<md-list-item *ngFor="let navigationItem of filteredNavigationItems"
(click)="toggleShortcut($event, navigationItem)">
<div class="w-100-p" fxLayout="row" fxLayoutAlign="start center">
<md-icon md-list-icon class="mr-8" *ngIf="navigationItem.icon">{{navigationItem.icon}}</md-icon>
<span class="h2 w-32 h-32 p-4 mr-8 secondary-text text-bold" fxLayout="row"
fxLayoutAlign="center center" *ngIf="!navigationItem.icon">
{{navigationItem.titleAbbr}}
</span>
<p md-line>{{navigationItem.title}}</p>
</div>
</md-list-item>
</md-nav-list>
</md-menu>
</div>

View File

@ -0,0 +1,3 @@
:host {
}

View File

@ -0,0 +1,87 @@
import { Component, OnInit } from '@angular/core';
import { FuseNavigationService } from '../navigation/navigation.service';
@Component({
selector : 'fuse-shortcuts',
templateUrl: './shortcuts.component.html',
styleUrls : ['./shortcuts.component.scss']
})
export class FuseShortcutsComponent implements OnInit
{
shortcutItems: any[] = [];
navigationItems: any[];
filteredNavigationItems: any[];
searching = false;
constructor(private fuseNavigationService: FuseNavigationService)
{
this.filteredNavigationItems = this.navigationItems = this.fuseNavigationService.getFlatNavigation();
}
ngOnInit()
{
// User's shortcut items
this.shortcutItems = [
{
'title': 'Calendar',
'type' : 'nav-item',
'icon' : 'today',
'url' : '/apps/calendar'
},
{
'title': 'Mail',
'type' : 'nav-item',
'icon' : 'email',
'url' : '/apps/mail'
},
{
'title': 'Contacts',
'type' : 'nav-item',
'icon' : 'account_box',
'url' : '/apps/contacts'
},
{
'title': 'To-Do',
'type' : 'nav-item',
'icon' : 'check_box',
'url' : '/apps/todo'
}
];
}
search(event)
{
const value = event.target.value.toLowerCase();
if ( value === '' )
{
this.searching = false;
this.filteredNavigationItems = this.navigationItems;
return;
}
this.searching = true;
this.filteredNavigationItems = this.navigationItems.filter((navigationItem) => {
return navigationItem.title.toLowerCase().includes(value);
});
}
toggleShortcut(event, itemToToggle)
{
event.stopPropagation();
for ( let i = 0; i < this.shortcutItems.length; i++ )
{
if ( this.shortcutItems[i].url === itemToToggle.url )
{
this.shortcutItems.splice(i, 1);
return;
}
}
this.shortcutItems.push(itemToToggle);
}
}

View File

@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { FuseShortcutsComponent } from './shortcuts.component';
import { SharedModule } from '../../modules/shared.module';
@NgModule({
declarations: [
FuseShortcutsComponent
],
imports : [
SharedModule,
RouterModule
],
exports : [
FuseShortcutsComponent
]
})
export class FuseShortcutsModule
{
}

View File

@ -48,12 +48,12 @@ import { FuseHljsComponent } from '../components/hljs/hljs.component';
FuseMdSidenavHelperDirective, FuseMdSidenavHelperDirective,
FuseMdSidenavTogglerDirective, FuseMdSidenavTogglerDirective,
FusePipesModule, FusePipesModule,
FuseCountdownComponent,
FuseHljsComponent,
PerfectScrollbarModule, PerfectScrollbarModule,
ReactiveFormsModule, ReactiveFormsModule,
ColorPickerModule, ColorPickerModule,
NgxDnDModule, NgxDnDModule,
FuseCountdownComponent,
FuseHljsComponent,
NgxDatatableModule NgxDatatableModule
], ],
entryComponents: [ entryComponents: [

View File

@ -1,3 +1,18 @@
.secondary-text,
.mat-icon,
.icon {
color: rgba(0, 0, 0, 0.54) !important;
}
.hint-text,
.disabled-text {
color: rgba(0, 0, 0, 0.38) !important;
}
.divider {
color: rgba(0, 0, 0, 0.12) !important;
}
// Material colors map // Material colors map
$matColorsMap: ( $matColorsMap: (
primary: $primary, primary: $primary,
@ -37,9 +52,7 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400
&.secondary-text, &.secondary-text,
.secondary-text, .secondary-text,
&.mat-icon,
.mat-icon, .mat-icon,
&.icon,
.icon { .icon {
color: rgba(0, 0, 0, 0.54) !important; color: rgba(0, 0, 0, 0.54) !important;
} }
@ -64,9 +77,7 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400
// If the base text color is white... // If the base text color is white...
@else { @else {
&.mat-icon,
.mat-icon, .mat-icon,
&.icon,
.icon { .icon {
color: rgba(255, 255, 255, 1) !important; color: rgba(255, 255, 255, 1) !important;
} }
@ -114,7 +125,7 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400
color: $color !important; color: $color !important;
// Generate text color levels // Generate text color levels
// based on current color // based on current contrast color
@include generateTextColorLevels($color); @include generateTextColorLevels($color);
} }
@ -158,18 +169,3 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400
} }
} }
} }
.secondary-text,
.mat-icon,
.icon {
color: rgba(0, 0, 0, 0.54) !important;
}
.hint-text,
.disabled-text {
color: rgba(0, 0, 0, 0.38) !important;
}
.divider {
color: rgba(0, 0, 0, 0.12) !important;
}

View File

@ -10,6 +10,7 @@ import { FuseNavigationModule } from '../core/components/navigation/navigation.m
import { FuseNavbarToggleDirective } from './navbar/navbar-toggle.directive'; import { FuseNavbarToggleDirective } from './navbar/navbar-toggle.directive';
import { QuickPanelComponent } from './quick-panel/quick-panel.component'; import { QuickPanelComponent } from './quick-panel/quick-panel.component';
import { FuseThemeOptionsComponent } from '../core/components/theme-options/theme-options.component'; import { FuseThemeOptionsComponent } from '../core/components/theme-options/theme-options.component';
import { FuseShortcutsModule } from '../core/components/shortcuts/shortcuts.module';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -25,7 +26,8 @@ import { FuseThemeOptionsComponent } from '../core/components/theme-options/them
imports : [ imports : [
SharedModule, SharedModule,
RouterModule, RouterModule,
FuseNavigationModule FuseNavigationModule,
FuseShortcutsModule
], ],
exports : [ exports : [
FuseMainComponent FuseMainComponent

View File

@ -10,7 +10,9 @@
<div class="toolbar-separator" fxHide.gt-xs></div> <div class="toolbar-separator" fxHide.gt-xs></div>
<div class="px-16">Shortcuts</div> <div class="px-16">
<fuse-shortcuts></fuse-shortcuts>
</div>
</div> </div>
<div class="" fxFlex="0 1 auto" fxLayout="row" fxLayoutAlign="start center"> <div class="" fxFlex="0 1 auto" fxLayout="row" fxLayoutAlign="start center">