]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - 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
1 import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core'
2 import { GlobalIconName } from '@app/shared/shared-icons'
3
4 @Component({
5 selector: 'my-button',
6 styleUrls: [ './button.component.scss' ],
7 templateUrl: './button.component.html',
8 changeDetection: ChangeDetectionStrategy.OnPush
9 })
10
11 export class ButtonComponent implements OnInit, OnChanges {
12 @Input() label = ''
13 @Input() className = 'grey-button'
14 @Input() icon: GlobalIconName = undefined
15 @Input() routerLink: string[] | string
16 @Input() title: string = undefined
17 @Input() loading = false
18 @Input() disabled = false
19 @Input() responsiveLabel = false
20
21 classes: { [id: string]: boolean } = {}
22
23 ngOnInit () {
24 this.buildClasses()
25 }
26
27 ngOnChanges () {
28 this.buildClasses()
29 }
30
31 private buildClasses () {
32 this.classes = {
33 [this.className]: true,
34 'disabled': this.disabled,
35 'icon-only': !this.label,
36 'has-icon': !!this.icon,
37 'responsive-label': this.responsiveLabel
38 }
39 }
40 }