Add home & login component with routing

This commit is contained in:
2018-06-01 17:54:55 -04:00
parent 27e5615f8f
commit 174d1cb327
14 changed files with 170 additions and 30 deletions

View File

@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { LoginComponent } from './login/login.component';
import { PageNotFoundComponent } from './not-found.component';
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'login', component: LoginComponent },
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }

View File

@@ -4,7 +4,8 @@
}
nav {
margin-left: 26px;
margin-left: 25px;
width: 100% !important;
}
.nav_header {
@@ -15,6 +16,11 @@ nav {
.nav_header li {
float: left;
padding: .2em;
}
.nav_header li:last-child {
float: right;
}
li a {
@@ -26,12 +32,15 @@ li a {
li a:hover {
background: #424242;
/* color: #e91e63; */
}
.demo-tab-content {
color: white;
padding: 16px;
}
.container {
margin: 2em auto;
width: 70%;
}
}
.active {
background: #424242;
border-radius: 25%;
}

View File

@@ -5,7 +5,7 @@
<nav>
<ul class="nav_header">
<li>
<a href="#">Home</a>
<a routerLink="/home" routerLinkActive="active">Home</a>
</li>
<li>
<a href="#">Products</a>
@@ -14,29 +14,12 @@
<a href="#">Add Product</a>
</li>
<li>
<a href="#">LogIn</a>
<a routerLink="/login" routerLinkActive="active">LogIn</a>
</li>
</ul>
</nav>
</mat-toolbar-row>
</mat-toolbar>
<div class="container">
<mat-card>
<mat-tab-group>
<mat-tab label="About">
<div class="demo-tab-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</mat-tab>
<mat-tab label="Dashboard">
<div class="demo-tab-content">
Content 2
</div>
</mat-tab>
</mat-tab-group>
</mat-card>
<div class="container ">
<router-outlet></router-outlet>
</div>

View File

@@ -2,17 +2,25 @@ import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppMaterialModule } from './app-material.module';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { PageNotFoundComponent } from './not-found.component';
import { HomeComponent } from './home/home.component';
import { LoginComponent } from './login/login.component';
@NgModule({
declarations: [
AppComponent
AppComponent,
PageNotFoundComponent,
HomeComponent,
LoginComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppMaterialModule
AppMaterialModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]

View File

@@ -0,0 +1,4 @@
.demo-tab-content {
color: white;
padding: 16px;
}

View File

@@ -0,0 +1,18 @@
<mat-card>
<mat-tab-group>
<mat-tab label="About">
<div class="demo-tab-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and
more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</mat-tab>
<mat-tab label="Dashboard">
<div class="demo-tab-content">
Content 2
</div>
</mat-tab>
</mat-tab-group>
</mat-card>

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HomeComponent } from './home.component';
describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomeComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

View File

@@ -0,0 +1,4 @@
.demo-tab-content {
color: white;
padding: 16px;
}

View File

@@ -0,0 +1,3 @@
<p class="demo-tab-content">
login works!
</p>

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

View File

@@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
template: `
<div>
<h2>404 Page not found !!</h2>
</div>`,
styles: [`h2 {font-size: 32px; color: white; text-align: center;}`]
})
export class PageNotFoundComponent { }

View File

@@ -4,7 +4,8 @@
* {
margin: 0;
}
body {
background: #212121;
box-sizing: border-box;
}
}