import { Component, Input, OnInit } from '@angular/core';
import { MD2Icon } from '../massive-darkness2.model';

@Component({
  selector: 'md2-icon',
  templateUrl: './md2-icon.component.html',
  styleUrls: ['./md2-icon.component.scss']
})
export class MD2IconComponent implements OnInit {

  @Input() iconClass: string = 'mr-1';


  private _icon: string | MD2Icon;

  @Input() public set icon(v: string | MD2Icon) {
    if (this._icon != v) {
      this._icon = v;

    }
    if (this.isMD2Icon(v)) {
      this.iconName = MD2Icon[v].toLowerCase();
    } else {
      this.iconName = v;
    }
  }

  isMD2Icon(icon: MD2Icon | string): icon is MD2Icon {
    return Number.isInteger(icon);
  }
  @Input() size: string = 'sm';
  iconName: string;
  constructor() { }

  ngOnInit(): void {
  }

  public get sizeClass(): string {
    switch (this.size) {
      case 'sm':
        return 'g-font-size-18'
        break;
      case 'med':
        return 'g-font-size-30'
        break;
      case 'lg':
        return 'g-font-size-50'
        break;

      default:
        return 'g-font-size-' + this.size;
        break;
    }
  }

}
