blob: 2e464243247c7a8ccf7f623769a9e3a9af90cb88 [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {
2 AfterViewChecked,
3 Component,
4 ElementRef,
5 EventEmitter,
6 Input,
7 Output
8} from "@angular/core";
9import * as _ from 'lodash';
10
11@Component({
12 selector : 'vid-svg-icon',
13 template: `
14 <svg-icon
15 [mode]="mode"
16 [size]="size"
17 [name]="name"
18 [testId]="testId"
19 [clickable]="clickable">
20 </svg-icon>
21 `,
22
23
24})
25export 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}