-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprogress.ts
44 lines (35 loc) · 824 Bytes
/
progress.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
import { Component, Input } from '@angular/core';
@Component({
selector: "lsu-progress",
template: `
<div class="ui {{ color }} {{ size }} progress">
<div class="bar" style="transition-duration: 300ms;" [style.width]="getPercent()">
<div class="progress">{{ text || getPercent() }}</div>
</div>
<div class="label" *ngIf="label">{{ label }}</div>
</div>
`
})
export class ProgressComponent {
@Input()
public text: string;
@Input()
public label: string;
@Input()
public percent: number;
@Input()
public color: string;
@Input()
public size: string;
constructor() {
}
getPercent(): string {
if (this.percent < 0) {
return '0%';
} else if (this.percent > 100) {
return "100%";
} else {
return this.percent + '%';
}
}
}