-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the service and getting ready to animate the notifications
- Loading branch information
Showing
28 changed files
with
506 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
<span>Content</span> | ||
</div> | ||
|
||
<notifications></notifications> | ||
<notification-panel></notification-panel> | ||
|
||
</div> |
16 changes: 14 additions & 2 deletions
16
angular2-animated-notifications-panel/app/app.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import { Component, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; | ||
|
||
import {NotificationsComponent} from "./notifications/index"; | ||
import {NotificationService} from "./shared/index"; | ||
import {NotificationPanelComponent} from "./notification-panel/index"; | ||
|
||
@Component({ | ||
selector: 'my-app', | ||
moduleId: module.id, | ||
directives: [NotificationsComponent], | ||
directives: [NotificationPanelComponent], | ||
templateUrl: "app.component.html", | ||
styleUrls: ['app.component.css'] | ||
}) | ||
export class AppComponent { | ||
|
||
constructor( | ||
private notificationService: NotificationService | ||
) { | ||
|
||
// this.notificationService.startRandomGeneration(); | ||
for(let i = 0; i < 10; i++) { | ||
let n = this.notificationService.createRandomNotification(); | ||
this.notificationService.addNotification(n); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import { bootstrap } from '@angular/platform-browser-dynamic'; | ||
|
||
import {NotificationService} from "./shared/index"; | ||
import {AppComponent} from './app.component'; | ||
|
||
|
||
bootstrap(AppComponent, []); | ||
bootstrap(AppComponent, [ | ||
NotificationService | ||
]); |
5 changes: 5 additions & 0 deletions
5
angular2-animated-notifications-panel/app/notification-panel/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
__export(require("./notification-panel.component")); |
1 change: 1 addition & 0 deletions
1
angular2-animated-notifications-panel/app/notification-panel/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./notification-panel.component"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
...otifications/notifications.component.html → ...n-panel/notification-panel.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
<div class="container" @panelWidthTrigger="expandedState"> | ||
<div class="title"> | ||
<div class="title" @titleColorTrigger="expandedState"> | ||
<span *ngIf="expanded" @titleTextTrigger="'in'">Notifications</span> | ||
<a class="link" (click)="toggleExpandedState()"> | ||
<i @iconTrigger="expandedState" class="fa fa-arrow-circle-left" aria-hidden="true"></i> | ||
</a> | ||
</div> | ||
|
||
<div class="notifications"> | ||
<notification *ngFor="let n of notificationService.notifications$ | async" | ||
[notification]="n" | ||
[expanded]="expanded"></notification> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
angular2-animated-notifications-panel/app/notification-panel/notification-panel.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { | ||
Component, | ||
OnInit, | ||
trigger, | ||
state, | ||
style, | ||
transition, | ||
animate | ||
} from '@angular/core'; | ||
|
||
import {NotificationService} from "../shared/index"; | ||
import {NotificationComponent} from "../notification/index"; | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'notification-panel', | ||
directives: [NotificationComponent], | ||
templateUrl: 'notification-panel.component.html', | ||
styleUrls: ['notification-panel.component.css'], | ||
animations: [ | ||
trigger('panelWidthTrigger', [ | ||
state('expanded', style({ | ||
width: '300px' | ||
})), | ||
state('collapsed', style({ | ||
width: '38px' | ||
})), | ||
transition('collapsed => expanded', animate('200ms ease-in')), | ||
transition('expanded => collapsed', animate('200ms 200ms ease-out')) | ||
]), | ||
trigger('titleColorTrigger', [ | ||
state('collapsed', style({ | ||
backgroundColor: '#FFFFFF', | ||
color: '#E74C3C' | ||
})), | ||
state('expanded', style({ | ||
backgroundColor: '#E74C3C', | ||
color: '#FFFFFF' | ||
})), | ||
transition('collapsed => expanded', animate('200ms ease-in')), | ||
transition('expanded => collapsed', animate('200ms 200ms ease-out')) | ||
]), | ||
trigger('titleTextTrigger', [ | ||
state('in', style({ opacity: '1' })), | ||
transition('void => *', [ | ||
style({ opacity: '0' }), | ||
animate('100ms 300ms') | ||
]), | ||
transition('* => void', [ | ||
animate('50ms', style({ opacity: '0' })) | ||
]) | ||
]), | ||
trigger('iconTrigger', [ | ||
state('collapsed', style({ transform: 'rotate(0deg)' })), | ||
state('expanded', style({ transform: 'rotate(180deg)' })), | ||
transition('collapsed => expanded', animate('200ms ease-in')), | ||
transition('expanded => collapsed', animate('200ms ease-out')) | ||
]) | ||
] | ||
}) | ||
export class NotificationPanelComponent implements OnInit { | ||
expanded = false; | ||
expandedState = 'collapsed'; | ||
|
||
constructor( | ||
private notificationService: NotificationService | ||
) { } | ||
|
||
ngOnInit() { } | ||
|
||
toggleExpandedState() { | ||
this.expandedState = this.expanded ? 'collapsed' : 'expanded'; | ||
this.expanded = !this.expanded; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
angular2-animated-notifications-panel/app/notification/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./notification.component"; |
31 changes: 31 additions & 0 deletions
31
angular2-animated-notifications-panel/app/notification/notification.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
:host { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
min-height: 0; | ||
min-width: 0; | ||
padding: 8px; | ||
} | ||
|
||
.details { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
margin-left: 8px; | ||
} | ||
|
||
.icon { | ||
} | ||
|
||
.message { | ||
|
||
} | ||
|
||
.date { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
font-size: 0.8em; | ||
color: #444444; | ||
} |
14 changes: 14 additions & 0 deletions
14
angular2-animated-notifications-panel/app/notification/notification.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="icon" [ngSwitch]="notification.type"> | ||
<i *ngSwitchCase="0" class="fa fa-comment"></i> | ||
<i *ngSwitchCase="1" class="fa fa-exclamation-triangle"></i> | ||
<i *ngSwitchCase="2" class="fa fa-code"></i> | ||
<i *ngSwitchCase="3" class="fa fa-credit-card"></i> | ||
</div> | ||
<div *ngIf="expanded" class="details"> | ||
<div class="message"> | ||
<span>{{notification.message}}</span> | ||
</div> | ||
<div class="date"> | ||
<span>{{notification.date | date:'mediumTime'}}</span> | ||
</div> | ||
</div> |
42 changes: 42 additions & 0 deletions
42
angular2-animated-notifications-panel/app/notification/notification.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var core_1 = require('@angular/core'); | ||
var index_1 = require("../shared/index"); | ||
var NotificationComponent = (function () { | ||
function NotificationComponent() { | ||
this.remove = new core_1.EventEmitter(false); | ||
this.notificationTypes = index_1.NotificationType; | ||
} | ||
NotificationComponent.prototype.ngOnInit = function () { }; | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata('design:type', index_1.Notification) | ||
], NotificationComponent.prototype, "notification", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata('design:type', Boolean) | ||
], NotificationComponent.prototype, "expanded", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata('design:type', Object) | ||
], NotificationComponent.prototype, "remove", void 0); | ||
NotificationComponent = __decorate([ | ||
core_1.Component({ | ||
moduleId: module.id, | ||
selector: 'notification', | ||
templateUrl: 'notification.component.html', | ||
styleUrls: ['notification.component.css'] | ||
}), | ||
__metadata('design:paramtypes', []) | ||
], NotificationComponent); | ||
return NotificationComponent; | ||
}()); | ||
exports.NotificationComponent = NotificationComponent; |
Oops, something went wrong.