@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 11.2 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var LogoQuoraDirective_1;
let LogoQuoraComponent = class LogoQuoraComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], LogoQuoraComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], LogoQuoraComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], LogoQuoraComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], LogoQuoraComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], LogoQuoraComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], LogoQuoraComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], LogoQuoraComponent.prototype, "size", void 0);
LogoQuoraComponent = __decorate([
Component({
selector: "ibm-icon-logo-quora",
template: `
<svg
ibmIconLogoQuora
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], LogoQuoraComponent);
let LogoQuoraDirective = LogoQuoraDirective_1 = class LogoQuoraDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "LogoQuora32", "filepath": "logo--quora/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": "M29,23.86H27a1.72,1.72,0,0,1-1.73,1.72c-1.15,0-1.82-.86-2.58-2a11,11,0,0,0,4.79-9.1c.09-7.19-5.85-11.89-12.17-11.89S3,7.37,3,14.37,9,26.16,15.17,26.16a10.71,10.71,0,0,0,3.07-.48c1.15,2.11,2.59,3.74,5.46,3.74A5,5,0,0,0,29,23.86Zm-8.14-3.45a6.31,6.31,0,0,0-5.56-3.16,6,6,0,0,0-3.74,1.15L12.2,20a2.56,2.56,0,0,1,.86-.1c1.82,0,3,1.53,4.12,3.64a7.58,7.58,0,0,1-1.91.19C10.86,23.76,9,20.6,9,14.47s1.91-9.3,6.23-9.3,6.32,3.16,6.32,9.3A20.68,20.68,0,0,1,20.83,20.41Z" } }], "name": "logo--quora", "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="M29,23.86H27a1.72,1.72,0,0,1-1.73,1.72c-1.15,0-1.82-.86-2.58-2a11,11,0,0,0,4.79-9.1c.09-7.19-5.85-11.89-12.17-11.89S3,7.37,3,14.37,9,26.16,15.17,26.16a10.71,10.71,0,0,0,3.07-.48c1.15,2.11,2.59,3.74,5.46,3.74A5,5,0,0,0,29,23.86Zm-8.14-3.45a6.31,6.31,0,0,0-5.56-3.16,6,6,0,0,0-3.74,1.15L12.2,20a2.56,2.56,0,0,1,.86-.1c1.82,0,3,1.53,4.12,3.64a7.58,7.58,0,0,1-1.91.19C10.86,23.76,9,20.6,9,14.47s1.91-9.3,6.23-9.3,6.32,3.16,6.32,9.3A20.68,20.68,0,0,1,20.83,20.41Z"></path></svg>`
},
"24": {
metadata: { "moduleName": "LogoQuora24", "filepath": "logo--quora/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": "M29,23.86H27a1.72,1.72,0,0,1-1.73,1.72c-1.15,0-1.82-.86-2.58-2a11,11,0,0,0,4.79-9.1c.09-7.19-5.85-11.89-12.17-11.89S3,7.37,3,14.37,9,26.16,15.17,26.16a10.71,10.71,0,0,0,3.07-.48c1.15,2.11,2.59,3.74,5.46,3.74A5,5,0,0,0,29,23.86Zm-8.14-3.45a6.31,6.31,0,0,0-5.56-3.16,6,6,0,0,0-3.74,1.15L12.2,20a2.56,2.56,0,0,1,.86-.1c1.82,0,3,1.53,4.12,3.64a7.58,7.58,0,0,1-1.91.19C10.86,23.76,9,20.6,9,14.47s1.91-9.3,6.23-9.3,6.32,3.16,6.32,9.3A20.68,20.68,0,0,1,20.83,20.41Z" } }], "name": "logo--quora", "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="M29,23.86H27a1.72,1.72,0,0,1-1.73,1.72c-1.15,0-1.82-.86-2.58-2a11,11,0,0,0,4.79-9.1c.09-7.19-5.85-11.89-12.17-11.89S3,7.37,3,14.37,9,26.16,15.17,26.16a10.71,10.71,0,0,0,3.07-.48c1.15,2.11,2.59,3.74,5.46,3.74A5,5,0,0,0,29,23.86Zm-8.14-3.45a6.31,6.31,0,0,0-5.56-3.16,6,6,0,0,0-3.74,1.15L12.2,20a2.56,2.56,0,0,1,.86-.1c1.82,0,3,1.53,4.12,3.64a7.58,7.58,0,0,1-1.91.19C10.86,23.76,9,20.6,9,14.47s1.91-9.3,6.23-9.3,6.32,3.16,6.32,9.3A20.68,20.68,0,0,1,20.83,20.41Z"></path></svg>`
},
"20": {
metadata: { "moduleName": "LogoQuora20", "filepath": "logo--quora/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": "M29,23.86H27a1.72,1.72,0,0,1-1.73,1.72c-1.15,0-1.82-.86-2.58-2a11,11,0,0,0,4.79-9.1c.09-7.19-5.85-11.89-12.17-11.89S3,7.37,3,14.37,9,26.16,15.17,26.16a10.71,10.71,0,0,0,3.07-.48c1.15,2.11,2.59,3.74,5.46,3.74A5,5,0,0,0,29,23.86Zm-8.14-3.45a6.31,6.31,0,0,0-5.56-3.16,6,6,0,0,0-3.74,1.15L12.2,20a2.56,2.56,0,0,1,.86-.1c1.82,0,3,1.53,4.12,3.64a7.58,7.58,0,0,1-1.91.19C10.86,23.76,9,20.6,9,14.47s1.91-9.3,6.23-9.3,6.32,3.16,6.32,9.3A20.68,20.68,0,0,1,20.83,20.41Z" } }], "name": "logo--quora", "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="M29,23.86H27a1.72,1.72,0,0,1-1.73,1.72c-1.15,0-1.82-.86-2.58-2a11,11,0,0,0,4.79-9.1c.09-7.19-5.85-11.89-12.17-11.89S3,7.37,3,14.37,9,26.16,15.17,26.16a10.71,10.71,0,0,0,3.07-.48c1.15,2.11,2.59,3.74,5.46,3.74A5,5,0,0,0,29,23.86Zm-8.14-3.45a6.31,6.31,0,0,0-5.56-3.16,6,6,0,0,0-3.74,1.15L12.2,20a2.56,2.56,0,0,1,.86-.1c1.82,0,3,1.53,4.12,3.64a7.58,7.58,0,0,1-1.91.19C10.86,23.76,9,20.6,9,14.47s1.91-9.3,6.23-9.3,6.32,3.16,6.32,9.3A20.68,20.68,0,0,1,20.83,20.41Z"></path></svg>`
},
"16": {
metadata: { "moduleName": "LogoQuora16", "filepath": "logo--quora/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": "M29,23.86H27a1.72,1.72,0,0,1-1.73,1.72c-1.15,0-1.82-.86-2.58-2a11,11,0,0,0,4.79-9.1c.09-7.19-5.85-11.89-12.17-11.89S3,7.37,3,14.37,9,26.16,15.17,26.16a10.71,10.71,0,0,0,3.07-.48c1.15,2.11,2.59,3.74,5.46,3.74A5,5,0,0,0,29,23.86Zm-8.14-3.45a6.31,6.31,0,0,0-5.56-3.16,6,6,0,0,0-3.74,1.15L12.2,20a2.56,2.56,0,0,1,.86-.1c1.82,0,3,1.53,4.12,3.64a7.58,7.58,0,0,1-1.91.19C10.86,23.76,9,20.6,9,14.47s1.91-9.3,6.23-9.3,6.32,3.16,6.32,9.3A20.68,20.68,0,0,1,20.83,20.41Z" } }], "name": "logo--quora", "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="M29,23.86H27a1.72,1.72,0,0,1-1.73,1.72c-1.15,0-1.82-.86-2.58-2a11,11,0,0,0,4.79-9.1c.09-7.19-5.85-11.89-12.17-11.89S3,7.37,3,14.37,9,26.16,15.17,26.16a10.71,10.71,0,0,0,3.07-.48c1.15,2.11,2.59,3.74,5.46,3.74A5,5,0,0,0,29,23.86Zm-8.14-3.45a6.31,6.31,0,0,0-5.56-3.16,6,6,0,0,0-3.74,1.15L12.2,20a2.56,2.56,0,0,1,.86-.1c1.82,0,3,1.53,4.12,3.64a7.58,7.58,0,0,1-1.91.19C10.86,23.76,9,20.6,9,14.47s1.91-9.3,6.23-9.3,6.32,3.16,6.32,9.3A20.68,20.68,0,0,1,20.83,20.41Z"></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;
LogoQuoraDirective_1.titleIdCounter++;
title.setAttribute("id", `logo-quora-${LogoQuoraDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `logo-quora-${LogoQuoraDirective_1.titleIdCounter}`);
}
}
};
LogoQuoraDirective.titleIdCounter = 0;
LogoQuoraDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], LogoQuoraDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], LogoQuoraDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], LogoQuoraDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], LogoQuoraDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], LogoQuoraDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], LogoQuoraDirective.prototype, "size", void 0);
LogoQuoraDirective = LogoQuoraDirective_1 = __decorate([
Directive({
selector: "[ibmIconLogoQuora]"
}),
__metadata("design:paramtypes", [ElementRef])
], LogoQuoraDirective);
let LogoQuoraModule = class LogoQuoraModule {
};
LogoQuoraModule = __decorate([
NgModule({
declarations: [
LogoQuoraComponent,
LogoQuoraDirective,
],
exports: [
LogoQuoraComponent,
LogoQuoraDirective,
]
})
], LogoQuoraModule);
export { LogoQuoraComponent, LogoQuoraDirective, LogoQuoraModule };