mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
DEV: adds a loading property to d-button (#9072)
Usage: ``` {{d-button icon="times" label="foo.bar" isLoading=true}} ``` Note that a button loading without an icon will shrink text size to prevent button to jump in size. A button while loading is disabled.
This commit is contained in:
@ -54,3 +54,49 @@ componentTest("link-styled button", {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
componentTest("isLoading button", {
|
||||
template: "{{d-button isLoading=isLoading}}",
|
||||
|
||||
beforeEach() {
|
||||
this.set("isLoading", true);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(
|
||||
find("button.is-loading .spinner").length,
|
||||
"it has a spinner showing"
|
||||
);
|
||||
assert.ok(
|
||||
find("button[disabled]").length,
|
||||
"while loading the button is disabled"
|
||||
);
|
||||
|
||||
this.set("isLoading", false);
|
||||
|
||||
assert.notOk(
|
||||
find("button .spinner").length,
|
||||
"it doesn't have a spinner showing"
|
||||
);
|
||||
assert.ok(
|
||||
find("button:not([disabled])").length,
|
||||
"while not loading the button is enabled"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
componentTest("disabled button", {
|
||||
template: "{{d-button disabled=disabled}}",
|
||||
|
||||
beforeEach() {
|
||||
this.set("disabled", true);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(find("button[disabled]").length, "the button is disabled");
|
||||
|
||||
this.set("disabled", false);
|
||||
|
||||
assert.ok(find("button:not([disabled])").length, "the button is enabled");
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user