Skip to content

CrateSidebar: Extract tomlSnippet property #3261

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 1 commit into from
Feb 22, 2021
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
6 changes: 3 additions & 3 deletions app/components/crate-sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
<p local-class="copy-help">Add the following line to your Cargo.toml file:</p>
{{#if (is-clipboard-supported)}}
<CopyButton
@copyText='{{@crate.name}} = "{{@version.num}}"'
@copyText={{this.tomlSnippet}}
title="Copy Cargo.toml snippet to clipboard"
local-class="copy-button"
>
<span>{{@crate.name}} = "{{@version.num}}"</span>
<span>{{this.tomlSnippet}}</span>
{{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}}
</CopyButton>
{{else}}
<code local-class="copy-fallback">
{{@crate.name}} = "{{@version.num}}"
{{this.tomlSnippet}}
</code>
{{/if}}
</div>
Expand Down
4 changes: 4 additions & 0 deletions app/components/crate-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ export default class DownloadGraph extends Component {
}

@gt('sortedVersions.length', NUM_VERSIONS) hasMoreVersions;

get tomlSnippet() {
return `${this.args.crate.name} = "${this.args.version.num}"`;
}
}