-
Notifications
You must be signed in to change notification settings - Fork 357
/
Copy pathpink.toast.ts
106 lines (103 loc) · 2.67 KB
/
pink.toast.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import {
animate,
keyframes,
state,
style,
transition,
trigger
} from '@angular/animations';
import { Component } from '@angular/core';
import { Toast, ToastrService, ToastPackage } from '../lib/public_api';
@Component({
selector: '[pink-toast-component]',
styles: [`
:host {
background-color: #FF69B4;
position: relative;
overflow: hidden;
margin: 0 0 6px;
padding: 10px 10px 10px 10px;
width: 300px;
border-radius: 3px 3px 3px 3px;
color: #FFFFFF;
pointer-events: all;
cursor: pointer;
}
.btn-pink {
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0);
}
`],
template: `
<div class="row" [style.display]="state().value === 'inactive' ? 'none' : ''">
<div class="col-9">
<div *ngIf="title" [class]="options.titleClass" [attr.aria-label]="title">
{{ title }}
</div>
<div *ngIf="message && options.enableHtml" role="alert"
[class]="options.messageClass" [innerHTML]="message">
</div>
<div *ngIf="message && !options.enableHtml" role="alert"
[class]="options.messageClass" [attr.aria-label]="message">
{{ message }}
</div>
</div>
<div class="col-3 text-right">
<a *ngIf="!options.closeButton" class="btn btn-pink btn-sm" (click)="action($event)">
{{ undoString }}
</a>
<a *ngIf="options.closeButton" (click)="remove()" class="btn btn-pink btn-sm">
close
</a>
</div>
</div>
<div *ngIf="options.progressBar">
<div class="toast-progress" [style.width]="width() + '%'"></div>
</div>
`,
animations: [
trigger('flyInOut', [
state('inactive', style({
opacity: 0,
})),
transition('inactive => active', animate('400ms ease-out', keyframes([
style({
transform: 'translate3d(100%, 0, 0) skewX(-30deg)',
opacity: 0,
}),
style({
transform: 'skewX(20deg)',
opacity: 1,
}),
style({
transform: 'skewX(-5deg)',
opacity: 1,
}),
style({
transform: 'none',
opacity: 1,
}),
]))),
transition('active => removed', animate('400ms ease-out', keyframes([
style({
opacity: 1,
}),
style({
transform: 'translate3d(100%, 0, 0) skewX(30deg)',
opacity: 0,
}),
]))),
]),
],
preserveWhitespaces: false,
})
export class PinkToast extends Toast {
// used for demo purposes
undoString = 'undo';
action(event: Event) {
event.stopPropagation();
this.undoString = 'undid';
this.toastPackage.triggerAction();
return false;
}
}