swarm-ui: the terminal message box has a placeholder and a spinner instead of a label and a sent line
The label 'message <agent>' is the input's placeholder (the label stays for screen readers). The send button shows a spinner over its label while the request is pending and keeps its width, and the 'sent' line is gone: the box empties when the message is held. Spinner is a component of its own now, used by the button and the refresh picker.
This commit is contained in:
parent
5eef1f4a3d
commit
c37205e8f5
1 changed files with 103 additions and 51 deletions
|
|
@ -5,6 +5,7 @@
|
|||
// so far; a third reading gets added the day something needs it, not
|
||||
// speculatively.
|
||||
import type { ComponentChildren } from "preact";
|
||||
import { Spinner } from "../spinner/Spinner.js";
|
||||
import "./Button.css";
|
||||
|
||||
export type ButtonVariant = "primary" | "default";
|
||||
|
|
@ -13,6 +14,7 @@ export function Button({
|
|||
variant = "default",
|
||||
type = "button",
|
||||
disabled,
|
||||
busy = false,
|
||||
onClick,
|
||||
describedBy,
|
||||
children,
|
||||
|
|
@ -20,6 +22,10 @@ export function Button({
|
|||
variant?: ButtonVariant;
|
||||
type?: "button" | "submit";
|
||||
disabled?: boolean;
|
||||
/** A request from this button is in flight: a spinner covers the label,
|
||||
* which keeps its space so the button does not change width, and the button
|
||||
* cannot be pressed again. */
|
||||
busy?: boolean;
|
||||
onClick?: (e: Event) => void;
|
||||
/** Id of the element that says why the button is disabled. */
|
||||
describedBy?: string;
|
||||
|
|
@ -27,13 +33,19 @@ export function Button({
|
|||
}) {
|
||||
return (
|
||||
<button
|
||||
class={"ui-button ui-button-" + variant}
|
||||
class={"ui-button ui-button-" + variant + (busy ? " ui-button-busy" : "")}
|
||||
type={type}
|
||||
disabled={disabled}
|
||||
disabled={disabled || busy}
|
||||
aria-busy={busy || undefined}
|
||||
onClick={onClick}
|
||||
aria-describedby={describedBy}
|
||||
>
|
||||
{children}
|
||||
<span class="ui-button-label">{children}</span>
|
||||
{busy ? (
|
||||
<span class="ui-button-spinner">
|
||||
<Spinner />
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue