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> <button type="{{::$ctrl.type}}" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored hfj">
*[label]* <span translate>{{$ctrl.label}}</span>
<vn-icon
icon="{{::$ctrl.icon}}"
class="{{::$ctrl.icon}}">
</vn-icon>
</button> </button>

View File

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