@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 14.4 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var PartlyCloudyDirective_1;
let PartlyCloudyComponent = class PartlyCloudyComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], PartlyCloudyComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PartlyCloudyComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], PartlyCloudyComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PartlyCloudyComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], PartlyCloudyComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PartlyCloudyComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PartlyCloudyComponent.prototype, "size", void 0);
PartlyCloudyComponent = __decorate([
Component({
selector: "ibm-icon-partly-cloudy",
template: `
<svg
ibmIconPartlyCloudy
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], PartlyCloudyComponent);
let PartlyCloudyDirective = PartlyCloudyDirective_1 = class PartlyCloudyDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "PartlyCloudy32", "filepath": "partly-cloudy/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": "M27 15H31V17H27z" } }, { "elem": "path", "attrs": { "d": "M23.086 5.794H27.329V7.794H23.086z", "transform": "rotate(-45 25.207 6.794)" } }, { "elem": "path", "attrs": { "d": "M15 1H17V5H15z" } }, { "elem": "path", "attrs": { "d": "M4.672 24.208H8.915V26.208H4.672z", "transform": "rotate(-45 6.793 25.208)" } }, { "elem": "path", "attrs": { "d": "M5.793 4.672H7.793V8.915H5.793z", "transform": "rotate(-45 6.793 6.794)" } }, { "elem": "path", "attrs": { "d": "M1 15H5V17H1zM26.7939 20.3418a6.9617 6.9617 0 00-1.8681-3.2671A8.485 8.485 0 0025 16a9 9 0 10-14.585 7.0332A4.9771 4.9771 0 0015 30H25a4.9947 4.9947 0 001.7939-9.6582zM9 16a6.9955 6.9955 0 0113.9849-.2969A6.8883 6.8883 0 0020 15a7.04 7.04 0 00-6.7944 5.3418A4.986 4.986 0 0011.5618 21.39 6.9675 6.9675 0 019 16zM25 28H15a2.9945 2.9945 0 01-.6963-5.9082l.6587-.1572.0986-.67a4.9923 4.9923 0 019.878 0l.0986.6695.6587.1572A2.9945 2.9945 0 0125 28z" } }], "name": "partly-cloudy", "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="M27 15H31V17H27z"></path><path d="M23.086 5.794H27.329V7.794H23.086z" transform="rotate(-45 25.207 6.794)"></path><path d="M15 1H17V5H15z"></path><path d="M4.672 24.208H8.915V26.208H4.672z" transform="rotate(-45 6.793 25.208)"></path><path d="M5.793 4.672H7.793V8.915H5.793z" transform="rotate(-45 6.793 6.794)"></path><path d="M1 15H5V17H1zM26.7939 20.3418a6.9617 6.9617 0 00-1.8681-3.2671A8.485 8.485 0 0025 16a9 9 0 10-14.585 7.0332A4.9771 4.9771 0 0015 30H25a4.9947 4.9947 0 001.7939-9.6582zM9 16a6.9955 6.9955 0 0113.9849-.2969A6.8883 6.8883 0 0020 15a7.04 7.04 0 00-6.7944 5.3418A4.986 4.986 0 0011.5618 21.39 6.9675 6.9675 0 019 16zM25 28H15a2.9945 2.9945 0 01-.6963-5.9082l.6587-.1572.0986-.67a4.9923 4.9923 0 019.878 0l.0986.6695.6587.1572A2.9945 2.9945 0 0125 28z"></path></svg>`
},
"24": {
metadata: { "moduleName": "PartlyCloudy24", "filepath": "partly-cloudy/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": "M27 15H31V17H27z" } }, { "elem": "path", "attrs": { "d": "M23.086 5.794H27.329V7.794H23.086z", "transform": "rotate(-45 25.207 6.794)" } }, { "elem": "path", "attrs": { "d": "M15 1H17V5H15z" } }, { "elem": "path", "attrs": { "d": "M4.672 24.208H8.915V26.208H4.672z", "transform": "rotate(-45 6.793 25.208)" } }, { "elem": "path", "attrs": { "d": "M5.793 4.672H7.793V8.915H5.793z", "transform": "rotate(-45 6.793 6.794)" } }, { "elem": "path", "attrs": { "d": "M1 15H5V17H1zM26.7939 20.3418a6.9617 6.9617 0 00-1.8681-3.2671A8.485 8.485 0 0025 16a9 9 0 10-14.585 7.0332A4.9771 4.9771 0 0015 30H25a4.9947 4.9947 0 001.7939-9.6582zM9 16a6.9955 6.9955 0 0113.9849-.2969A6.8883 6.8883 0 0020 15a7.04 7.04 0 00-6.7944 5.3418A4.986 4.986 0 0011.5618 21.39 6.9675 6.9675 0 019 16zM25 28H15a2.9945 2.9945 0 01-.6963-5.9082l.6587-.1572.0986-.67a4.9923 4.9923 0 019.878 0l.0986.6695.6587.1572A2.9945 2.9945 0 0125 28z" } }], "name": "partly-cloudy", "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="M27 15H31V17H27z"></path><path d="M23.086 5.794H27.329V7.794H23.086z" transform="rotate(-45 25.207 6.794)"></path><path d="M15 1H17V5H15z"></path><path d="M4.672 24.208H8.915V26.208H4.672z" transform="rotate(-45 6.793 25.208)"></path><path d="M5.793 4.672H7.793V8.915H5.793z" transform="rotate(-45 6.793 6.794)"></path><path d="M1 15H5V17H1zM26.7939 20.3418a6.9617 6.9617 0 00-1.8681-3.2671A8.485 8.485 0 0025 16a9 9 0 10-14.585 7.0332A4.9771 4.9771 0 0015 30H25a4.9947 4.9947 0 001.7939-9.6582zM9 16a6.9955 6.9955 0 0113.9849-.2969A6.8883 6.8883 0 0020 15a7.04 7.04 0 00-6.7944 5.3418A4.986 4.986 0 0011.5618 21.39 6.9675 6.9675 0 019 16zM25 28H15a2.9945 2.9945 0 01-.6963-5.9082l.6587-.1572.0986-.67a4.9923 4.9923 0 019.878 0l.0986.6695.6587.1572A2.9945 2.9945 0 0125 28z"></path></svg>`
},
"20": {
metadata: { "moduleName": "PartlyCloudy20", "filepath": "partly-cloudy/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": "M27 15H31V17H27z" } }, { "elem": "path", "attrs": { "d": "M23.086 5.794H27.329V7.794H23.086z", "transform": "rotate(-45 25.207 6.794)" } }, { "elem": "path", "attrs": { "d": "M15 1H17V5H15z" } }, { "elem": "path", "attrs": { "d": "M4.672 24.208H8.915V26.208H4.672z", "transform": "rotate(-45 6.793 25.208)" } }, { "elem": "path", "attrs": { "d": "M5.793 4.672H7.793V8.915H5.793z", "transform": "rotate(-45 6.793 6.794)" } }, { "elem": "path", "attrs": { "d": "M1 15H5V17H1zM26.7939 20.3418a6.9617 6.9617 0 00-1.8681-3.2671A8.485 8.485 0 0025 16a9 9 0 10-14.585 7.0332A4.9771 4.9771 0 0015 30H25a4.9947 4.9947 0 001.7939-9.6582zM9 16a6.9955 6.9955 0 0113.9849-.2969A6.8883 6.8883 0 0020 15a7.04 7.04 0 00-6.7944 5.3418A4.986 4.986 0 0011.5618 21.39 6.9675 6.9675 0 019 16zM25 28H15a2.9945 2.9945 0 01-.6963-5.9082l.6587-.1572.0986-.67a4.9923 4.9923 0 019.878 0l.0986.6695.6587.1572A2.9945 2.9945 0 0125 28z" } }], "name": "partly-cloudy", "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="M27 15H31V17H27z"></path><path d="M23.086 5.794H27.329V7.794H23.086z" transform="rotate(-45 25.207 6.794)"></path><path d="M15 1H17V5H15z"></path><path d="M4.672 24.208H8.915V26.208H4.672z" transform="rotate(-45 6.793 25.208)"></path><path d="M5.793 4.672H7.793V8.915H5.793z" transform="rotate(-45 6.793 6.794)"></path><path d="M1 15H5V17H1zM26.7939 20.3418a6.9617 6.9617 0 00-1.8681-3.2671A8.485 8.485 0 0025 16a9 9 0 10-14.585 7.0332A4.9771 4.9771 0 0015 30H25a4.9947 4.9947 0 001.7939-9.6582zM9 16a6.9955 6.9955 0 0113.9849-.2969A6.8883 6.8883 0 0020 15a7.04 7.04 0 00-6.7944 5.3418A4.986 4.986 0 0011.5618 21.39 6.9675 6.9675 0 019 16zM25 28H15a2.9945 2.9945 0 01-.6963-5.9082l.6587-.1572.0986-.67a4.9923 4.9923 0 019.878 0l.0986.6695.6587.1572A2.9945 2.9945 0 0125 28z"></path></svg>`
},
"16": {
metadata: { "moduleName": "PartlyCloudy16", "filepath": "partly-cloudy/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": "M27 15H31V17H27z" } }, { "elem": "path", "attrs": { "d": "M23.086 5.794H27.329V7.794H23.086z", "transform": "rotate(-45 25.207 6.794)" } }, { "elem": "path", "attrs": { "d": "M15 1H17V5H15z" } }, { "elem": "path", "attrs": { "d": "M4.672 24.208H8.915V26.208H4.672z", "transform": "rotate(-45 6.793 25.208)" } }, { "elem": "path", "attrs": { "d": "M5.793 4.672H7.793V8.915H5.793z", "transform": "rotate(-45 6.793 6.794)" } }, { "elem": "path", "attrs": { "d": "M1 15H5V17H1zM26.7939 20.3418a6.9617 6.9617 0 00-1.8681-3.2671A8.485 8.485 0 0025 16a9 9 0 10-14.585 7.0332A4.9771 4.9771 0 0015 30H25a4.9947 4.9947 0 001.7939-9.6582zM9 16a6.9955 6.9955 0 0113.9849-.2969A6.8883 6.8883 0 0020 15a7.04 7.04 0 00-6.7944 5.3418A4.986 4.986 0 0011.5618 21.39 6.9675 6.9675 0 019 16zM25 28H15a2.9945 2.9945 0 01-.6963-5.9082l.6587-.1572.0986-.67a4.9923 4.9923 0 019.878 0l.0986.6695.6587.1572A2.9945 2.9945 0 0125 28z" } }], "name": "partly-cloudy", "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="M27 15H31V17H27z"></path><path d="M23.086 5.794H27.329V7.794H23.086z" transform="rotate(-45 25.207 6.794)"></path><path d="M15 1H17V5H15z"></path><path d="M4.672 24.208H8.915V26.208H4.672z" transform="rotate(-45 6.793 25.208)"></path><path d="M5.793 4.672H7.793V8.915H5.793z" transform="rotate(-45 6.793 6.794)"></path><path d="M1 15H5V17H1zM26.7939 20.3418a6.9617 6.9617 0 00-1.8681-3.2671A8.485 8.485 0 0025 16a9 9 0 10-14.585 7.0332A4.9771 4.9771 0 0015 30H25a4.9947 4.9947 0 001.7939-9.6582zM9 16a6.9955 6.9955 0 0113.9849-.2969A6.8883 6.8883 0 0020 15a7.04 7.04 0 00-6.7944 5.3418A4.986 4.986 0 0011.5618 21.39 6.9675 6.9675 0 019 16zM25 28H15a2.9945 2.9945 0 01-.6963-5.9082l.6587-.1572.0986-.67a4.9923 4.9923 0 019.878 0l.0986.6695.6587.1572A2.9945 2.9945 0 0125 28z"></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;
PartlyCloudyDirective_1.titleIdCounter++;
title.setAttribute("id", `partly-cloudy-${PartlyCloudyDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `partly-cloudy-${PartlyCloudyDirective_1.titleIdCounter}`);
}
}
};
PartlyCloudyDirective.titleIdCounter = 0;
PartlyCloudyDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], PartlyCloudyDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PartlyCloudyDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], PartlyCloudyDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PartlyCloudyDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], PartlyCloudyDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PartlyCloudyDirective.prototype, "size", void 0);
PartlyCloudyDirective = PartlyCloudyDirective_1 = __decorate([
Directive({
selector: "[ibmIconPartlyCloudy]"
}),
__metadata("design:paramtypes", [ElementRef])
], PartlyCloudyDirective);
let PartlyCloudyModule = class PartlyCloudyModule {
};
PartlyCloudyModule = __decorate([
NgModule({
declarations: [
PartlyCloudyComponent,
PartlyCloudyDirective,
],
exports: [
PartlyCloudyComponent,
PartlyCloudyDirective,
]
})
], PartlyCloudyModule);
export { PartlyCloudyComponent, PartlyCloudyDirective, PartlyCloudyModule };