|
@@ -1,9 +1,20 @@
|
|
|
-import { NgClass } from '@angular/common';
|
|
|
+import { DOCUMENT, NgClass } from '@angular/common';
|
|
|
import * as i0 from '@angular/core';
|
|
|
-import { Component, ChangeDetectionStrategy, Input } from '@angular/core';
|
|
|
+import { Component, ChangeDetectionStrategy, Inject, Input } from '@angular/core';
|
|
|
+
|
|
|
+const icons = `
|
|
|
+<svg xmlns="http://www.w3.org/2000/svg" style="display:none">
|
|
|
+ <symbol id="arrow-down" viewBox="0 0 24 24">
|
|
|
+ <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5L12 21m0 0l-7.5-7.5M12 21V3" />
|
|
|
+ </symbol>
|
|
|
+</svg>
|
|
|
+`;
|
|
|
|
|
|
class IconComponent {
|
|
|
- constructor() {
|
|
|
+ constructor(renderer, document, el) {
|
|
|
+ this.renderer = renderer;
|
|
|
+ this.document = document;
|
|
|
+ this.el = el;
|
|
|
this.icon = '';
|
|
|
this.iconClass = '';
|
|
|
this.fill = 'currentColor';
|
|
@@ -13,7 +24,7 @@ class IconComponent {
|
|
|
this.iconPath = '';
|
|
|
}
|
|
|
ngOnInit() {
|
|
|
- this.iconPath = '';
|
|
|
+ this.injectSVG();
|
|
|
this.strokeColor = this.getFormattedColor(this.strokeColor);
|
|
|
this.fill = this.getFormattedColor(this.fill);
|
|
|
}
|
|
@@ -24,13 +35,25 @@ class IconComponent {
|
|
|
}
|
|
|
return color;
|
|
|
}
|
|
|
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: IconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
|
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.0", type: IconComponent, isStandalone: true, selector: "ct-icon", inputs: { icon: "icon", iconClass: "iconClass", fill: "fill", strokeWidth: "strokeWidth", strokeColor: "strokeColor", size: "size" }, ngImport: i0, template: "<svg\n [ngClass]=\"iconClass\"\n [attr.fill]=\"fill\"\n [attr.stroke-width]=\"strokeWidth\"\n [attr.stroke]=\"strokeColor\"\n class=\"flex size-full\">\n <use [attr.xlink:href]=\"iconPath\"></use>\n</svg>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
|
+ getIconPath() {
|
|
|
+ return `#${this.icon}`;
|
|
|
+ }
|
|
|
+ injectSVG() {
|
|
|
+ const svgElement = this.renderer.createElement('div');
|
|
|
+ this.renderer.setProperty(svgElement, 'innerHTML', icons);
|
|
|
+ this.renderer.setStyle(svgElement, 'display', 'none');
|
|
|
+ this.renderer.appendChild(this.document.body, svgElement);
|
|
|
+ }
|
|
|
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: IconComponent, deps: [{ token: i0.Renderer2 }, { token: DOCUMENT }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
|
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.0", type: IconComponent, isStandalone: true, selector: "ct-icon", inputs: { icon: "icon", iconClass: "iconClass", fill: "fill", strokeWidth: "strokeWidth", strokeColor: "strokeColor", size: "size" }, ngImport: i0, template: "<svg\n [ngClass]=\"iconClass\"\n [attr.fill]=\"fill\"\n [attr.stroke-width]=\"strokeWidth\"\n [attr.stroke]=\"strokeColor\"\n class=\"flex size-full\">\n <use [attr.xlink:href]=\"getIconPath()\"></use>\n</svg>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
|
}
|
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: IconComponent, decorators: [{
|
|
|
type: Component,
|
|
|
- args: [{ selector: 'ct-icon', standalone: true, imports: [NgClass], changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg\n [ngClass]=\"iconClass\"\n [attr.fill]=\"fill\"\n [attr.stroke-width]=\"strokeWidth\"\n [attr.stroke]=\"strokeColor\"\n class=\"flex size-full\">\n <use [attr.xlink:href]=\"iconPath\"></use>\n</svg>\n" }]
|
|
|
- }], propDecorators: { icon: [{
|
|
|
+ args: [{ selector: 'ct-icon', standalone: true, imports: [NgClass], changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg\n [ngClass]=\"iconClass\"\n [attr.fill]=\"fill\"\n [attr.stroke-width]=\"strokeWidth\"\n [attr.stroke]=\"strokeColor\"\n class=\"flex size-full\">\n <use [attr.xlink:href]=\"getIconPath()\"></use>\n</svg>\n" }]
|
|
|
+ }], ctorParameters: () => [{ type: i0.Renderer2 }, { type: Document, decorators: [{
|
|
|
+ type: Inject,
|
|
|
+ args: [DOCUMENT]
|
|
|
+ }] }, { type: i0.ElementRef }], propDecorators: { icon: [{
|
|
|
type: Input
|
|
|
}], iconClass: [{
|
|
|
type: Input
|