Refactorizacion de buton en componente para Tarea #265 CR: JUAN
This commit is contained in:
parent
024a248797
commit
bf87c3d2ac
|
@ -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>
|
|
@ -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: '@?'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
vn-button {
|
||||||
|
& i {
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue