Refactorizacion de buton en componente para Tarea #265 CR: JUAN

This commit is contained in:
gerard 2018-05-08 09:26:17 +02:00
parent 024a248797
commit bf87c3d2ac
3 changed files with 30 additions and 16 deletions

View File

@ -1,3 +1,7 @@
<button type = "*[typeName]*" class="*[className]*" *[enabled]* translate>
*[label]*
<button type="{{::$ctrl.type}}" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored hfj">
<span translate>{{$ctrl.label}}</span>
<vn-icon
icon="{{::$ctrl.icon}}"
class="{{::$ctrl.icon}}">
</vn-icon>
</button>

View File

@ -1,17 +1,22 @@
import ngModule from '../../module';
import template from './button.html';
import Input from '../../lib/input';
import './style.scss';
directive.$inject = ['vnTemplate'];
export default function directive(vnTemplate) {
return {
restrict: 'E',
template: (_, $attrs) =>
vnTemplate.get(template, $attrs, {
label: 'Submit',
className: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored',
enabled: 'true',
typeName: 'button'
})
};
export default class Button extends Input {
constructor($element) {
super($element);
this.input = this.element.querySelector('.mdl-button');
}
}
ngModule.directive('vnButton', directive);
Button.$inject = ['$element'];
ngModule.component('vnButton', {
controller: Button,
template: require('./button.html'),
bindings: {
label: '@?',
disabled: '<?',
icon: '@?'
}
});

View File

@ -0,0 +1,5 @@
vn-button {
& i {
margin-top: 6px;
}
}