UX: Add success state to copy button (#13691)

Replaces the message "Topic link copied" with a more intuitive delayed change of the copy button to a success tick.
This commit is contained in:
Kris 2021-07-11 20:47:24 -04:00 committed by GitHub
parent e9ea5124da
commit aebc6164fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 10 deletions

View File

@ -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",
@action
copy() {
@ -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) {}
},
});

View File

@ -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",
});
},
@action
onChangeUsers(usernames) {
this.set("users", usernames.uniq());

View File

@ -1 +1 @@
{{d-button class="btn-default" icon="copy" action=(action "copy")}}
{{d-button class=copyClass icon=copyIcon action=(action "copy")}}

View File

@ -9,7 +9,7 @@
value=topicUrl
readonly=true
}}
{{copy-button selector="input.invite-link" copied=(action "copied")}}
{{copy-button selector="input.invite-link"}}
</div>
</div>