Skip to content

Commit

Permalink
fix lint on es-button
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Apr 20, 2020
1 parent 6dec76c commit 0eb219f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions addon/components/es-button.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';

export default class EsButtonComponent extends Component {
// default value
_onClicked = () => {};
_type = "button";

constructor() {
super(...arguments);
Expand All @@ -14,8 +16,16 @@ export default class EsButtonComponent extends Component {
} else {
this._onClicked = this.args.onClicked;
}

if(!this.args.type) {
// eslint-disable-next-line no-console
console.warn(new Error('Button created with no @type defined - defaulting to `type="button"`'));
} else {
this._type = this.args.type;
}
}

@action
buttonClicked() {
this._onClicked();
}
Expand Down
5 changes: 3 additions & 2 deletions addon/templates/components/es-button.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<button
class={{if @secondary "es-button-secondary" "es-button"}}
aria-label={{@label}}
onclick={{action this.buttonClicked}}
type={{this._type}}
...attributes
{{on "click" this.buttonClicked}}
>
{{#if hasBlock}}
{{yield}}
{{else}}
{{@label}}
{{/if}}
</button>
</button>

0 comments on commit 0eb219f

Please sign in to comment.