WIP
This commit is contained in:
@@ -1 +1 @@
|
||||
<span [innerHtml]="iconHtml" class="g-font-size-20 g-line-height-0 mx-2"></span>
|
||||
<span [innerHtml]="iconHtml" class="{{sizeClass}} mx-2"></span>
|
||||
@@ -15,19 +15,27 @@ export class MD2IconComponent implements OnInit {
|
||||
private _icon: string | MD2Icon;
|
||||
|
||||
@Input() public set icon(v: string | MD2Icon) {
|
||||
if (this._icon != v) {
|
||||
this._icon = v;
|
||||
//if it's string, convert it to MD2Icon
|
||||
if (typeof v === 'string') {
|
||||
v = MD2Icon[v];
|
||||
if (v !== undefined) {
|
||||
if (this._icon != v) {
|
||||
this._icon = v;
|
||||
//if it's string, convert it to MD2Icon
|
||||
if (typeof v === 'string') {
|
||||
const key = Object.keys(MD2Icon).find(
|
||||
k => k.toLowerCase() === v.toString().toLowerCase()
|
||||
);
|
||||
if (key) {
|
||||
v = MD2Icon[key as keyof typeof MD2Icon];
|
||||
}
|
||||
}
|
||||
this.iconHtml = this.md2StateService.iconHtml(v as MD2Icon);
|
||||
}
|
||||
if (this.isMD2Icon(v)) {
|
||||
this.iconName = MD2Icon[v].toLowerCase();
|
||||
} else {
|
||||
this.iconName = v;
|
||||
}
|
||||
this.iconHtml = this.md2StateService.iconHtml(v as MD2Icon);
|
||||
}
|
||||
if (this.isMD2Icon(v)) {
|
||||
this.iconName = MD2Icon[v].toLowerCase();
|
||||
} else {
|
||||
this.iconName = v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
isMD2Icon(icon: MD2Icon | string): icon is MD2Icon {
|
||||
|
||||
Reference in New Issue
Block a user