aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/loaders/loader.component.ts
blob: bd038f8b5514fd4368ab2af10b981ac7b46985c7 (plain) (blame)
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
import { Component, Input } from '@angular/core'

@Component({
  selector: 'my-loader',
  template: `<div *ngIf="loading" class="spinner-border" [ngStyle]="getStyle()" role="status"></div>`
})
export class LoaderComponent {
  @Input() loading: boolean
  @Input() size: 'sm' | 'xl'

  private readonly sizes = {
    sm: {
      width: '1rem',
      height: '1rem',
      'border-width': '0.15rem'
    },
    xl: {
      width: '3rem',
      height: '3rem'
    }
  }

  getStyle () {
    if (!this.size) return undefined

    return this.sizes[this.size]
  }
}