Commit 48f8ff50 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

navigation bar and side nav (completed)

parent 362d388c
<app-nav></app-nav>
<mat-sidenav-container>
<mat-sidenav #sidenav role="navigation">
<!--this is a place for us to add side-nav code-->
<app-sidenav-list (sidenavClose)="sidenav.close()"></app-sidenav-list>
</mat-sidenav>
<mat-sidenav-content>
<!--in here all the content must reside. We will add a navigation header as well-->
<mat-sidenav-content>
<app-header (sidenavToggle)="sidenav.toggle()"></app-header>
<main>
<router-outlet></router-outlet>
</main>
</mat-sidenav-content>
</mat-sidenav-content>
</mat-sidenav-container>
mat-sidenav-container, mat-sidenav-content, mat-sidenav {
height: 100%;
}
mat-sidenav {
width: 250px;
}
main {
padding: 10px;
}
\ No newline at end of file
......@@ -19,11 +19,13 @@ import { AddPrefixComponent } from './components/add-prefix/add-prefix.component
import { PrefixDetailsComponent } from './components/prefix-details/prefix-details.component';
import { PrefixListComponent } from './components/prefix-list/prefix-list.component';
import { NotifierModule } from "angular-notifier";
import { NavigationBarComponent } from './components/navigation-bar/navigation-bar.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MaterialModule} from './mat-module';
import { NavComponent } from './components/nav/nav.component';
import {MaterialModule} from './mat-module';
import { FlexLayoutModule } from '@angular/flex-layout';
import { HeaderComponent } from './navigation/header/header.component';
import { SidenavListComponent } from './navigation/sidenav-list/sidenav-list.component';
......@@ -38,8 +40,8 @@ import { NavComponent } from './components/nav/nav.component';
AddPrefixComponent,
PrefixDetailsComponent,
PrefixListComponent,
NavigationBarComponent,
NavComponent,
HeaderComponent,
SidenavListComponent,
],
imports: [
BrowserModule,
......@@ -50,6 +52,7 @@ import { NavComponent } from './components/nav/nav.component';
NotifierModule,
BrowserAnimationsModule,
MaterialModule,
FlexLayoutModule,
],
providers: [
AuthService,
......
<app-navigation-bar></app-navigation-bar>
<mat-sidenav-container autosize>
<mat-sidenav #navigationSidenav mode="over" role="navigation">
<mat-toolbar>
<mat-toolbar-row>
<h2 class="toolbar-title"> APP </h2>
</mat-toolbar-row>
</mat-toolbar>
<!-- <mat-nav-list dense> -->
<mat-nav-list>
<h2 matSubheader> WORK </h2>
<a mat-list-item routerLink="/" style="height: 0;"></a>
<!-- <mat-divider></mat-divider> -->
<h2 matSubheader> CUSTOMER </h2>
<!--
<ng-container *ngIf="salesRoutes">
<h2 matSubheader> {{ 'SALES_SUB_HEADER' | translate }} </h2>
<a *ngFor="let item of salesRoutes"
mat-list-item
(click)="navigationSidenav.close()"
[routerLink]="[item.route]"
routerLinkActive="list-item-active">
<mat-icon matListIcon class="nav-list-icon"> {{ item.icon }} </mat-icon>
{{item.title}}
</a>
</ng-container>
<ng-container *ngIf="collateralRoutes">
<h2 matSubheader> {{ 'COLLATERAL_SUB_HEADER' | translate }} </h2>
<a *ngFor="let item of collateralRoutes"
mat-list-item
(click)="navigationSidenav.close()"
[routerLink]="[item.route]"
routerLinkActive="list-item-active">
<mat-icon matListIcon class="nav-list-icon"> {{ item.icon }} </mat-icon>
{{item.title}}
</a>
</ng-container>
-->
<h2 matSubheader> SALES</h2>
<h2 matSubheader> COL </h2>
<h2 matSubheader> MARKETING</h2>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav #commandbarSidenav position="end" mode="side" class="crm-command-bar-sidenav">
<mat-list style="padding: 10px;">
</mat-list>
</mat-sidenav>
<mat-sidenav-content role="main">
<!--
<crm-navigation-bar *ngIf="isAuthenticated()" (toggleSidenav)="navigationSidenav.toggle()">
</crm-navigation-bar>
-->
<router-outlet></router-outlet>
</mat-sidenav-content>
</mat-sidenav-container>
@mixin crm-nav-theme($theme) {
$nav-list-icon-padding: 12px !default;
$toolbar-title-padding: 16px !default;
.list-item-active {
font-weight: bold;
color: mat-color(map-get($theme, accent), darker) !important;
background: rgba(0, 0, 0, 0.04);
}
.nav-list-icon {
margin: 0 $nav-list-icon-padding 0 $nav-list-icon-padding;
}
.toolbar-title {
margin: 0 $toolbar-title-padding 0 $toolbar-title-padding;
}
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NavComponent } from './nav.component';
describe('NavComponent', () => {
let component: NavComponent;
let fixture: ComponentFixture<NavComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ NavComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(NavComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { AuthService } from './../../services/auth.service';
@Component({
selector: 'app-nav',
templateUrl: './nav.component.html',
styleUrls: ['./nav.component.scss']
})
export class NavComponent implements OnInit {
constructor(private authService: AuthService,) { }
ngOnInit(): void {
}
public isAuthenticated() {
this.authService.isLoggedIn();
}
}
<mat-toolbar color="primary" class="app-navigation-bar">
<mat-toolbar-row>
<span class="toolbar-title"> {{ 'APP_TOOLBAR_TITLE'}} </span>
<div fxFlex fxLayout fxLayoutAlign="flex-end">
<ul fxLayout fxLayoutGap="20px" class="navigation-items">
<li fxHide.xs>
<button mat-icon-button>
<mat-icon> settings </mat-icon>
</button>
</li>
<li fxHide.xs>
<button mat-icon-button>
<mat-icon> help_outline </mat-icon>
</button>
</li>
<li>
<button mat-icon-button [matMenuTriggerFor]="auth">
<mat-icon> person </mat-icon>
</button>
<mat-menu #auth="matMenu">
<mat-divider></mat-divider>
<button mat-menu-item (click)="logout()">
<mat-icon> exit_to_app </mat-icon>
<span> {{ 'SIGN_OUT_NAVIGATION_BAR_BUTTON' }} </span>
</button>
</mat-menu>
</li>
</ul>
</div>
</mat-toolbar-row>
</mat-toolbar>
<div fxFlex fxLayout fxLayoutAlign="flex-end" fxHide.xs>
<div fxFlex fxLayout fxLayoutAlign="flex-end" fxHide.xs>
<mat-icon class="toolbar-icon">settings</mat-icon>
<mat-icon class="toolbar-icon">help_outline</mat-icon>
<button mat-icon-button [matMenuTriggerFor]="auth">
<mat-icon>person_outline</mat-icon>
</button>
<mat-menu #auth="matMenu">
<button mat-menu-item>
<mat-icon>exit_to_app</mat-icon>
<span>Sign out</span>
</button>
</mat-menu>
</div>
<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item>
<mat-icon>dialpad</mat-icon>
<span>Redial</span>
</button>
<button mat-menu-item disabled>
<mat-icon>voicemail</mat-icon>
<span>Check voicemail</span>
</button>
<button mat-menu-item>
<mat-icon>notifications_off</mat-icon>
<span>Disable alerts</span>
</button>
</mat-menu>
<div fxFlex fxLayout fxLayoutAlign="flex-end" fxHide.xs>
<ul fxLayout fxLayoutGap="20px" class="navigation-items">
<li>
<a>
<mat-icon class="toolbar-icon">settings</mat-icon>
</a>
</li>
<li>
<a >
<mat-icon class="toolbar-icon">help_outline</mat-icon>
</a>
</li>
<li>
<a>
<mat-icon class="toolbar-icon">person_outline</mat-icon>
</a>
</li>
</ul>
</div>
\ No newline at end of file
$toolbar-title-padding: 16px !default;
.toolbar-title {
margin: 0 $toolbar-title-padding 0 $toolbar-title-padding;
}
.navigation-items {
list-style: none;
padding: 0;
margin: 0;
cursor: pointer;
}
.app-navigation-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 998;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NavigationBarComponent } from './navigation-bar.component';
describe('NavigationBarComponent', () => {
let component: NavigationBarComponent;
let fixture: ComponentFixture<NavigationBarComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ NavigationBarComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(NavigationBarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, EventEmitter, Output } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { AuthService } from './../../services/auth.service';
@Component({
selector: 'app-navigation-bar',
templateUrl: './navigation-bar.component.html',
styleUrls: ['./navigation-bar.component.scss']
})
export class NavigationBarComponent {
@Output() toggleSidenav = new EventEmitter<void>();
private returnUrl = '/';
constructor(private authService: AuthService,
private router: Router) {
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.returnUrl = event.url;
}
});
}
public onProfile() {
this.router.navigate(['users/profile']);
}
public logout() {
this.authService.logout();
}
}
<mat-toolbar color="primary">
<div fxHide.gt-xs>
<button mat-icon-button (click)="onToggleSidenav()">
<mat-icon>menu</mat-icon>
</button>
</div>
<div>
<a routerLink="/boilerplates">Boilerplates</a>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<li>
<a routerLink="/add-boilerplate">Add Boilepate</a>
</li>
<li>
<a routerLink="/account">Account Actions</a>
</li>
</ul>
</div>
</mat-toolbar>
\ No newline at end of file
a {
text-decoration: none;
color: white;
}
a:hover, a:active{
color: lightgray;
}
.navigation-items{
list-style-type: none;
padding: 0;
margin: 0;
}
mat-toolbar{
border-radius: 3px;
}
@media(max-width: 959px){
mat-toolbar{
border-radius: 0px;
}
}
\ No newline at end of file
import { Component, OnInit, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
@Output() public sidenavToggle = new EventEmitter();
constructor() { }
ngOnInit(): void {
}
public onToggleSidenav = () => {
this.sidenavToggle.emit();
}
}
<mat-nav-list>
<a mat-list-item routerLink="#" (click)="onSidenavClose()">
<mat-icon>home</mat-icon> <span class="nav-caption">Home</span>
</a>
<a mat-list-item routerLink="#" (click)="onSidenavClose()">
<mat-icon>assignment_ind</mat-icon> <span class="nav-caption">Owner Actions</span>
</a>
<a mat-list-item routerLink="#" (click)="onSidenavClose()">
<mat-icon>account_balance</mat-icon><span class="nav-caption">Account Actions</span>
</a>
<mat-list-item [matMenuTriggerFor]="menu">
<mat-icon>unfold_more</mat-icon>
<a matline>Example</a>
</mat-list-item>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="onSidenavClose()">View profile</button>
<button mat-menu-item (click)="onSidenavClose()">Add contact</button>
</mat-menu>
</mat-nav-list>
\ No newline at end of file
a{
text-decoration: none;
color: white;
}
a:hover, a:active{
color: lightgray;
}
.nav-caption{
display: inline-block;
padding-left: 6px;
}
\ No newline at end of file
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-sidenav-list',
templateUrl: './sidenav-list.component.html',
styleUrls: ['./sidenav-list.component.scss']
})
export class SidenavListComponent implements OnInit {
@Output() sidenavClose = new EventEmitter();
constructor() { }
ngOnInit() {
}
public onSidenavClose = () => {
this.sidenavClose.emit();
}
}
......@@ -7,5 +7,8 @@
/* Import angular-notifier. */
@import '~angular-notifier/styles';
html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
/* for sidenav to take a whole page */
html, body {
margin: 0;
height: 100%;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment