import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
import { UiIconSize } from '@ui/icon/icon-size.enum';
import { UiIconType } from '@ui/icon/icon-type.enum';

const CUSTOM_ICONS: UiIconType[] = [
  UiIconType.HOME,
  UiIconType.SETTINGS,
  UiIconType.PLUS,
  UiIconType.CLIPBOARD,
  UiIconType.BUILDING,
  UiIconType.LOGOUT,
  UiIconType.BANKID,
];

@Component({
  selector: 'ui-icon',
  templateUrl: './icon.component.html',
  styleUrls: ['./icon.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconComponent implements OnChanges {
  @Input() uiType: UiIconType;
  @Input() uiSize: UiIconSize = UiIconSize.M;

  iconClass: string;
  iconType = UiIconType;

  ngOnChanges(): void {
    this.iconClass = `icon--${this.uiSize}`;
  }

  get isCustomIcon(): boolean {
    return CUSTOM_ICONS.includes(this.uiType);
  }
}
