import { Component, ChangeDetectionStrategy, Input, HostBinding } from '@angular/core';

interface IUiLoader {
  loading: boolean;
  spinnerSize: string;
}

@Component({
  selector: '[uiLoader]:not(button)',
  templateUrl: 'loader.component.html',
  styleUrls: ['loader.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class UiLoaderComponent implements IUiLoader {
  @Input('uiLoader')
  loading: boolean = false;

  @Input('spinnerSize')
  spinnerSize: string = '36px';

  constructor() {}
}

@Component({
  selector: 'button[uiLoader]',
  templateUrl: 'loader.component.html',
  styleUrls: ['loader.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class UiButtonLoaderComponent implements IUiLoader {
  @Input('uiLoader')
  @HostBinding('disabled')
  loading: boolean = false;

  @Input('spinnerSize')
  spinnerSize: string = '1em';

  constructor() {}
}
