salix/front/core/components/icon/icon.js

35 lines
773 B
JavaScript
Raw Normal View History

2018-02-10 15:18:01 +00:00
import ngModule from '../../module';
2018-03-01 15:52:35 +00:00
import './style.scss';
2018-02-21 10:41:22 +00:00
class Icon {
constructor($attrs) {
this.$attrs = $attrs;
this._icon = null;
}
set icon(value) {
this._icon = value;
this.drawIcon();
}
get icon() {
return this._icon;
}
drawIcon() {
if (this.icon.startsWith('icon-')) {
this.iconClass = this.icon;
this.iconContent = '';
} else {
this.iconClass = 'material-icons';
this.iconContent = this.icon;
}
}
}
Icon.$inject = ['$attrs'];
2020-07-24 15:46:06 +00:00
ngModule.vnComponent('vnIcon', {
2019-02-20 11:31:08 +00:00
template: '<i class="{{::$ctrl.iconClass}} unselectable">{{::$ctrl.iconContent}}</i>',
2018-02-21 10:41:22 +00:00
controller: Icon,
bindings: {
icon: '@'
}
});