Skip to content

Commit

Permalink
run tagless-ember-components-codemod
Browse files Browse the repository at this point in the history
This is the result of running the tagless-ember-components-codemod
against Ember Bootstrap.

The following open pull request have been merged in before:

- Support native classes: ember-codemods/tagless-ember-components-codemod#44
- Support component with event handlers: ember-codemods/tagless-ember-components-codemod#52
- Support aria role for native classes: ember-codemods/tagless-ember-components-codemod#56

Steps:
  mv addon/templates/components/common addon/templates/components/base
  npx jelhan/tagless-ember-components-codemod#merged-native-class-support
  mv addon/templates/components/base addon/templates/components/common
  • Loading branch information
jelhan committed Jan 23, 2020
1 parent e81f167 commit 20bf6b0
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 54 deletions.
4 changes: 2 additions & 2 deletions addon/components/base/bs-accordion.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { action } from '@ember/object';
import { layout as templateLayout } from '@ember-decorators/component';
import { layout as templateLayout, tagName } from '@ember-decorators/component';
import Component from '@ember/component';
import layout from 'ember-bootstrap/templates/components/bs-accordion';
import listenTo from 'ember-bootstrap/utils/cp/listen-to';
Expand Down Expand Up @@ -36,7 +36,7 @@ import defaultValue from 'ember-bootstrap/utils/default-decorator';
@extends Ember.Component
@public
*/
@templateLayout(layout)
@tagName("")
export default class Accordion extends Component {
@defaultValue
ariaRole = 'tablist';
Expand Down
4 changes: 2 additions & 2 deletions addon/components/base/bs-form/element/help-text.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { layout as templateLayout } from '@ember-decorators/component';
import { layout as templateLayout, tagName } from '@ember-decorators/component';
import Component from '@ember/component';
import layout from 'ember-bootstrap/templates/components/bs-form/element/help-text';

Expand All @@ -9,5 +9,5 @@ import layout from 'ember-bootstrap/templates/components/bs-form/element/help-te
@extends Ember.Component
@private
*/
@templateLayout(layout)
@tagName("")
export default class FormElementHelpText extends Component {}
4 changes: 2 additions & 2 deletions addon/components/base/bs-form/group.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { layout as templateLayout } from '@ember-decorators/component';
import { layout as templateLayout, tagName } from '@ember-decorators/component';
import { notEmpty } from '@ember/object/computed';
import Component from '@ember/component';
import layout from 'ember-bootstrap/templates/components/bs-form/group';
Expand All @@ -25,7 +25,7 @@ import layout from 'ember-bootstrap/templates/components/bs-form/group';
@extends Ember.Component
@public
*/
@templateLayout(layout)
@tagName("")
export default class FormGroup extends Component {
/**
* @property classTypePrefix
Expand Down
5 changes: 2 additions & 3 deletions addon/components/base/bs-modal/body.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classNames, layout as templateLayout } from '@ember-decorators/component';
import { layout as templateLayout, tagName } from '@ember-decorators/component';
import Component from '@ember/component';
import layout from 'ember-bootstrap/templates/components/bs-modal/body';

Expand All @@ -11,6 +11,5 @@ import layout from 'ember-bootstrap/templates/components/bs-modal/body';
@extends Ember.Component
@public
*/
@templateLayout(layout)
@classNames('modal-body')
@tagName("")
export default class ModalBody extends Component {}
10 changes: 5 additions & 5 deletions addon/components/base/bs-modal/footer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { classNames, layout as templateLayout, tagName } from '@ember-decorators/component';
import { action } from "@ember/object";
import { layout as templateLayout, tagName } from '@ember-decorators/component';
import { notEmpty } from '@ember/object/computed';
import Component from '@ember/component';
import layout from 'ember-bootstrap/templates/components/bs-modal/footer';
Expand All @@ -13,9 +14,7 @@ import defaultValue from 'ember-bootstrap/utils/default-decorator';
@extends Ember.Component
@public
*/
@templateLayout(layout)
@tagName('form')
@classNames('modal-footer')
@tagName("")
export default class ModalFooter extends Component {
/**
* The title of the default close button. Will be ignored (i.e. no close button) if you provide your own block
Expand Down Expand Up @@ -84,7 +83,8 @@ export default class ModalFooter extends Component {
* @public
*/

submit(e) {
@action
handleSubmit(e) {
e.preventDefault();
// send to parent bs-modal component
this.get('onSubmit')();
Expand Down
11 changes: 5 additions & 6 deletions addon/components/base/bs-modal/header/close.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { attributeBindings, classNames, layout as templateLayout, tagName } from '@ember-decorators/component';
import { action } from "@ember/object";
import { layout as templateLayout, tagName } from '@ember-decorators/component';
import Component from '@ember/component';
import layout from 'ember-bootstrap/templates/components/bs-modal/header/close';
import defaultValue from 'ember-bootstrap/utils/default-decorator';
Expand All @@ -10,10 +11,7 @@ import defaultValue from 'ember-bootstrap/utils/default-decorator';
@extends Ember.Component
@private
*/
@templateLayout(layout)
@tagName('button')
@classNames('close')
@attributeBindings('type', 'aria-label')
@tagName("")
export default class ModalHeaderClose extends Component {
'aria-label' = 'Close';

Expand All @@ -27,7 +25,8 @@ export default class ModalHeaderClose extends Component {
onClick() {
}

click() {
@action
handleClick() {
this.get('onClick')();
}
}
6 changes: 2 additions & 4 deletions addon/components/base/bs-modal/header/title.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classNames, layout as templateLayout, tagName } from '@ember-decorators/component';
import { layout as templateLayout, tagName } from '@ember-decorators/component';
import Component from '@ember/component';
import layout from 'ember-bootstrap/templates/components/bs-modal/header/title';

Expand All @@ -9,7 +9,5 @@ import layout from 'ember-bootstrap/templates/components/bs-modal/header/title';
@extends Ember.Component
@private
*/
@templateLayout(layout)
@tagName('h4')
@classNames('modal-title')
@tagName("")
export default class ModalHeaderTitle extends Component {}
5 changes: 2 additions & 3 deletions addon/components/base/bs-progress.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classNames, layout as templateLayout } from '@ember-decorators/component';
import { layout as templateLayout, tagName } from '@ember-decorators/component';
import Component from '@ember/component';
import layout from 'ember-bootstrap/templates/components/bs-progress';
import defaultValue from 'ember-bootstrap/utils/default-decorator';
Expand Down Expand Up @@ -36,8 +36,7 @@ import defaultValue from 'ember-bootstrap/utils/default-decorator';
@extends Ember.Component
@public
*/
@templateLayout(layout)
@classNames('progress')
@tagName("")
export default class Progress extends Component {
/**
* @property progressBarComponent
Expand Down
14 changes: 8 additions & 6 deletions addon/templates/components/common/bs-accordion.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{yield
(hash
item=(component this.itemComponent selected=this.isSelected onClick=this.doChange)
change=this.doChange
)
}}
<div ...attributes>
{{yield
(hash
item=(component this.itemComponent selected=this.isSelected onClick=this.doChange)
change=this.doChange
)
}}
</div>
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{{@text}}
<div ...attributes>
{{@text}}
</div>
10 changes: 6 additions & 4 deletions addon/templates/components/common/bs-form/group.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{yield}}
{{#if this.hasFeedback}}
<span class="form-control-feedback {{this.iconName}}" aria-hidden="true"></span>
{{/if}}
<div ...attributes>
{{yield}}
{{#if this.hasFeedback}}
<span class="form-control-feedback {{this.iconName}}" aria-hidden="true"></span>
{{/if}}
</div>
4 changes: 3 additions & 1 deletion addon/templates/components/common/bs-modal/body.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{{yield}}
<div class="modal-body" ...attributes>
{{yield}}
</div>
19 changes: 11 additions & 8 deletions addon/templates/components/common/bs-modal/footer.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{{#if hasBlock}}
{{yield}}
{{else}}
{{#if this.hasSubmitButton}}
{{#component this.buttonComponent onClick=@onClose}}{{this.closeTitle}}{{/component}}
{{#component this.buttonComponent type=this.submitButtonType onClick=@onSubmit _disabled=this.submitDisabled}}{{@submitTitle}}{{/component}}
<form class="modal-footer" ...attributes {{on "submit" this.handleSubmit}}>
{{#if hasBlock}}
{{yield}}
{{else}}
{{#component this.buttonComponent type="primary" onClick=@onClose}}{{this.closeTitle}}{{/component}}
{{#if this.hasSubmitButton}}
{{#component this.buttonComponent onClick=@onClose}}{{this.closeTitle}}{{/component}}
{{#component this.buttonComponent type=this.submitButtonType onClick=@onSubmit _disabled=this.submitDisabled}}{{@submitTitle}}{{/component}}
{{else}}
{{#component this.buttonComponent type="primary" onClick=@onClose}}{{this.closeTitle}}{{/component}}
{{/if}}
{{/if}}
{{/if}}

</form>
4 changes: 3 additions & 1 deletion addon/templates/components/common/bs-modal/header/close.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<span aria-hidden="true">&times;</span>
<button type={{this.type}} aria-label={{this.aria-label}} class="close" ...attributes {{on "click" this.handleClick}}>
<span aria-hidden="true">&times;</span>
</button>
5 changes: 4 additions & 1 deletion addon/templates/components/common/bs-modal/header/title.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{{yield}}
<h4 class="modal-title" ...attributes>
{{yield}}

</h4>
13 changes: 8 additions & 5 deletions addon/templates/components/common/bs-progress.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{{yield
(hash
bar=(component this.progressBarComponent)
)
}}
<div class="progress" ...attributes>
{{yield
(hash
bar=(component this.progressBarComponent)
)
}}

</div>

0 comments on commit 20bf6b0

Please sign in to comment.