+21
-15
packages/lucide-angular/src/lib/lucide-angular.component.ts
+21
-15
packages/lucide-angular/src/lib/lucide-angular.component.ts
···
27
27
size?: TypedChange<number>;
28
28
strokeWidth?: TypedChange<number>;
29
29
absoluteStrokeWidth?: TypedChange<boolean>;
30
+
class: TypedChange<string>;
30
31
};
31
32
32
33
export function formatFixed(number: number, decimals = 3): string {
···
40
41
export class LucideAngularComponent implements OnChanges {
41
42
@Input() class?: string;
42
43
@Input() name?: string | LucideIconData;
44
+
@Input() img?: LucideIconData;
43
45
@Input() color?: string;
44
46
@Input() absoluteStrokeWidth = false;
45
47
defaultSize: number;
···
54
56
this.defaultSize = defaultAttributes.height;
55
57
}
56
58
57
-
@Input() set img(img: LucideIconData) {
58
-
this.name = img;
59
-
}
60
-
61
59
_size?: number;
62
60
63
61
get size(): number {
···
87
85
}
88
86
89
87
ngOnChanges(changes: LucideAngularComponentChanges): void {
90
-
this.color = this.color ?? this.iconConfig.color;
91
-
this.size = this.parseNumber(this.size ?? this.iconConfig.size);
92
-
this.strokeWidth = this.parseNumber(this.strokeWidth ?? this.iconConfig.strokeWidth);
93
-
this.absoluteStrokeWidth = this.absoluteStrokeWidth ?? this.iconConfig.absoluteStrokeWidth;
94
-
if (changes.name || changes.img) {
95
-
const name = changes.img?.currentValue ?? changes.name?.currentValue;
96
-
if (typeof name === 'string') {
97
-
const icoOfName = this.getIcon(this.toPascalCase(name));
88
+
if (
89
+
changes.name ||
90
+
changes.img ||
91
+
changes.color ||
92
+
changes.size ||
93
+
changes.absoluteStrokeWidth ||
94
+
changes.strokeWidth ||
95
+
changes.class
96
+
) {
97
+
this.color = this.color ?? this.iconConfig.color;
98
+
this.size = this.parseNumber(this.size ?? this.iconConfig.size);
99
+
this.strokeWidth = this.parseNumber(this.strokeWidth ?? this.iconConfig.strokeWidth);
100
+
this.absoluteStrokeWidth = this.absoluteStrokeWidth ?? this.iconConfig.absoluteStrokeWidth;
101
+
const nameOrIcon = this.img ?? this.name;
102
+
if (typeof nameOrIcon === 'string') {
103
+
const icoOfName = this.getIcon(this.toPascalCase(nameOrIcon));
98
104
if (icoOfName) {
99
105
this.replaceElement(icoOfName);
100
106
} else {
101
107
throw new Error(
102
-
`The "${name}" icon has not been provided by any available icon providers.`,
108
+
`The "${nameOrIcon}" icon has not been provided by any available icon providers.`,
103
109
);
104
110
}
105
-
} else if (Array.isArray(name)) {
106
-
this.replaceElement(name);
111
+
} else if (Array.isArray(nameOrIcon)) {
112
+
this.replaceElement(nameOrIcon);
107
113
} else {
108
114
throw new Error(`No icon name or image has been provided.`);
109
115
}