mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 16:53:44 +08:00
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:
parent
e9ea5124da
commit
aebc6164fc
|
@ -1,8 +1,11 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
|
import discourseDebounce from "discourse-common/lib/debounce";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: "",
|
tagName: "",
|
||||||
|
copyIcon: "copy",
|
||||||
|
copyClass: "btn-primary",
|
||||||
|
|
||||||
@action
|
@action
|
||||||
copy() {
|
copy() {
|
||||||
|
@ -14,6 +17,17 @@ export default Component.extend({
|
||||||
if (this.copied) {
|
if (this.copied) {
|
||||||
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) {}
|
} catch (err) {}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -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
|
@action
|
||||||
onChangeUsers(usernames) {
|
onChangeUsers(usernames) {
|
||||||
this.set("users", usernames.uniq());
|
this.set("users", usernames.uniq());
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{{d-button class="btn-default" icon="copy" action=(action "copy")}}
|
{{d-button class=copyClass icon=copyIcon action=(action "copy")}}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
value=topicUrl
|
value=topicUrl
|
||||||
readonly=true
|
readonly=true
|
||||||
}}
|
}}
|
||||||
{{copy-button selector="input.invite-link" copied=(action "copied")}}
|
{{copy-button selector="input.invite-link"}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user