Skip to content

Commit 9df055d

Browse files
committed
Moved Logo & Buttons from App Component to Header Component
added Inline CSS styles for Header View
1 parent c66551c commit 9df055d

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

src/app/app.component.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
<div class="navbar-header">
2-
<a class="navbar-brand" href="#">Auth0 - Angular 2</a>
3-
<button class="btn btn-primary btn-margin" (click)="auth.login()" *ngIf="!auth.authenticated()">Log In</button>
4-
<button class="btn btn-primary btn-margin" (click)="auth.logout()" *ngIf="auth.authenticated()">Log Out</button>
5-
</div>
1+
<app-header></app-header>
62
<router-outlet></router-outlet>

src/app/app.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Component } from '@angular/core';
2-
import { Auth } from './auth/auth.service';
32

43
@Component({
54
selector: 'app-root',
65
templateUrl: './app.component.html',
76
styleUrls: ['./app.component.css']
87
})
98
export class AppComponent {
10-
constructor(private auth: Auth) {}
9+
1110
}
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
<p>
2-
header works!
3-
</p>
1+
<header>
2+
<a class="logo" href="#" routerLink="/" >Auth0 + Angular 2</a>
3+
<button class="login-btn" (click)="auth.login()" *ngIf="!auth.authenticated()">Log In</button>
4+
5+
<ul class="user-menu" *ngIf="auth.authenticated()">
6+
<li><a href="#" routerLink="/dashboard">Dashboard</a></li>
7+
<li><a href="#" routerLink="/user-profile">My Profile</a></li>
8+
<button class="logout-btn" (click)="auth.logout()">Log Out</button>
9+
</ul>
10+
</header>

src/app/shared/header/header.component.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { Auth } from '../../auth/auth.service';
23

34
@Component({
45
selector: 'app-header',
56
templateUrl: './header.component.html',
6-
styles: []
7+
styles: [
8+
`header {
9+
background: #eee;
10+
width: 100%;
11+
padding: 20px 0;
12+
}
13+
.logo {
14+
margin: 0 20px;
15+
font-size: 18px;
16+
font-weight: bold;
17+
text-decoration: none;
18+
}
19+
.login-btn,
20+
.logout-btn {
21+
float: right;
22+
margin: 0 20px;
23+
}
24+
.user-menu {
25+
float: right;
26+
margin: 0;
27+
}
28+
.user-menu > li {
29+
display: inline-block;
30+
}`
31+
]
732
})
833
export class HeaderComponent implements OnInit {
934

10-
constructor() { }
35+
constructor(private auth: Auth) {}
1136

1237
ngOnInit() {
1338
}

0 commit comments

Comments
 (0)