@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 14.3 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var SunnyComponent = /** @class */ (function () {
function SunnyComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], SunnyComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunnyComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SunnyComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunnyComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SunnyComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunnyComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunnyComponent.prototype, "size", void 0);
SunnyComponent = __decorate([
Component({
selector: "ibm-icon-sunny",
template: "\n <svg\n ibmIconSunny\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 "
})
], SunnyComponent);
return SunnyComponent;
}());
var SunnyDirective = /** @class */ (function () {
function SunnyDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Sunny32", "filepath": "sunny/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": "M16,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z", "transform": "translate(0 .005)" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.86 7.856)" } }, { "elem": "path", "attrs": { "d": "M2 15.005H7V17.005000000000003H2z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.86 24.149)" } }, { "elem": "path", "attrs": { "d": "M15 25.005H17V30.005H15z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.152 24.149)" } }, { "elem": "path", "attrs": { "d": "M25 15.005H30V17.005000000000003H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.152 7.856)" } }, { "elem": "path", "attrs": { "d": "M15 2.005H17V7.005H15z" } }], "name": "sunny", "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=\"M16,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\" transform=\"translate(0 .005)\"></path><path d=\"M6.854 5.375H8.854V10.333H6.854z\" transform=\"rotate(-45 7.86 7.856)\"></path><path d=\"M2 15.005H7V17.005000000000003H2z\"></path><path d=\"M5.375 23.147H10.333V25.147H5.375z\" transform=\"rotate(-45 7.86 24.149)\"></path><path d=\"M15 25.005H17V30.005H15z\"></path><path d=\"M23.147 21.668H25.147V26.625999999999998H23.147z\" transform=\"rotate(-45 24.152 24.149)\"></path><path d=\"M25 15.005H30V17.005000000000003H25z\"></path><path d=\"M21.668 6.854H26.625999999999998V8.854H21.668z\" transform=\"rotate(-45 24.152 7.856)\"></path><path d=\"M15 2.005H17V7.005H15z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Sunny24", "filepath": "sunny/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": "M16,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z", "transform": "translate(0 .005)" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.86 7.856)" } }, { "elem": "path", "attrs": { "d": "M2 15.005H7V17.005000000000003H2z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.86 24.149)" } }, { "elem": "path", "attrs": { "d": "M15 25.005H17V30.005H15z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.152 24.149)" } }, { "elem": "path", "attrs": { "d": "M25 15.005H30V17.005000000000003H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.152 7.856)" } }, { "elem": "path", "attrs": { "d": "M15 2.005H17V7.005H15z" } }], "name": "sunny", "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=\"M16,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\" transform=\"translate(0 .005)\"></path><path d=\"M6.854 5.375H8.854V10.333H6.854z\" transform=\"rotate(-45 7.86 7.856)\"></path><path d=\"M2 15.005H7V17.005000000000003H2z\"></path><path d=\"M5.375 23.147H10.333V25.147H5.375z\" transform=\"rotate(-45 7.86 24.149)\"></path><path d=\"M15 25.005H17V30.005H15z\"></path><path d=\"M23.147 21.668H25.147V26.625999999999998H23.147z\" transform=\"rotate(-45 24.152 24.149)\"></path><path d=\"M25 15.005H30V17.005000000000003H25z\"></path><path d=\"M21.668 6.854H26.625999999999998V8.854H21.668z\" transform=\"rotate(-45 24.152 7.856)\"></path><path d=\"M15 2.005H17V7.005H15z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Sunny20", "filepath": "sunny/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": "M16,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z", "transform": "translate(0 .005)" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.86 7.856)" } }, { "elem": "path", "attrs": { "d": "M2 15.005H7V17.005000000000003H2z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.86 24.149)" } }, { "elem": "path", "attrs": { "d": "M15 25.005H17V30.005H15z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.152 24.149)" } }, { "elem": "path", "attrs": { "d": "M25 15.005H30V17.005000000000003H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.152 7.856)" } }, { "elem": "path", "attrs": { "d": "M15 2.005H17V7.005H15z" } }], "name": "sunny", "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=\"M16,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\" transform=\"translate(0 .005)\"></path><path d=\"M6.854 5.375H8.854V10.333H6.854z\" transform=\"rotate(-45 7.86 7.856)\"></path><path d=\"M2 15.005H7V17.005000000000003H2z\"></path><path d=\"M5.375 23.147H10.333V25.147H5.375z\" transform=\"rotate(-45 7.86 24.149)\"></path><path d=\"M15 25.005H17V30.005H15z\"></path><path d=\"M23.147 21.668H25.147V26.625999999999998H23.147z\" transform=\"rotate(-45 24.152 24.149)\"></path><path d=\"M25 15.005H30V17.005000000000003H25z\"></path><path d=\"M21.668 6.854H26.625999999999998V8.854H21.668z\" transform=\"rotate(-45 24.152 7.856)\"></path><path d=\"M15 2.005H17V7.005H15z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Sunny16", "filepath": "sunny/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": "M16,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z", "transform": "translate(0 .005)" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.86 7.856)" } }, { "elem": "path", "attrs": { "d": "M2 15.005H7V17.005000000000003H2z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.86 24.149)" } }, { "elem": "path", "attrs": { "d": "M15 25.005H17V30.005H15z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.152 24.149)" } }, { "elem": "path", "attrs": { "d": "M25 15.005H30V17.005000000000003H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.152 7.856)" } }, { "elem": "path", "attrs": { "d": "M15 2.005H17V7.005H15z" } }], "name": "sunny", "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=\"M16,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\" transform=\"translate(0 .005)\"></path><path d=\"M6.854 5.375H8.854V10.333H6.854z\" transform=\"rotate(-45 7.86 7.856)\"></path><path d=\"M2 15.005H7V17.005000000000003H2z\"></path><path d=\"M5.375 23.147H10.333V25.147H5.375z\" transform=\"rotate(-45 7.86 24.149)\"></path><path d=\"M15 25.005H17V30.005H15z\"></path><path d=\"M23.147 21.668H25.147V26.625999999999998H23.147z\" transform=\"rotate(-45 24.152 24.149)\"></path><path d=\"M25 15.005H30V17.005000000000003H25z\"></path><path d=\"M21.668 6.854H26.625999999999998V8.854H21.668z\" transform=\"rotate(-45 24.152 7.856)\"></path><path d=\"M15 2.005H17V7.005H15z\"></path></svg>"
},
};
}
SunnyDirective_1 = SunnyDirective;
SunnyDirective.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;
SunnyDirective_1.titleIdCounter++;
title.setAttribute("id", "sunny-" + SunnyDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "sunny-" + SunnyDirective_1.titleIdCounter);
}
};
var SunnyDirective_1;
SunnyDirective.titleIdCounter = 0;
SunnyDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], SunnyDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunnyDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SunnyDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunnyDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SunnyDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunnyDirective.prototype, "size", void 0);
SunnyDirective = SunnyDirective_1 = __decorate([
Directive({
selector: "[ibmIconSunny]"
}),
__metadata("design:paramtypes", [ElementRef])
], SunnyDirective);
return SunnyDirective;
}());
var SunnyModule = /** @class */ (function () {
function SunnyModule() {
}
SunnyModule = __decorate([
NgModule({
declarations: [
SunnyComponent,
SunnyDirective,
],
exports: [
SunnyComponent,
SunnyDirective,
]
})
], SunnyModule);
return SunnyModule;
}());
export { SunnyComponent, SunnyDirective, SunnyModule };