]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-main/buttons/button.component.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / buttons / button.component.ts
CommitLineData
a6f214d4 1import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core'
67ed6552 2import { GlobalIconName } from '@app/shared/shared-icons'
74d63469
GR
3
4@Component({
5 selector: 'my-button',
faf7eab7 6 styleUrls: [ './button.component.scss' ],
34ba86a8
C
7 templateUrl: './button.component.html',
8 changeDetection: ChangeDetectionStrategy.OnPush
74d63469
GR
9})
10
a6f214d4 11export class ButtonComponent implements OnInit, OnChanges {
74d63469 12 @Input() label = ''
b345a804 13 @Input() className = 'grey-button'
457bb213 14 @Input() icon: GlobalIconName = undefined
db66f391 15 @Input() routerLink: string[] | string
c199c427 16 @Input() title: string = undefined
b5f919ac 17 @Input() loading = false
1fe1e14c 18 @Input() disabled = false
faf7eab7 19 @Input() responsiveLabel = false
74d63469 20
5b0ec7cd
C
21 classes: { [id: string]: boolean } = {}
22
a6f214d4
C
23 ngOnInit () {
24 this.buildClasses()
25 }
26
5b0ec7cd 27 ngOnChanges () {
a6f214d4
C
28 this.buildClasses()
29 }
30
31 private buildClasses () {
5b0ec7cd 32 this.classes = {
1fe1e14c 33 [this.className]: true,
d0fbc9fd 34 'disabled': this.disabled,
db129781 35 'icon-only': !this.label,
db66f391 36 'has-icon': !!this.icon,
faf7eab7 37 'responsive-label': this.responsiveLabel
1fe1e14c
RK
38 }
39 }
74d63469 40}