UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 11.1 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var SoccerComponent = /** @class */ (function () { function SoccerComponent() { 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: "\n <svg\n ibmIconSoccer\n [size]=\"size\"\n [ariaLabel]=\"ariaLabel\"\n [ariaLabelledby]=\"ariaLabelledby\"\n [ariaHidden]=\"ariaHidden\"\n [title]=\"title\"\n [isFocusable]=\"focusable\"\n [attr.class]=\"innerClass\">\n </svg>\n " }) ], SoccerComponent); return SoccerComponent; }()); var SoccerDirective = /** @class */ (function () { function SoccerDirective(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>" }, }; } SoccerDirective_1 = SoccerDirective; SoccerDirective.prototype.ngAfterViewInit = function () { var svg = this.elementRef.nativeElement; svg.setAttribute("xmlns", "http://www.w3.org/2000/svg"); var icon = this.icons[this.size]; var domParser = new DOMParser(); var rawSVG = icon.svg; var svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement; var 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; } var 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() }); var attrKeys = Object.keys(attributes); for (var i = 0; i < attrKeys.length; i++) { var key = attrKeys[i]; var value = attributes[key]; if (key === "title") { continue; } if (value) { svg.setAttribute(key, value); } } if (attributes.title) { var 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); } }; var SoccerDirective_1; SoccerDirective.titleIdCounter = 0; SoccerDirective.ctorParameters = function () { return [ { 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); return SoccerDirective; }()); var SoccerModule = /** @class */ (function () { function SoccerModule() { } SoccerModule = __decorate([ NgModule({ declarations: [ SoccerComponent, SoccerDirective, ], exports: [ SoccerComponent, SoccerDirective, ] }) ], SoccerModule); return SoccerModule; }()); export { SoccerComponent, SoccerDirective, SoccerModule };