A platform for community discussion. Free, open, simple.
UX: Add success state to copy button (#13691)
Krisaebc6164fc98
diff --git a/app/assets/javascripts/discourse/app/components/copy-button.js b/app/assets/javascripts/discourse/app/components/copy-button.jsindex 8eae4c3cdd6..c1b7eb24c89 100644--- a/app/assets/javascripts/discourse/app/components/copy-button.js+++ b/app/assets/javascripts/discourse/app/components/copy-button.js@@ -1,8 +1,11 @@import Component from "@ember/component";import { action } from "@ember/object";+import discourseDebounce from "discourse-common/lib/debounce";export default Component.extend({tagName: "",+ copyIcon: "copy",+ copyClass: "btn-primary",@actioncopy() {@@ -14,6 +17,17 @@ export default Component.extend({if (this.copied) {this.copied();}++ this.set("copyIcon", "check");+ this.set("copyClass", "btn-primary ok");++ discourseDebounce(() => {+ if (this.isDestroying || this.isDestroyed) {+ return;+ }+ this.set("copyIcon", "copy");+ this.set("copyClass", "btn-primary");+ }, 3000);} catch (err) {}},});diff --git a/app/assets/javascripts/discourse/app/controllers/share-topic.js b/app/assets/javascripts/discourse/app/controllers/share-topic.jsindex c4ad16f19b0..7f8d3e2a85f 100644--- a/app/assets/javascripts/discourse/app/controllers/share-topic.js+++ b/app/assets/javascripts/discourse/app/controllers/share-topic.js@@ -39,14 +39,6 @@ export default Controller.extend();},- @action- copied() {- return this.appEvents.trigger("modal-body:flash", {- text: I18n.t("topic.share.copied"),- messageClass: "success",- });- },-@actiononChangeUsers(usernames) {this.set("users", usernames.uniq());diff --git a/app/assets/javascripts/discourse/app/templates/components/copy-button.hbs b/app/assets/javascripts/discourse/app/templates/components/copy-button.hbsindex 7ec679ab938..6a554d97829 100644--- a/app/assets/javascripts/discourse/app/templates/components/copy-button.hbs+++ b/app/assets/javascripts/discourse/app/templates/components/copy-button.hbs@@ -1 +1 @@-{{d-button class="btn-default" icon="copy" action=(action "copy")}}+{{d-button class=copyClass icon=copyIcon action=(action "copy")}}diff --git a/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs b/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbsindex 75f5a312708..4df72979dea 100644--- a/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs+++ b/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs@@ -9,7 +9,7 @@value=topicUrlreadonly=true}}- {{copy-button selector="input.invite-link" copied=(action "copied")}}+ {{copy-button selector="input.invite-link"}}</div></div>