Skip to content

Commit

Permalink
use a real component for md-tabs-canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
panthony committed Apr 18, 2017
1 parent b69fec8 commit ab32c55
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 13 deletions.
27 changes: 27 additions & 0 deletions addon/components/paper-tabs-canvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @module ember-paper
*/
import Component from 'ember-component';
import computed from 'ember-computed';
import layout from '../templates/components/paper-tabs-canvas';

/**
* @class PaperTabsCanvas
* @extends Component
*/
export default Component.extend({

tagName: 'md-tabs-canvas',

layout,

/* Inherited from {{paper-tabs-wrapper}} */
shouldPaginate: computed.readOnly('parentComponent.shouldPaginate'),
shouldCenterTabs: computed.readOnly('parentComponent.shouldCenterTabs'),

classNameBindings: [
'shouldPaginate:md-paginated',
'shouldCenterTabs:md-center-tabs'
]

});
11 changes: 0 additions & 11 deletions addon/components/paper-tabs-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ export default Component.extend(ChildMixin, {
canPageBack: computed.readOnly('parentComponent.canPageBack'),
canPageForward: computed.readOnly('parentComponent.canPageForward'),

canvasClass: computed('shouldPaginate', 'shouldCenterTabs', function() {
let classes = [];
if (this.get('shouldPaginate')) {
classes.push('md-paginated');
}
if (this.get('shouldCenterTabs')) {
classes.push('md-center-tabs');
}
return classes.join(' ');
}),

actions: {
nextPage() {
if (this.get('canPageForward')) {
Expand Down
1 change: 1 addition & 0 deletions addon/templates/components/paper-tabs-canvas.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{yield}}
4 changes: 2 additions & 2 deletions addon/templates/components/paper-tabs-wrapper.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{{paper-prev-button disabled=(not canPageBack) click=(action "previousPage")}}
{{paper-next-button disabled=(not canPageForward) click=(action "nextPage")}}
{{/if}}
<md-tabs-canvas class={{canvasClass}}>
{{#paper-tabs-canvas parentComponent=parentComponent}}
{{#paper-pagination-wrapper parentComponent=parentComponent}}
{{yield}}
{{/paper-pagination-wrapper}}
</md-tabs-canvas>
{{/paper-tabs-canvas}}
1 change: 1 addition & 0 deletions app/components/paper-tabs-canvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-paper/components/paper-tabs-canvas';
36 changes: 36 additions & 0 deletions tests/integration/components/paper-tabs-canvas-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('paper-tabs-canvas', 'Integration | Component | paper tabs canvas', {
integration: true,
beforeEach() {
this.set('parentComponent', (function() {
return {
wormhole: 'wormhole',
send() {},
registerChild() {},
unregisterChild() {}
};
})());
}
});

test('it add md-paginated to canvas if parentComponent.shouldPaginate is true', function(assert) {
this.set('parentComponent.shouldPaginate', true);

this.render(hbs`{{#paper-tabs-canvas parentComponent=parentComponent}}
block content
{{/paper-tabs-canvas}}`);

assert.ok(this.$('md-tabs-canvas').hasClass('md-paginated'));
});

test('it add md-center-tabs to canvas if parentComponent.shouldCenterTabs is true', function(assert) {
this.set('parentComponent.shouldCenterTabs', true);

this.render(hbs`{{#paper-tabs-canvas parentComponent=parentComponent}}
block content
{{/paper-tabs-canvas}}`);

assert.ok(this.$('md-tabs-canvas').hasClass('md-center-tabs'));
});

0 comments on commit ab32c55

Please sign in to comment.