Skip to content

Commit 242302e

Browse files
committed
add w-pulse addon
1 parent f7166cd commit 242302e

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Component from '@ember/component';
2+
import layout from '../templates/components/w-pulse';
3+
import { task } from 'ember-concurrency-decorators';
4+
import { timeout } from "ember-concurrency";
5+
import { later } from '@ember/runloop';
6+
7+
export default class WPulseComponent extends Component {
8+
layout = layout
9+
10+
duration = 3000
11+
12+
didReceiveAttrs() {
13+
this._super(...arguments)
14+
15+
if(this.triggered) this.generatePulseTask.perform()
16+
}
17+
18+
@task
19+
generatePulseTask = function *() {
20+
yield timeout(this.duration)
21+
later(() => this.set('triggered', false))
22+
}
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{#if triggered}}
2+
{{yield}}
3+
{{/if}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from 'ember-w-pack/components/w-pulse';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import { render } from '@ember/test-helpers';
4+
import hbs from 'htmlbars-inline-precompile';
5+
6+
module('Integration | Component | w-pulse', function(hooks) {
7+
setupRenderingTest(hooks);
8+
9+
test('it renders', async function(assert) {
10+
// Set any properties with this.set('myProperty', 'value');
11+
// Handle any actions with this.set('myAction', function(val) { ... });
12+
13+
await render(hbs`<WPulse />`);
14+
15+
assert.equal(this.element.textContent.trim(), '');
16+
17+
// Template block usage:
18+
await render(hbs`
19+
<WPulse>
20+
template block text
21+
</WPulse>
22+
`);
23+
24+
assert.equal(this.element.textContent.trim(), 'template block text');
25+
});
26+
});

0 commit comments

Comments
 (0)