diff --git a/ui/core/app/components/copyable/index.hbs b/ui/core/app/components/copyable/index.hbs
index 499c4fc43..497e5f2f7 100644
--- a/ui/core/app/components/copyable/index.hbs
+++ b/ui/core/app/components/copyable/index.hbs
@@ -5,18 +5,24 @@
{{did-insert this.register}}
{{will-destroy this.destroy}}
>
-
- {{yield}}
-
+ {{#if this.copied}}
+
+ {{yield}}
+
+ {{else}}
+
+ {{yield}}
+
+ {{/if}}
{{this.copyableButtonText}}
+ @iconOnly={{if this.copied this.successIcon this.actionIcon}}
+ title={{if this.copied this.successText this.actionText}}
+ >{{this.actionText}}
{{else}}
{{yield}}
diff --git a/ui/core/app/components/copyable/index.js b/ui/core/app/components/copyable/index.js
index 010c12758..0801d56b5 100644
--- a/ui/core/app/components/copyable/index.js
+++ b/ui/core/app/components/copyable/index.js
@@ -3,17 +3,22 @@ import ClipboardJS from 'clipboard';
import { action } from '@ember/object';
import { generateComponentID } from 'rose/utilities/component-auto-id';
import { task, timeout } from 'ember-concurrency';
-import { set } from '@ember/object';
import { bind } from '@ember/runloop';
+import { tracked } from '@glimmer/tracking';
export default class CopyableComponent extends Component {
// =attributes
id = generateComponentID();
- icon = 'copy-action';
copyableButtonId = `copyable-button-${this.id}`;
- copyableButtonText = this.args.buttonText;
+
+ actionIcon = 'copy-action';
+ successIcon = 'copy-success';
+ actionText = this.args.buttonText;
+ successText = this.args.acknowledgeText;
+
+ @tracked copied = false;
/**
* A Ember Concurrency-based task that updates copy icon to a success state
@@ -26,11 +31,9 @@ export default class CopyableComponent extends Component {
* @type {Task}
*/
@task(function * () {
- set(this, 'icon', 'copy-success');
- set(this, 'copyableButtonText', this.args.acknowledgeText);
+ this.copied = true;
yield timeout(1000);
- set(this, 'icon', 'copy-action');
- set(this, 'copyableButtonText', this.args.buttonText);
+ this.copied = false;
}).drop() successIconTimer;
// =methods
@@ -58,7 +61,7 @@ export default class CopyableComponent extends Component {
*/
@action
register() {
- if(!this.clipboard) {
+ if (!this.clipboard) {
this.clipboard = new ClipboardJS(`#${this.copyableButtonId}`, {
text: () => this.args.text,
});
diff --git a/ui/core/app/styles/app.scss b/ui/core/app/styles/app.scss
index 052ca77c0..42ad8597c 100644
--- a/ui/core/app/styles/app.scss
+++ b/ui/core/app/styles/app.scss
@@ -100,4 +100,13 @@
position: relative;
top: -2px;
}
+
+ mark {
+ background-color: transparent;
+ animation: fadeBackground 0.75s linear;
+ @keyframes fadeBackground {
+ 0% { background-color: var(--action-subtler-1); }
+ 100% { background-color: transparent; }
+ }
+ }
}