Skip to content

Update import example component to glimmer #808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/components/import-example.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class='highlight javascript'>
<div class='ribbon'></div>
{{#if (is-clipboard-supported)}}
<div class='import-copy'>
{{#if this.showClipboardSuccessIcon}}
{{svg-jar 'success' width='24px' height='24px'}}
{{else}}
<CopyButton @clipboardText={{concat 'import ' @item " from '" @package "';"}} @title='Copy to clipboard' @success={{this.showSuccess}}>
{{svg-jar 'copy' width='24px' height='24px'}}
</CopyButton>
{{/if}}
</div>
{{/if}}
<table class='CodeRay'>
<tbody>
<tr>
<td class='code'><pre><span class='wrapper'><span class='keyword'>import</span> {{@item}} <span class='keyword'>from</span> <span class='string'>'{{@package}}'</span>;</span></pre></td>
</tr>
</tbody>
</table>
</div>
10 changes: 6 additions & 4 deletions app/components/import-example.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* eslint-disable ember/classic-decorator-no-classic-methods */
import { action } from '@ember/object';
import Component from '@ember/component';
import Component from '@glimmer/component';
import { later } from '@ember/runloop';
import { tracked } from '@glimmer/tracking';

export default class ImportExample extends Component {
@tracked showClipboardSuccessIcon = false;

@action
showSuccess() {
this.toggleProperty('showClipboardSuccessIcon');
later(this, () => this.toggleProperty('showClipboardSuccessIcon'), 950);
this.showClipboardSuccessIcon = true;
later(this, () => (this.showClipboardSuccessIcon = false), 950);
}
}
21 changes: 0 additions & 21 deletions app/templates/components/import-example.hbs

This file was deleted.

4 changes: 2 additions & 2 deletions tests/integration/components/import-example-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ module('Integration | Component | import example', function (hooks) {

test('it renders a class import example', async function (assert) {
await render(
hbs`{{import-example item='Application' package='@ember/application'}}`
hbs`<ImportExample @item='Application' @package='@ember/application'/>`
);
assert.dom('*').hasText("import Application from '@ember/application';");
});

test('it renders a function import example', async function (assert) {
await render(
hbs`{{import-example item='{ uniqBy }' package='@ember/object/computed'}}`
hbs`<ImportExample @item='{ uniqBy }' @package='@ember/object/computed'/>`
);
assert.dom('*').hasText("import { uniqBy } from '@ember/object/computed';");
});
Expand Down