circletone.mjs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { DOCUMENT, NgClass } from '@angular/common';
  2. import * as i0 from '@angular/core';
  3. import { Component, ChangeDetectionStrategy, Inject, Input } from '@angular/core';
  4. const icons = `
  5. <svg xmlns="http://www.w3.org/2000/svg" style="display:none">
  6. <symbol id="arrow-down" viewBox="0 0 24 24">
  7. <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5L12 21m0 0l-7.5-7.5M12 21V3" />
  8. </symbol>
  9. </svg>
  10. `;
  11. class IconComponent {
  12. constructor(renderer, document, el) {
  13. this.renderer = renderer;
  14. this.document = document;
  15. this.el = el;
  16. this.icon = '';
  17. this.iconClass = '';
  18. this.fill = 'currentColor';
  19. this.strokeWidth = 1.5;
  20. this.strokeColor = 'currentColor';
  21. this.size = '6';
  22. this.iconPath = '';
  23. }
  24. ngOnInit() {
  25. this.injectSVG();
  26. this.strokeColor = this.getFormattedColor(this.strokeColor);
  27. this.fill = this.getFormattedColor(this.fill);
  28. }
  29. getFormattedColor(color) {
  30. if (color.startsWith('--')) {
  31. const rgbValue = getComputedStyle(document.documentElement).getPropertyValue(color).trim();
  32. return `rgb(${rgbValue})`;
  33. }
  34. return color;
  35. }
  36. getIconPath() {
  37. return `#${this.icon}`;
  38. }
  39. injectSVG() {
  40. const svgElement = this.renderer.createElement('div');
  41. this.renderer.setProperty(svgElement, 'innerHTML', icons);
  42. this.renderer.setStyle(svgElement, 'display', 'none');
  43. this.renderer.appendChild(this.document.body, svgElement);
  44. }
  45. 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 }); }
  46. 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 }); }
  47. }
  48. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: IconComponent, decorators: [{
  49. type: Component,
  50. 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" }]
  51. }], ctorParameters: () => [{ type: i0.Renderer2 }, { type: Document, decorators: [{
  52. type: Inject,
  53. args: [DOCUMENT]
  54. }] }, { type: i0.ElementRef }], propDecorators: { icon: [{
  55. type: Input
  56. }], iconClass: [{
  57. type: Input
  58. }], fill: [{
  59. type: Input
  60. }], strokeWidth: [{
  61. type: Input
  62. }], strokeColor: [{
  63. type: Input
  64. }], size: [{
  65. type: Input
  66. }] } });
  67. class ButtonComponent {
  68. constructor() {
  69. this.text = '';
  70. this.type = 'default';
  71. this.size = 'base';
  72. this.variant = 'default';
  73. }
  74. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: ButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  75. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.0", type: ButtonComponent, isStandalone: true, selector: "ct-button", inputs: { text: "text", type: "type", size: "size", variant: "variant" }, ngImport: i0, template: "<button\n class=\"rounded-md px-4 py-2\"\n [class.bg-primary]=\"type === 'default'\"\n [class.bg-on-primary]=\"type === 'alternate'\"\n [class.bg-yellow-400]=\"type === 'warning'\"\n [class.bg-red-400]=\"type === 'error'\"\n [class.bg-lime-600]=\"type === 'success'\">\n {{ text }}\n</button>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
  76. }
  77. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: ButtonComponent, decorators: [{
  78. type: Component,
  79. args: [{ selector: 'ct-button', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<button\n class=\"rounded-md px-4 py-2\"\n [class.bg-primary]=\"type === 'default'\"\n [class.bg-on-primary]=\"type === 'alternate'\"\n [class.bg-yellow-400]=\"type === 'warning'\"\n [class.bg-red-400]=\"type === 'error'\"\n [class.bg-lime-600]=\"type === 'success'\">\n {{ text }}\n</button>\n" }]
  80. }], propDecorators: { text: [{
  81. type: Input,
  82. args: [{ required: true }]
  83. }], type: [{
  84. type: Input
  85. }], size: [{
  86. type: Input
  87. }], variant: [{
  88. type: Input
  89. }] } });
  90. /*
  91. * Public API Surface of circletone
  92. */
  93. /**
  94. * Generated bundle index. Do not edit.
  95. */
  96. export { ButtonComponent, IconComponent };
  97. //# sourceMappingURL=circletone.mjs.map