@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 13.1 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var TennisDirective_1;
let TennisComponent = class TennisComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], TennisComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TennisComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], TennisComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TennisComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], TennisComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TennisComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TennisComponent.prototype, "size", void 0);
TennisComponent = __decorate([
Component({
selector: "ibm-icon-tennis",
template: `
<svg
ibmIconTennis
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], TennisComponent);
let TennisDirective = TennisDirective_1 = class TennisDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Tennis32", "filepath": "tennis/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": "rect", "attrs": { "width": "4", "height": "4", "x": "20", "y": "2", "rx": "2" } }, { "elem": "path", "attrs": { "d": "M11,16a1,1,0,0,1-.707-1.707l7-7a1,1,0,1,1,1.414,1.414l-7,7A.9962.9962,0,0,1,11,16Z" } }, { "elem": "path", "attrs": { "d": "M23.707,24.293a8.3948,8.3948,0,0,0-4.72-2.209c.1992-.1641.3931-.3364.5777-.521a9.2447,9.2447,0,0,0,1.7334-9.9141l-1.8768.6973c1.11,2.9805.6346,5.8975-1.2722,7.8022a6.6964,6.6964,0,0,1-5.561,1.8047,9.7746,9.7746,0,0,1-5.771-2.7856c-2.9727-2.97-4.0759-8.2276-.9805-11.32,1.9068-1.9053,4.8267-2.38,7.8094-1.271l.6987-1.875C10.6616,3.333,6.8591,3.9961,4.4207,6.4331c-3.9427,3.9385-2.6761,10.4956.98,14.1489a11.8136,11.8136,0,0,0,6.9766,3.36c.21.022.4153.0234.6223.0332V24h4.9968a6.8463,6.8463,0,0,1,4.2962,1.707L26.5859,30,28,28.5859Z" } }], "name": "tennis", "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"><rect width="4" height="4" x="20" y="2" rx="2"></rect><path d="M11,16a1,1,0,0,1-.707-1.707l7-7a1,1,0,1,1,1.414,1.414l-7,7A.9962.9962,0,0,1,11,16Z"></path><path d="M23.707,24.293a8.3948,8.3948,0,0,0-4.72-2.209c.1992-.1641.3931-.3364.5777-.521a9.2447,9.2447,0,0,0,1.7334-9.9141l-1.8768.6973c1.11,2.9805.6346,5.8975-1.2722,7.8022a6.6964,6.6964,0,0,1-5.561,1.8047,9.7746,9.7746,0,0,1-5.771-2.7856c-2.9727-2.97-4.0759-8.2276-.9805-11.32,1.9068-1.9053,4.8267-2.38,7.8094-1.271l.6987-1.875C10.6616,3.333,6.8591,3.9961,4.4207,6.4331c-3.9427,3.9385-2.6761,10.4956.98,14.1489a11.8136,11.8136,0,0,0,6.9766,3.36c.21.022.4153.0234.6223.0332V24h4.9968a6.8463,6.8463,0,0,1,4.2962,1.707L26.5859,30,28,28.5859Z"></path></svg>`
},
"24": {
metadata: { "moduleName": "Tennis24", "filepath": "tennis/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": "rect", "attrs": { "width": "4", "height": "4", "x": "20", "y": "2", "rx": "2" } }, { "elem": "path", "attrs": { "d": "M11,16a1,1,0,0,1-.707-1.707l7-7a1,1,0,1,1,1.414,1.414l-7,7A.9962.9962,0,0,1,11,16Z" } }, { "elem": "path", "attrs": { "d": "M23.707,24.293a8.3948,8.3948,0,0,0-4.72-2.209c.1992-.1641.3931-.3364.5777-.521a9.2447,9.2447,0,0,0,1.7334-9.9141l-1.8768.6973c1.11,2.9805.6346,5.8975-1.2722,7.8022a6.6964,6.6964,0,0,1-5.561,1.8047,9.7746,9.7746,0,0,1-5.771-2.7856c-2.9727-2.97-4.0759-8.2276-.9805-11.32,1.9068-1.9053,4.8267-2.38,7.8094-1.271l.6987-1.875C10.6616,3.333,6.8591,3.9961,4.4207,6.4331c-3.9427,3.9385-2.6761,10.4956.98,14.1489a11.8136,11.8136,0,0,0,6.9766,3.36c.21.022.4153.0234.6223.0332V24h4.9968a6.8463,6.8463,0,0,1,4.2962,1.707L26.5859,30,28,28.5859Z" } }], "name": "tennis", "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"><rect width="4" height="4" x="20" y="2" rx="2"></rect><path d="M11,16a1,1,0,0,1-.707-1.707l7-7a1,1,0,1,1,1.414,1.414l-7,7A.9962.9962,0,0,1,11,16Z"></path><path d="M23.707,24.293a8.3948,8.3948,0,0,0-4.72-2.209c.1992-.1641.3931-.3364.5777-.521a9.2447,9.2447,0,0,0,1.7334-9.9141l-1.8768.6973c1.11,2.9805.6346,5.8975-1.2722,7.8022a6.6964,6.6964,0,0,1-5.561,1.8047,9.7746,9.7746,0,0,1-5.771-2.7856c-2.9727-2.97-4.0759-8.2276-.9805-11.32,1.9068-1.9053,4.8267-2.38,7.8094-1.271l.6987-1.875C10.6616,3.333,6.8591,3.9961,4.4207,6.4331c-3.9427,3.9385-2.6761,10.4956.98,14.1489a11.8136,11.8136,0,0,0,6.9766,3.36c.21.022.4153.0234.6223.0332V24h4.9968a6.8463,6.8463,0,0,1,4.2962,1.707L26.5859,30,28,28.5859Z"></path></svg>`
},
"20": {
metadata: { "moduleName": "Tennis20", "filepath": "tennis/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": "rect", "attrs": { "width": "4", "height": "4", "x": "20", "y": "2", "rx": "2" } }, { "elem": "path", "attrs": { "d": "M11,16a1,1,0,0,1-.707-1.707l7-7a1,1,0,1,1,1.414,1.414l-7,7A.9962.9962,0,0,1,11,16Z" } }, { "elem": "path", "attrs": { "d": "M23.707,24.293a8.3948,8.3948,0,0,0-4.72-2.209c.1992-.1641.3931-.3364.5777-.521a9.2447,9.2447,0,0,0,1.7334-9.9141l-1.8768.6973c1.11,2.9805.6346,5.8975-1.2722,7.8022a6.6964,6.6964,0,0,1-5.561,1.8047,9.7746,9.7746,0,0,1-5.771-2.7856c-2.9727-2.97-4.0759-8.2276-.9805-11.32,1.9068-1.9053,4.8267-2.38,7.8094-1.271l.6987-1.875C10.6616,3.333,6.8591,3.9961,4.4207,6.4331c-3.9427,3.9385-2.6761,10.4956.98,14.1489a11.8136,11.8136,0,0,0,6.9766,3.36c.21.022.4153.0234.6223.0332V24h4.9968a6.8463,6.8463,0,0,1,4.2962,1.707L26.5859,30,28,28.5859Z" } }], "name": "tennis", "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"><rect width="4" height="4" x="20" y="2" rx="2"></rect><path d="M11,16a1,1,0,0,1-.707-1.707l7-7a1,1,0,1,1,1.414,1.414l-7,7A.9962.9962,0,0,1,11,16Z"></path><path d="M23.707,24.293a8.3948,8.3948,0,0,0-4.72-2.209c.1992-.1641.3931-.3364.5777-.521a9.2447,9.2447,0,0,0,1.7334-9.9141l-1.8768.6973c1.11,2.9805.6346,5.8975-1.2722,7.8022a6.6964,6.6964,0,0,1-5.561,1.8047,9.7746,9.7746,0,0,1-5.771-2.7856c-2.9727-2.97-4.0759-8.2276-.9805-11.32,1.9068-1.9053,4.8267-2.38,7.8094-1.271l.6987-1.875C10.6616,3.333,6.8591,3.9961,4.4207,6.4331c-3.9427,3.9385-2.6761,10.4956.98,14.1489a11.8136,11.8136,0,0,0,6.9766,3.36c.21.022.4153.0234.6223.0332V24h4.9968a6.8463,6.8463,0,0,1,4.2962,1.707L26.5859,30,28,28.5859Z"></path></svg>`
},
"16": {
metadata: { "moduleName": "Tennis16", "filepath": "tennis/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": "rect", "attrs": { "width": "4", "height": "4", "x": "20", "y": "2", "rx": "2" } }, { "elem": "path", "attrs": { "d": "M11,16a1,1,0,0,1-.707-1.707l7-7a1,1,0,1,1,1.414,1.414l-7,7A.9962.9962,0,0,1,11,16Z" } }, { "elem": "path", "attrs": { "d": "M23.707,24.293a8.3948,8.3948,0,0,0-4.72-2.209c.1992-.1641.3931-.3364.5777-.521a9.2447,9.2447,0,0,0,1.7334-9.9141l-1.8768.6973c1.11,2.9805.6346,5.8975-1.2722,7.8022a6.6964,6.6964,0,0,1-5.561,1.8047,9.7746,9.7746,0,0,1-5.771-2.7856c-2.9727-2.97-4.0759-8.2276-.9805-11.32,1.9068-1.9053,4.8267-2.38,7.8094-1.271l.6987-1.875C10.6616,3.333,6.8591,3.9961,4.4207,6.4331c-3.9427,3.9385-2.6761,10.4956.98,14.1489a11.8136,11.8136,0,0,0,6.9766,3.36c.21.022.4153.0234.6223.0332V24h4.9968a6.8463,6.8463,0,0,1,4.2962,1.707L26.5859,30,28,28.5859Z" } }], "name": "tennis", "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"><rect width="4" height="4" x="20" y="2" rx="2"></rect><path d="M11,16a1,1,0,0,1-.707-1.707l7-7a1,1,0,1,1,1.414,1.414l-7,7A.9962.9962,0,0,1,11,16Z"></path><path d="M23.707,24.293a8.3948,8.3948,0,0,0-4.72-2.209c.1992-.1641.3931-.3364.5777-.521a9.2447,9.2447,0,0,0,1.7334-9.9141l-1.8768.6973c1.11,2.9805.6346,5.8975-1.2722,7.8022a6.6964,6.6964,0,0,1-5.561,1.8047,9.7746,9.7746,0,0,1-5.771-2.7856c-2.9727-2.97-4.0759-8.2276-.9805-11.32,1.9068-1.9053,4.8267-2.38,7.8094-1.271l.6987-1.875C10.6616,3.333,6.8591,3.9961,4.4207,6.4331c-3.9427,3.9385-2.6761,10.4956.98,14.1489a11.8136,11.8136,0,0,0,6.9766,3.36c.21.022.4153.0234.6223.0332V24h4.9968a6.8463,6.8463,0,0,1,4.2962,1.707L26.5859,30,28,28.5859Z"></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;
TennisDirective_1.titleIdCounter++;
title.setAttribute("id", `tennis-${TennisDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `tennis-${TennisDirective_1.titleIdCounter}`);
}
}
};
TennisDirective.titleIdCounter = 0;
TennisDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], TennisDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TennisDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], TennisDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TennisDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], TennisDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TennisDirective.prototype, "size", void 0);
TennisDirective = TennisDirective_1 = __decorate([
Directive({
selector: "[ibmIconTennis]"
}),
__metadata("design:paramtypes", [ElementRef])
], TennisDirective);
let TennisModule = class TennisModule {
};
TennisModule = __decorate([
NgModule({
declarations: [
TennisComponent,
TennisDirective,
],
exports: [
TennisComponent,
TennisDirective,
]
})
], TennisModule);
export { TennisComponent, TennisDirective, TennisModule };