-
Notifications
You must be signed in to change notification settings - Fork 0
/
icon.js
35 lines (31 loc) · 878 Bytes
/
icon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @classdesc Represents a FabrIcon component.
* @extends FabrCoreComponent
*/
fbr.FabrIcon = class extends fbr.FabrCoreComponent {
constructor() {
super();
this.componentName = "FabrIcon";
this.componentStyleClass = "fabr-icon";
this.selector = "[fabr-icon]";
this.eventMap = {};
this.iconHelper = new fbr.FabrHelperIcon();
this.iconHelper.init(this);
this.iconHelper.setIconsLibraryMaterial();
}
/**
* Render the icon.
* @param {Object} icon - The icon to render.
*/
render(icon) {
const iconName = icon.getAttribute("fabr-icon-name");
if (!iconName) {
// @@@IF NOT BUILD@@@
this.debugger.log(`Icon name not provided.`);
// @@@ENDIF@@@
}
const iconElement = this.iconHelper.new(iconName);
iconElement.classList.add("fabr-icon-element");
icon.appendChild(iconElement);
}
};