File size: 2,007 Bytes
f2db836
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// ---------------------------------------------------------------------------
// ui/Busy.tsx — WAVE 37 · T05. The in-flight label for a write control.
//
// ⛔ THE DEFECT THIS EXISTS FOR IS NOT "there was no feedback". It is that the
// feedback was INDISTINGUISHABLE FROM NOTHING TO DO. Every write control in
// `settings/` carried `disabled={busy}` and nothing else — and the same controls
// also carry `disabled={!dirty}`, `disabled={!accountDirty}`, `disabled={!canCopy}`,
// `disabled={pw.length === 0}`. So a greyed button mid-save looks exactly like a
// greyed button with nothing to save. The owner's words for that: "left on the
// same pane wondering".
//
// ⭐ THE PATTERN IS NOT NEW, WHICH IS THE POINT. `account/FeedbackPage.tsx` has
// swapped its icon for `<span className="lp-spin" role="status">` while sending
// since wave 35, and `settings/SettingsModal.tsx`'s own connector card already
// renders `{form.busy ? "Saving…" : "Save key"}`. Two correct precedents, in two
// files, and neither reached the account controls beside them. This is the third
// copy — so it is the one that becomes a component instead.
//
// ⚠ SPINNER *AND* LABEL, not either alone. A spinner says "something is
// happening"; the label says WHICH something, which is what a person who clicked
// two controls in five seconds actually needs.
//
// ⚠ `role="status"` on the spinner and `aria-label={doing}` — a screen reader
// announces the state change rather than hearing a button silently become
// disabled. The visible label carries the same word, so the two agree.
// ---------------------------------------------------------------------------

/** `<Busy busy={busy} idle="Save access" doing="Saving" />` inside a `<button>`. */
export function Busy({ busy, idle, doing }: { busy: boolean; idle: string; doing: string }) {
  return busy ? (
    <>
      <span className="lp-spin set-btn-spin" role="status" aria-label={doing} />
      {doing}
    </>
  ) : (
    <>{idle}</>
  );
}