UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 12 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var BrightnessContrastDirective_1; let BrightnessContrastComponent = class BrightnessContrastComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], BrightnessContrastComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], BrightnessContrastComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], BrightnessContrastComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], BrightnessContrastComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], BrightnessContrastComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], BrightnessContrastComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], BrightnessContrastComponent.prototype, "size", void 0); BrightnessContrastComponent = __decorate([ Component({ selector: "ibm-icon-brightness-contrast", template: ` <svg ibmIconBrightnessContrast [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], BrightnessContrastComponent); let BrightnessContrastDirective = BrightnessContrastDirective_1 = class BrightnessContrastDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "BrightnessContrast32", "filepath": "brightness-contrast/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": "M15 2H17V5H15zM27 15H30V17H27zM15 27H17V30H15zM2 15H5V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.22 5.73H8.219999999999999V8.73H6.22z", "transform": "rotate(-45 7.227 7.236)" } }, { "elem": "path", "attrs": { "d": "M23.27 6.23H26.27V8.23H23.27z", "transform": "rotate(-45 24.766 7.232)" } }, { "elem": "path", "attrs": { "d": "M23.77 23.27H25.77V26.27H23.77z", "transform": "rotate(-45 24.77 24.77)" } }, { "elem": "path", "attrs": { "d": "M5.47 25.13L7.59 23 9 24.42 6.88 26.54 5.47 25.13zM16 8a8 8 0 108 8A8 8 0 0016 8zm0 14a6 6 0 010-12z" } }], "name": "brightness-contrast", "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="M15 2H17V5H15zM27 15H30V17H27zM15 27H17V30H15zM2 15H5V17H2z"></path><path d="M6.22 5.73H8.219999999999999V8.73H6.22z" transform="rotate(-45 7.227 7.236)"></path><path d="M23.27 6.23H26.27V8.23H23.27z" transform="rotate(-45 24.766 7.232)"></path><path d="M23.77 23.27H25.77V26.27H23.77z" transform="rotate(-45 24.77 24.77)"></path><path d="M5.47 25.13L7.59 23 9 24.42 6.88 26.54 5.47 25.13zM16 8a8 8 0 108 8A8 8 0 0016 8zm0 14a6 6 0 010-12z"></path></svg>` }, "24": { metadata: { "moduleName": "BrightnessContrast24", "filepath": "brightness-contrast/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": "M15 2H17V5H15zM27 15H30V17H27zM15 27H17V30H15zM2 15H5V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.22 5.73H8.219999999999999V8.73H6.22z", "transform": "rotate(-45 7.227 7.236)" } }, { "elem": "path", "attrs": { "d": "M23.27 6.23H26.27V8.23H23.27z", "transform": "rotate(-45 24.766 7.232)" } }, { "elem": "path", "attrs": { "d": "M23.77 23.27H25.77V26.27H23.77z", "transform": "rotate(-45 24.77 24.77)" } }, { "elem": "path", "attrs": { "d": "M5.47 25.13L7.59 23 9 24.42 6.88 26.54 5.47 25.13zM16 8a8 8 0 108 8A8 8 0 0016 8zm0 14a6 6 0 010-12z" } }], "name": "brightness-contrast", "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="M15 2H17V5H15zM27 15H30V17H27zM15 27H17V30H15zM2 15H5V17H2z"></path><path d="M6.22 5.73H8.219999999999999V8.73H6.22z" transform="rotate(-45 7.227 7.236)"></path><path d="M23.27 6.23H26.27V8.23H23.27z" transform="rotate(-45 24.766 7.232)"></path><path d="M23.77 23.27H25.77V26.27H23.77z" transform="rotate(-45 24.77 24.77)"></path><path d="M5.47 25.13L7.59 23 9 24.42 6.88 26.54 5.47 25.13zM16 8a8 8 0 108 8A8 8 0 0016 8zm0 14a6 6 0 010-12z"></path></svg>` }, "20": { metadata: { "moduleName": "BrightnessContrast20", "filepath": "brightness-contrast/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": "M15 2H17V5H15zM27 15H30V17H27zM15 27H17V30H15zM2 15H5V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.22 5.73H8.219999999999999V8.73H6.22z", "transform": "rotate(-45 7.227 7.236)" } }, { "elem": "path", "attrs": { "d": "M23.27 6.23H26.27V8.23H23.27z", "transform": "rotate(-45 24.766 7.232)" } }, { "elem": "path", "attrs": { "d": "M23.77 23.27H25.77V26.27H23.77z", "transform": "rotate(-45 24.77 24.77)" } }, { "elem": "path", "attrs": { "d": "M5.47 25.13L7.59 23 9 24.42 6.88 26.54 5.47 25.13zM16 8a8 8 0 108 8A8 8 0 0016 8zm0 14a6 6 0 010-12z" } }], "name": "brightness-contrast", "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="M15 2H17V5H15zM27 15H30V17H27zM15 27H17V30H15zM2 15H5V17H2z"></path><path d="M6.22 5.73H8.219999999999999V8.73H6.22z" transform="rotate(-45 7.227 7.236)"></path><path d="M23.27 6.23H26.27V8.23H23.27z" transform="rotate(-45 24.766 7.232)"></path><path d="M23.77 23.27H25.77V26.27H23.77z" transform="rotate(-45 24.77 24.77)"></path><path d="M5.47 25.13L7.59 23 9 24.42 6.88 26.54 5.47 25.13zM16 8a8 8 0 108 8A8 8 0 0016 8zm0 14a6 6 0 010-12z"></path></svg>` }, "16": { metadata: { "moduleName": "BrightnessContrast16", "filepath": "brightness-contrast/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": "M15 2H17V5H15zM27 15H30V17H27zM15 27H17V30H15zM2 15H5V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.22 5.73H8.219999999999999V8.73H6.22z", "transform": "rotate(-45 7.227 7.236)" } }, { "elem": "path", "attrs": { "d": "M23.27 6.23H26.27V8.23H23.27z", "transform": "rotate(-45 24.766 7.232)" } }, { "elem": "path", "attrs": { "d": "M23.77 23.27H25.77V26.27H23.77z", "transform": "rotate(-45 24.77 24.77)" } }, { "elem": "path", "attrs": { "d": "M5.47 25.13L7.59 23 9 24.42 6.88 26.54 5.47 25.13zM16 8a8 8 0 108 8A8 8 0 0016 8zm0 14a6 6 0 010-12z" } }], "name": "brightness-contrast", "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="M15 2H17V5H15zM27 15H30V17H27zM15 27H17V30H15zM2 15H5V17H2z"></path><path d="M6.22 5.73H8.219999999999999V8.73H6.22z" transform="rotate(-45 7.227 7.236)"></path><path d="M23.27 6.23H26.27V8.23H23.27z" transform="rotate(-45 24.766 7.232)"></path><path d="M23.77 23.27H25.77V26.27H23.77z" transform="rotate(-45 24.77 24.77)"></path><path d="M5.47 25.13L7.59 23 9 24.42 6.88 26.54 5.47 25.13zM16 8a8 8 0 108 8A8 8 0 0016 8zm0 14a6 6 0 010-12z"></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; BrightnessContrastDirective_1.titleIdCounter++; title.setAttribute("id", `brightness-contrast-${BrightnessContrastDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `brightness-contrast-${BrightnessContrastDirective_1.titleIdCounter}`); } } }; BrightnessContrastDirective.titleIdCounter = 0; BrightnessContrastDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], BrightnessContrastDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], BrightnessContrastDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], BrightnessContrastDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], BrightnessContrastDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], BrightnessContrastDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], BrightnessContrastDirective.prototype, "size", void 0); BrightnessContrastDirective = BrightnessContrastDirective_1 = __decorate([ Directive({ selector: "[ibmIconBrightnessContrast]" }), __metadata("design:paramtypes", [ElementRef]) ], BrightnessContrastDirective); let BrightnessContrastModule = class BrightnessContrastModule { }; BrightnessContrastModule = __decorate([ NgModule({ declarations: [ BrightnessContrastComponent, BrightnessContrastDirective, ], exports: [ BrightnessContrastComponent, BrightnessContrastDirective, ] }) ], BrightnessContrastModule); export { BrightnessContrastComponent, BrightnessContrastDirective, BrightnessContrastModule };