Cyber, заюззай вебпак и все.
Вот пример моего компонента на Vue.
'use strict';
/*!
* TravelChat Client
* Released under the FSFUL license
*/
import iData from '../i-data/i-data';
import keyCodes from '../../core/keyCodes';
import * as tpls from './b-button.ss';
import { model } from '../../core/block';
import { wait } from '../i-block/i-block';
@model(tpls)
export default class bButton extends iData {
/**
* Button type
*/
type: string = 'button';
/**
* Connected form id
*/
form: ?string;
/**
* Icon before text
*/
preIcon: ?string;
/**
* Icon after text
*/
icon: ?string;
/**
* Tooltip text
*/
hint: ?string;
/**
* Tooltip position
*/
hintPos: ?string;
/** @override */
static mods = {
rounding: [
'none',
['small'],
'normal',
'big'
],
width: [
['normal'],
'full'
],
opened: [
'true',
['false']
]
};
/**
* Opens the dropdown
*/
@wait('loading')
open() {
if (this.$slots.dropdown && this.setMod('opened', true)) {
this.emit('open');
}
}
/**
* Closes the dropdown
*/
@wait('loading')
close() {
if (this.$slots.dropdown && this.setMod('opened', false)) {
this.emit('close');
}
}
/**
* Toggles the dropdown
*/
toggle() {
this.ifSomeMod(['opened'], true) ? this.close() : this.open();
}
}