Skip to content

Commit

Permalink
make import-example use the same code block as markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Jun 25, 2024
1 parent f593a7a commit e0d0bda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
22 changes: 1 addition & 21 deletions app/components/import-example.hbs
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
<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>
<MarkdownToHtml @markdown={{this.markdown}} />
14 changes: 5 additions & 9 deletions app/components/import-example.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { action } from '@ember/object';
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.showClipboardSuccessIcon = true;
later(this, () => (this.showClipboardSuccessIcon = false), 950);
get markdown() {
let md = `\`\`\`js
import ${this.args.item} from '${this.args.package}';
\`\`\``;
return md;
}
}

0 comments on commit e0d0bda

Please sign in to comment.