Skip to content

Commit 3022ea9

Browse files
feat(addon/components/paper-card-actions): migrates to tagless native class.
1 parent 1dd71e0 commit 3022ea9

File tree

3 files changed

+65
-17
lines changed

3 files changed

+65
-17
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
{{yield (hash
2-
icons=(component "paper-card-icon-actions")
3-
)}}
1+
<md-card-actions class={{this.classes}} ...attributes>
2+
{{yield (hash
3+
icons=(component "paper-card-icon-actions")
4+
)}}
5+
</md-card-actions>
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable ember/no-classic-components, ember/no-component-lifecycle-hooks, ember/require-tagless-components */
1+
/* eslint-disable ember/no-classic-components */
22
/**
33
* @module ember-paper
44
*/
@@ -8,19 +8,18 @@ import Component from '@ember/component';
88
* @class PaperCardActions
99
* @extends Ember.Component
1010
*/
11-
export default Component.extend({
12-
tagName: 'md-card-actions',
13-
classNameBindings: ['defaultClasses'],
14-
15-
didReceiveAttrs() {
16-
this._super(...arguments);
11+
export default class PaperCardActions extends Component {
12+
tagName = '';
1713

14+
get classes() {
1815
// if the consumer didn't set layout classes, we should set them
1916
// to the default (layout = row, layout align = end center)
2017
let providedClasses = this['class'];
2118

2219
if (!providedClasses || providedClasses.indexOf('layout-') === -1) {
23-
this.set('defaultClasses', 'layout-row layout-align-end-center');
20+
return `layout-row layout-align-end-center ${providedClasses}`.trimEnd();
2421
}
25-
},
26-
});
22+
23+
return providedClasses;
24+
}
25+
}

tests/integration/components/paper-card-test.js

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
/* eslint-disable prettier/prettier */
21
import { module, test } from 'qunit';
32
import { setupRenderingTest } from 'ember-qunit';
43
import { render } from '@ember/test-helpers';
54
import hbs from 'htmlbars-inline-precompile';
65

7-
module('Integration | Component | paper-card', function(hooks) {
6+
module('Integration | Component | paper-card', function (hooks) {
87
setupRenderingTest(hooks);
98

10-
test('blockless media renders image', async function(assert) {
9+
test('blockless media renders image', async function (assert) {
1110
assert.expect(5);
1211

1312
await render(hbs`
@@ -36,7 +35,7 @@ module('Integration | Component | paper-card', function(hooks) {
3635
assert.dom('img').hasClass('md-media-xl');
3736
});
3837

39-
test('block media renders div with correct class', async function(assert) {
38+
test('block media renders div with correct class', async function (assert) {
4039
assert.expect(1);
4140

4241
await render(hbs`
@@ -62,4 +61,52 @@ module('Integration | Component | paper-card', function(hooks) {
6261

6362
assert.dom('div.md-media-xl').exists({ count: 1 });
6463
});
64+
65+
test('block actions renders tag with default layout classes', async function (assert) {
66+
assert.expect(3);
67+
68+
await render(hbs`
69+
{{#paper-card as |card|}}
70+
{{#card.actions}}
71+
{{#paper-button iconButton=true}}{{paper-icon "favorite"}}{{/paper-button}}
72+
{{/card.actions}}
73+
{{/paper-card}}
74+
`);
75+
76+
assert.dom('md-card-actions').exists({ count: 1 });
77+
assert.dom('md-card-actions').hasClass('layout-row');
78+
assert.dom('md-card-actions').hasClass('layout-align-end-center');
79+
});
80+
81+
test('block actions renders tag with passed through layout classes', async function (assert) {
82+
assert.expect(2);
83+
84+
await render(hbs`
85+
{{#paper-card as |card|}}
86+
{{#card.actions class="layout-column"}}
87+
{{#paper-button iconButton=true}}{{paper-icon "favorite"}}{{/paper-button}}
88+
{{/card.actions}}
89+
{{/paper-card}}
90+
`);
91+
92+
assert.dom('md-card-actions').exists({ count: 1 });
93+
assert.dom('md-card-actions').hasClass('layout-column');
94+
});
95+
96+
test('block actions renders tag with passed through non-layout classes', async function (assert) {
97+
assert.expect(4);
98+
99+
await render(hbs`
100+
{{#paper-card as |card|}}
101+
{{#card.actions class="call-to-action"}}
102+
{{#paper-button iconButton=true}}{{paper-icon "favorite"}}{{/paper-button}}
103+
{{/card.actions}}
104+
{{/paper-card}}
105+
`);
106+
107+
assert.dom('md-card-actions').exists({ count: 1 });
108+
assert.dom('md-card-actions').hasClass('layout-row');
109+
assert.dom('md-card-actions').hasClass('layout-align-end-center');
110+
assert.dom('md-card-actions').hasClass('call-to-action');
111+
});
65112
});

0 commit comments

Comments
 (0)