Move onap UI loader and icons to VID
[vid.git] / vid-webpack-master / src / app / shared / components / svg / svg-component.ts
1 import {
2   AfterViewChecked,
3   Component,
4   ElementRef,
5   EventEmitter,
6   Input,
7   Output
8 } from "@angular/core";
9 import * as _ from 'lodash';
10
11 @Component({
12   selector : 'vid-svg-icon',
13   template: `
14       <custom-icon
15         [mode]="mode"
16         [size]="size"
17         [name]="name"
18         [testId]="testId"
19         [clickable]="clickable">
20     </custom-icon>
21   `,
22
23
24 })
25 export class SvgComponent implements AfterViewChecked{
26   @Input() mode : string = 'primary';
27   @Input() size : string = 'large';
28   @Input() testId : string = null;
29   @Input() name : string = null;
30   @Input() clickable : boolean = false;
31   @Input() fill : string ;
32   @Input() widthViewBox: string = null;
33   @Input() heightViewBox: string = null;
34
35   constructor(private elRef: ElementRef) {}
36
37   ngAfterViewChecked(): void {
38     if(!_.isNil(this.fill)){
39       this.elRef.nativeElement.children[0].children[0].children[0].style.fill = this.fill;
40     }
41
42     if(this.widthViewBox && this.heightViewBox){
43       this.elRef.nativeElement.children[0].children[0].children[0].setAttribute('viewBox', "1 1 " + this.widthViewBox + " " + this.heightViewBox)
44     }
45
46   }
47 }