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>
|
||||
*[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>
|
|
@ -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: '@?'
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
vn-button {
|
||||
& i {
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue