@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
177 lines (172 loc) • 10.4 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('/core'), require('@carbon/icon-helpers')) :
typeof define === 'function' && define.amd ? define(['exports', 'tslib', '/core', '@carbon/icon-helpers'], factory) :
(global = global || self, factory((global.CarbonIconsAngular = global.CarbonIconsAngular || {}, global.CarbonIconsAngular.Play = {}), global.tslib, global.ng.core, global.CarbonIconHelpers));
}(this, (function (exports, tslib, core, iconHelpers) { 'use strict';
var PlayComponent = /** @class */ (function () {
function PlayComponent() {
this.focusable = false;
}
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], PlayComponent.prototype, "ariaLabel", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], PlayComponent.prototype, "ariaLabelledby", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", Boolean)
], PlayComponent.prototype, "ariaHidden", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], PlayComponent.prototype, "title", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", Boolean)
], PlayComponent.prototype, "focusable", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], PlayComponent.prototype, "innerClass", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], PlayComponent.prototype, "size", void 0);
PlayComponent = tslib.__decorate([
core.Component({
selector: "ibm-icon-play",
template: "\n <svg\n ibmIconPlay\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 "
})
], PlayComponent);
return PlayComponent;
}());
var PlayDirective = /** @class */ (function () {
function PlayDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Play32", "filepath": "play/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": "M7,28a1,1,0,0,1-1-1V5a1,1,0,0,1,.5-.87,1,1,0,0,1,1,0l19,11a1,1,0,0,1,0,1.74l-19,11A1,1,0,0,1,7,28ZM8,6.73V25.27L24,16Z" } }], "name": "play", "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=\"M7,28a1,1,0,0,1-1-1V5a1,1,0,0,1,.5-.87,1,1,0,0,1,1,0l19,11a1,1,0,0,1,0,1.74l-19,11A1,1,0,0,1,7,28ZM8,6.73V25.27L24,16Z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Play24", "filepath": "play/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": "M7,28a1,1,0,0,1-1-1V5a1,1,0,0,1,.5-.87,1,1,0,0,1,1,0l19,11a1,1,0,0,1,0,1.74l-19,11A1,1,0,0,1,7,28ZM8,6.73V25.27L24,16Z" } }], "name": "play", "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=\"M7,28a1,1,0,0,1-1-1V5a1,1,0,0,1,.5-.87,1,1,0,0,1,1,0l19,11a1,1,0,0,1,0,1.74l-19,11A1,1,0,0,1,7,28ZM8,6.73V25.27L24,16Z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Play20", "filepath": "play/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": "M7,28a1,1,0,0,1-1-1V5a1,1,0,0,1,.5-.87,1,1,0,0,1,1,0l19,11a1,1,0,0,1,0,1.74l-19,11A1,1,0,0,1,7,28ZM8,6.73V25.27L24,16Z" } }], "name": "play", "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=\"M7,28a1,1,0,0,1-1-1V5a1,1,0,0,1,.5-.87,1,1,0,0,1,1,0l19,11a1,1,0,0,1,0,1.74l-19,11A1,1,0,0,1,7,28ZM8,6.73V25.27L24,16Z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Play16", "filepath": "play/16.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 16 16", "fill": "currentColor", "width": 16, "height": 16 }, "content": [{ "elem": "path", "attrs": { "d": "M3.5,14C3.2,14,3,13.8,3,13.5v-11c0-0.2,0.1-0.3,0.2-0.4C3.4,2,3.6,2,3.8,2.1l9.5,5.5c0.2,0.1,0.3,0.4,0.2,0.7\tc0,0.1-0.1,0.1-0.2,0.2l-9.5,5.5C3.7,14,3.6,14,3.5,14z M4,3.4v9.3L12,8L4,3.4z" } }], "name": "play", "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 16 16\" aria-hidden=\"true\"><path d=\"M3.5,14C3.2,14,3,13.8,3,13.5v-11c0-0.2,0.1-0.3,0.2-0.4C3.4,2,3.6,2,3.8,2.1l9.5,5.5c0.2,0.1,0.3,0.4,0.2,0.7\tc0,0.1-0.1,0.1-0.2,0.2l-9.5,5.5C3.7,14,3.6,14,3.5,14z M4,3.4v9.3L12,8L4,3.4z\"></path></svg>"
},
};
}
PlayDirective_1 = PlayDirective;
PlayDirective.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 = iconHelpers.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;
PlayDirective_1.titleIdCounter++;
title.setAttribute("id", "play-" + PlayDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "play-" + PlayDirective_1.titleIdCounter);
}
};
var PlayDirective_1;
PlayDirective.titleIdCounter = 0;
PlayDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], PlayDirective.prototype, "ariaLabel", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], PlayDirective.prototype, "ariaLabelledby", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", Boolean)
], PlayDirective.prototype, "ariaHidden", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], PlayDirective.prototype, "title", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", Boolean)
], PlayDirective.prototype, "isFocusable", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], PlayDirective.prototype, "size", void 0);
PlayDirective = PlayDirective_1 = tslib.__decorate([
core.Directive({
selector: "[ibmIconPlay]"
}),
tslib.__metadata("design:paramtypes", [core.ElementRef])
], PlayDirective);
return PlayDirective;
}());
var PlayModule = /** @class */ (function () {
function PlayModule() {
}
PlayModule = tslib.__decorate([
core.NgModule({
declarations: [
PlayComponent,
PlayDirective,
],
exports: [
PlayComponent,
PlayDirective,
]
})
], PlayModule);
return PlayModule;
}());
exports.PlayComponent = PlayComponent;
exports.PlayDirective = PlayDirective;
exports.PlayModule = PlayModule;
Object.defineProperty(exports, '__esModule', { value: true });
})));