import ngModule from '../../module';
import './style.scss';

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'];

ngModule.vnComponent('vnIcon', {
    template: '<i class="{{::$ctrl.iconClass}} unselectable notranslate">{{::$ctrl.iconContent}}</i>',
    controller: Icon,
    bindings: {
        icon: '@'
    }
});