UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.91 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var RssComponent = /** @class */ (function () { function RssComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], RssComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], RssComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RssComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], RssComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RssComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], RssComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], RssComponent.prototype, "size", void 0); RssComponent = __decorate([ Component({ selector: "ibm-icon-rss", template: "\n <svg\n ibmIconRss\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 " }) ], RssComponent); return RssComponent; }()); var RssDirective = /** @class */ (function () { function RssDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Rss32", "filepath": "rss/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": "path", "attrs": { "d": "M8 18c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6C14 20.7 11.3 18 8 18zM8 28c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4C12 26.2 10.2 28 8 28zM30 24h-2C28 13 19 4 8 4V2C20.1 2 30 11.9 30 24z" } }, { "elem": "path", "attrs": { "d": "M22,24h-2c0-6.6-5.4-12-12-12v-2C15.7,10,22,16.3,22,24z" } }], "name": "rss", "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\"><path d=\"M8 18c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6C14 20.7 11.3 18 8 18zM8 28c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4C12 26.2 10.2 28 8 28zM30 24h-2C28 13 19 4 8 4V2C20.1 2 30 11.9 30 24z\"></path><path d=\"M22,24h-2c0-6.6-5.4-12-12-12v-2C15.7,10,22,16.3,22,24z\"></path></svg>" }, "24": { metadata: { "moduleName": "Rss24", "filepath": "rss/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": "path", "attrs": { "d": "M8 18c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6C14 20.7 11.3 18 8 18zM8 28c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4C12 26.2 10.2 28 8 28zM30 24h-2C28 13 19 4 8 4V2C20.1 2 30 11.9 30 24z" } }, { "elem": "path", "attrs": { "d": "M22,24h-2c0-6.6-5.4-12-12-12v-2C15.7,10,22,16.3,22,24z" } }], "name": "rss", "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\"><path d=\"M8 18c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6C14 20.7 11.3 18 8 18zM8 28c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4C12 26.2 10.2 28 8 28zM30 24h-2C28 13 19 4 8 4V2C20.1 2 30 11.9 30 24z\"></path><path d=\"M22,24h-2c0-6.6-5.4-12-12-12v-2C15.7,10,22,16.3,22,24z\"></path></svg>" }, "20": { metadata: { "moduleName": "Rss20", "filepath": "rss/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": "path", "attrs": { "d": "M8 18c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6C14 20.7 11.3 18 8 18zM8 28c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4C12 26.2 10.2 28 8 28zM30 24h-2C28 13 19 4 8 4V2C20.1 2 30 11.9 30 24z" } }, { "elem": "path", "attrs": { "d": "M22,24h-2c0-6.6-5.4-12-12-12v-2C15.7,10,22,16.3,22,24z" } }], "name": "rss", "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\"><path d=\"M8 18c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6C14 20.7 11.3 18 8 18zM8 28c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4C12 26.2 10.2 28 8 28zM30 24h-2C28 13 19 4 8 4V2C20.1 2 30 11.9 30 24z\"></path><path d=\"M22,24h-2c0-6.6-5.4-12-12-12v-2C15.7,10,22,16.3,22,24z\"></path></svg>" }, "16": { metadata: { "moduleName": "Rss16", "filepath": "rss/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": "path", "attrs": { "d": "M8 18c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6C14 20.7 11.3 18 8 18zM8 28c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4C12 26.2 10.2 28 8 28zM30 24h-2C28 13 19 4 8 4V2C20.1 2 30 11.9 30 24z" } }, { "elem": "path", "attrs": { "d": "M22,24h-2c0-6.6-5.4-12-12-12v-2C15.7,10,22,16.3,22,24z" } }], "name": "rss", "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\"><path d=\"M8 18c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6C14 20.7 11.3 18 8 18zM8 28c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4C12 26.2 10.2 28 8 28zM30 24h-2C28 13 19 4 8 4V2C20.1 2 30 11.9 30 24z\"></path><path d=\"M22,24h-2c0-6.6-5.4-12-12-12v-2C15.7,10,22,16.3,22,24z\"></path></svg>" }, }; } RssDirective_1 = RssDirective; RssDirective.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; RssDirective_1.titleIdCounter++; title.setAttribute("id", "rss-" + RssDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "rss-" + RssDirective_1.titleIdCounter); } }; var RssDirective_1; RssDirective.titleIdCounter = 0; RssDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], RssDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], RssDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RssDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], RssDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RssDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], RssDirective.prototype, "size", void 0); RssDirective = RssDirective_1 = __decorate([ Directive({ selector: "[ibmIconRss]" }), __metadata("design:paramtypes", [ElementRef]) ], RssDirective); return RssDirective; }()); var RssModule = /** @class */ (function () { function RssModule() { } RssModule = __decorate([ NgModule({ declarations: [ RssComponent, RssDirective, ], exports: [ RssComponent, RssDirective, ] }) ], RssModule); return RssModule; }()); export { RssComponent, RssDirective, RssModule };