UNPKG

@carbon/icons-angular

Version:

Angular components for icons in digital and software products using the Carbon Design System

174 lines (171 loc) 10.4 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var SoccerDirective_1; let SoccerComponent = class SoccerComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], SoccerComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], SoccerComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], SoccerComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], SoccerComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], SoccerComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], SoccerComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], SoccerComponent.prototype, "size", void 0); SoccerComponent = __decorate([ Component({ selector: "ibm-icon-soccer", template: ` <svg ibmIconSoccer [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], SoccerComponent); let SoccerDirective = SoccerDirective_1 = class SoccerDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Soccer32", "filepath": "soccer/32.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 32, "height": 32 }, "content": [{ "elem": "circle", "attrs": { "cx": "17", "cy": "28", "r": "2" } }, { "elem": "path", "attrs": { "d": "M7.55 17.5H15.45V19.5H7.55z", "transform": "rotate(-45 11.5 18.5)" } }, { "elem": "path", "attrs": { "d": "M28 16.584L19.4143 8H6v2H18.5857l3 3L6 28.5859 7.4141 30 23 14.415 26.584 18 23 21.5859 24.4141 23 28 19.416A2.0044 2.0044 0 0028 16.584zM24.5 9A3.5 3.5 0 1128 5.5 3.504 3.504 0 0124.5 9zm0-5A1.5 1.5 0 1026 5.5 1.5017 1.5017 0 0024.5 4z" } }], "name": "soccer", "size": 32 }, "size": 32 }, svg: `<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><circle cx="17" cy="28" r="2"></circle><path d="M7.55 17.5H15.45V19.5H7.55z" transform="rotate(-45 11.5 18.5)"></path><path d="M28 16.584L19.4143 8H6v2H18.5857l3 3L6 28.5859 7.4141 30 23 14.415 26.584 18 23 21.5859 24.4141 23 28 19.416A2.0044 2.0044 0 0028 16.584zM24.5 9A3.5 3.5 0 1128 5.5 3.504 3.504 0 0124.5 9zm0-5A1.5 1.5 0 1026 5.5 1.5017 1.5017 0 0024.5 4z"></path></svg>` }, "24": { metadata: { "moduleName": "Soccer24", "filepath": "soccer/24.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 24, "height": 24 }, "content": [{ "elem": "circle", "attrs": { "cx": "17", "cy": "28", "r": "2" } }, { "elem": "path", "attrs": { "d": "M7.55 17.5H15.45V19.5H7.55z", "transform": "rotate(-45 11.5 18.5)" } }, { "elem": "path", "attrs": { "d": "M28 16.584L19.4143 8H6v2H18.5857l3 3L6 28.5859 7.4141 30 23 14.415 26.584 18 23 21.5859 24.4141 23 28 19.416A2.0044 2.0044 0 0028 16.584zM24.5 9A3.5 3.5 0 1128 5.5 3.504 3.504 0 0124.5 9zm0-5A1.5 1.5 0 1026 5.5 1.5017 1.5017 0 0024.5 4z" } }], "name": "soccer", "size": 24 }, "size": 24 }, svg: `<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 32 32" aria-hidden="true"><circle cx="17" cy="28" r="2"></circle><path d="M7.55 17.5H15.45V19.5H7.55z" transform="rotate(-45 11.5 18.5)"></path><path d="M28 16.584L19.4143 8H6v2H18.5857l3 3L6 28.5859 7.4141 30 23 14.415 26.584 18 23 21.5859 24.4141 23 28 19.416A2.0044 2.0044 0 0028 16.584zM24.5 9A3.5 3.5 0 1128 5.5 3.504 3.504 0 0124.5 9zm0-5A1.5 1.5 0 1026 5.5 1.5017 1.5017 0 0024.5 4z"></path></svg>` }, "20": { metadata: { "moduleName": "Soccer20", "filepath": "soccer/20.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 20, "height": 20 }, "content": [{ "elem": "circle", "attrs": { "cx": "17", "cy": "28", "r": "2" } }, { "elem": "path", "attrs": { "d": "M7.55 17.5H15.45V19.5H7.55z", "transform": "rotate(-45 11.5 18.5)" } }, { "elem": "path", "attrs": { "d": "M28 16.584L19.4143 8H6v2H18.5857l3 3L6 28.5859 7.4141 30 23 14.415 26.584 18 23 21.5859 24.4141 23 28 19.416A2.0044 2.0044 0 0028 16.584zM24.5 9A3.5 3.5 0 1128 5.5 3.504 3.504 0 0124.5 9zm0-5A1.5 1.5 0 1026 5.5 1.5017 1.5017 0 0024.5 4z" } }], "name": "soccer", "size": 20 }, "size": 20 }, svg: `<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="20" height="20" viewBox="0 0 32 32" aria-hidden="true"><circle cx="17" cy="28" r="2"></circle><path d="M7.55 17.5H15.45V19.5H7.55z" transform="rotate(-45 11.5 18.5)"></path><path d="M28 16.584L19.4143 8H6v2H18.5857l3 3L6 28.5859 7.4141 30 23 14.415 26.584 18 23 21.5859 24.4141 23 28 19.416A2.0044 2.0044 0 0028 16.584zM24.5 9A3.5 3.5 0 1128 5.5 3.504 3.504 0 0124.5 9zm0-5A1.5 1.5 0 1026 5.5 1.5017 1.5017 0 0024.5 4z"></path></svg>` }, "16": { metadata: { "moduleName": "Soccer16", "filepath": "soccer/16.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 16, "height": 16 }, "content": [{ "elem": "circle", "attrs": { "cx": "17", "cy": "28", "r": "2" } }, { "elem": "path", "attrs": { "d": "M7.55 17.5H15.45V19.5H7.55z", "transform": "rotate(-45 11.5 18.5)" } }, { "elem": "path", "attrs": { "d": "M28 16.584L19.4143 8H6v2H18.5857l3 3L6 28.5859 7.4141 30 23 14.415 26.584 18 23 21.5859 24.4141 23 28 19.416A2.0044 2.0044 0 0028 16.584zM24.5 9A3.5 3.5 0 1128 5.5 3.504 3.504 0 0124.5 9zm0-5A1.5 1.5 0 1026 5.5 1.5017 1.5017 0 0024.5 4z" } }], "name": "soccer", "size": 16 }, "size": 16 }, svg: `<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="16" height="16" viewBox="0 0 32 32" aria-hidden="true"><circle cx="17" cy="28" r="2"></circle><path d="M7.55 17.5H15.45V19.5H7.55z" transform="rotate(-45 11.5 18.5)"></path><path d="M28 16.584L19.4143 8H6v2H18.5857l3 3L6 28.5859 7.4141 30 23 14.415 26.584 18 23 21.5859 24.4141 23 28 19.416A2.0044 2.0044 0 0028 16.584zM24.5 9A3.5 3.5 0 1128 5.5 3.504 3.504 0 0124.5 9zm0-5A1.5 1.5 0 1026 5.5 1.5017 1.5017 0 0024.5 4z"></path></svg>` }, }; } ngAfterViewInit() { const svg = this.elementRef.nativeElement; svg.setAttribute("xmlns", "http://www.w3.org/2000/svg"); const icon = this.icons[this.size]; const domParser = new DOMParser(); const rawSVG = icon.svg; const svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement; let node = svgElement.firstChild; while (node) { // importNode makes a clone of the node // this ensures we keep looping over the nodes in the parsed document svg.appendChild(svg.ownerDocument.importNode(node, true)); node = node.nextSibling; } const attributes = getAttributes({ width: icon.metadata.descriptor.attrs.height, height: icon.metadata.descriptor.attrs.height, viewBox: icon.metadata.descriptor.attrs.viewBox, title: this.title, "aria-label": this.ariaLabel, "aria-labelledby": this.ariaLabelledby, "aria-hidden": this.ariaHidden, focusable: this.isFocusable.toString() }); const attrKeys = Object.keys(attributes); for (let i = 0; i < attrKeys.length; i++) { const key = attrKeys[i]; const value = attributes[key]; if (key === "title") { continue; } if (value) { svg.setAttribute(key, value); } } if (attributes.title) { const title = document.createElement("title"); title.textContent = attributes.title; SoccerDirective_1.titleIdCounter++; title.setAttribute("id", `soccer-${SoccerDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `soccer-${SoccerDirective_1.titleIdCounter}`); } } }; SoccerDirective.titleIdCounter = 0; SoccerDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], SoccerDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], SoccerDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], SoccerDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], SoccerDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], SoccerDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], SoccerDirective.prototype, "size", void 0); SoccerDirective = SoccerDirective_1 = __decorate([ Directive({ selector: "[ibmIconSoccer]" }), __metadata("design:paramtypes", [ElementRef]) ], SoccerDirective); let SoccerModule = class SoccerModule { }; SoccerModule = __decorate([ NgModule({ declarations: [ SoccerComponent, SoccerDirective, ], exports: [ SoccerComponent, SoccerDirective, ] }) ], SoccerModule); export { SoccerComponent, SoccerDirective, SoccerModule };