import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { UiLoaderType } from './loader-type.enum';

@Component({
  selector: 'ui-loader',
  templateUrl: './loader.component.html',
  styleUrls: ['./loader.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LoaderComponent {
  private readonly _defaultClass = 'ui-loader';
  @Input() uiType: UiLoaderType = UiLoaderType.PADDED;
  @Input() uiSize: 's' | 'm' = 'm';
  @Input() uiShowLoadingText = false;
  @Input() uiLoadingText = 'Laddar innehåll';

  get loaderClass(): string {
    if (this.uiType) {
      return `${this._defaultClass} ${this._defaultClass}--${this.uiType as string}`;
    }
    return this._defaultClass;
  }

  get spinnerClass(): string {
    return `${this._defaultClass}__spinner ${this._defaultClass}__spinner--${this.uiSize}`;
  }
}
