Skip to content

Commit 900fcb7

Browse files
committed
import-example: update to glimmer
Let's update the ImportExample component to extend glimmer/component instead of ember/component. Glimmer components offer a bunch of various advantages over classic components and are the direction that ember is heading in general.
1 parent e4675f1 commit 900fcb7

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/templates/components/import-example.hbs renamed to app/components/import-example.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{{#if this.showClipboardSuccessIcon}}
66
{{svg-jar "success" width="24px" height="24px"}}
77
{{else}}
8-
<CopyButton @clipboardText={{concat "import " this.item " from '" this.package "';"}} @title="Copy to clipboard" @success={{action "showSuccess"}}>
8+
<CopyButton @clipboardText={{concat "import " @item " from '" @package "';"}} @title="Copy to clipboard" @success={{this.showSuccess}}>
99
{{svg-jar "copy" width="24px" height="24px"}}
1010
</CopyButton>
1111
{{/if}}
@@ -14,7 +14,7 @@
1414
<table class="CodeRay">
1515
<tbody>
1616
<tr>
17-
<td class="code"><pre><span class="wrapper"><span class="keyword">import</span> {{item}} <span class="keyword">from</span> <span class="string">'{{this.package}}'</span>;</span></pre></td>
17+
<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>
1818
</tr>
1919
</tbody>
2020
</table>

app/components/import-example.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
/* eslint-disable ember/classic-decorator-no-classic-methods */
21
import { action } from '@ember/object';
3-
import Component from '@ember/component';
2+
import Component from '@glimmer/component';
43
import { later } from '@ember/runloop';
4+
import { tracked } from '@glimmer/tracking';
55

66
export default class ImportExample extends Component {
7+
@tracked showClipboardSuccessIcon = false;
8+
79
@action
810
showSuccess() {
9-
this.toggleProperty('showClipboardSuccessIcon');
10-
later(this, () => this.toggleProperty('showClipboardSuccessIcon'), 950);
11+
this.showClipboardSuccessIcon = true;
12+
later(this, () => (this.showClipboardSuccessIcon = false), 950);
1113
}
1214
}

0 commit comments

Comments
 (0)