@gemboss/ui 0.50.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +216 -0
- package/README.md +153 -1
- package/catalog/editor.html +25 -12
- package/catalog/index.html +635 -93
- package/gemboss-ui.css +3 -3
- package/package.json +8 -1
- package/parts/components.css +1 -1
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/assistant/engine-settings-store.ts +95 -0
- package/src/assistant/engine-settings.tsx +106 -0
- package/src/assistant/engine.tsx +98 -31
- package/src/assistant/index.ts +2 -0
- package/src/assistant-engine.css +1 -1
- package/src/auth-extras.css +1 -0
- package/src/auth-footer.css +1 -0
- package/src/auth-footer.tsx +71 -0
- package/src/auth-signin-plain.js +1 -1
- package/src/auth-sso-plain.js +1 -1
- package/src/auth-steps.css +1 -0
- package/src/auth-steps.tsx +179 -0
- package/src/auth.css +1 -1
- package/src/auth.tsx +159 -31
- package/src/dialog.tsx +3 -0
- package/src/editor/color-picker.tsx +183 -0
- package/src/editor/controls.tsx +49 -33
- package/src/editor/index.ts +8 -0
- package/src/editor/picker-grid.tsx +186 -0
- package/src/editor/picker.tsx +275 -0
- package/src/editor/popover.tsx +160 -0
- package/src/editor/swatch.ts +2 -1
- package/src/editor-color.css +1 -0
- package/src/editor-picker-grid.css +1 -0
- package/src/editor-picker.css +1 -0
- package/src/editor-plain.js +1 -1
- package/src/editor-popover.css +1 -0
- package/src/editor.css +1 -1
- package/src/engine-plain.js +1 -1
- package/src/icons.tsx +4 -0
- package/src/index.ts +4 -1
- package/src/theme.tsx +13 -3
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sign-up of several steps on the sign-in screen — @gemboss/ui, unreleased (24/10/2026).
|
|
3
|
+
*
|
|
4
|
+
* Chris's design canvas (24/10/2026) for GemBoss, GemCommunity and GemBoss Affiliates: a sign-up longer than a name and a
|
|
5
|
+
* password is asked ONE QUESTION A STEP, inside the same card. What every step shares is here:
|
|
6
|
+
* - `AuthSteps`: "Step 1 of 3" on the left, the step's name on the right, and a bar with one segment per step, the done
|
|
7
|
+
* and current ones in iris. The segments are a list a screen reader hears ("Account, done", then the current step,
|
|
8
|
+
* marked `aria-current="step"`);
|
|
9
|
+
* - `AuthStepActions`: Back and Continue side by side (no Back on the first step). Continue is the form's submit, so
|
|
10
|
+
* Enter in a field moves on and the browser checks `required` first; on the last step its words say what it sends;
|
|
11
|
+
* - `AuthChoices`: a question answered by picking one card ("You join as": Affiliate / Agency). Each card is a real radio
|
|
12
|
+
* in a label, a title, one line and a small iris note; the chosen one has a 2px ink edge on a light surface;
|
|
13
|
+
* - `AuthChips`: a question answered by picking several (checkboxes in 44px pills).
|
|
14
|
+
*
|
|
15
|
+
* Why not the kit's QuestionCard (question-card.tsx) for the choices: it is a whole card with its own confirm button and
|
|
16
|
+
* a cap of three, drawn from the admin core's --ui-* tokens with an iris selection, for the assistant's questions. These
|
|
17
|
+
* sit inside a form whose button is Continue, on a screen that runs without the core (GemCommunity, Affiliates) and has
|
|
18
|
+
* its own dark mode, so they are drawn from auth.css's --gb-* tokens. The behaviour is QuestionCard's: real inputs, the
|
|
19
|
+
* chosen one found by `:has(:checked)`. Nor `ui-chip` / `ui-create-chip`: those are buttons (aria-pressed) that filter a
|
|
20
|
+
* list in place; a form's answer is a checkbox, which posts with the form and needs no script.
|
|
21
|
+
*
|
|
22
|
+
* Presentational, no state of their own: the surface keeps the step and the answers. Controlled (`value` + `onChange`)
|
|
23
|
+
* or not (`defaultValue`, read from the form on submit). They import auth.css (Continue is its `gb-auth-submit`) and their
|
|
24
|
+
* own entry, auth-steps.css.
|
|
25
|
+
*/
|
|
26
|
+
import "./auth.css";
|
|
27
|
+
import "./auth-steps.css";
|
|
28
|
+
import React from "react";
|
|
29
|
+
|
|
30
|
+
const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean).join(" ");
|
|
31
|
+
|
|
32
|
+
export interface AuthStepsProps {
|
|
33
|
+
/** Each step's short name, in order: "Account", "About you", "Payout". */
|
|
34
|
+
steps: readonly React.ReactNode[];
|
|
35
|
+
/** The step being shown, counted from 1 as it is printed. Clamped into 1..steps.length. */
|
|
36
|
+
step: number;
|
|
37
|
+
/** The words on the left. Default "Step 2 of 3". */
|
|
38
|
+
count?: (step: number, total: number) => React.ReactNode;
|
|
39
|
+
/** The list's name for a screen reader (default "Steps"). */
|
|
40
|
+
label?: string;
|
|
41
|
+
/** Said after a finished step's name (default "done"). */
|
|
42
|
+
doneLabel?: string;
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function AuthSteps({ steps, step, count = (n, total) => `Step ${n} of ${total}`, label = "Steps", doneLabel = "done", className }: AuthStepsProps) {
|
|
47
|
+
const total = steps.length;
|
|
48
|
+
if (!total) return null;
|
|
49
|
+
const now = Math.min(Math.max(Math.round(step) || 1, 1), total);
|
|
50
|
+
return (
|
|
51
|
+
<div className={cx("gb-auth-steps", className)}>
|
|
52
|
+
<p className="gb-auth-steps-head">
|
|
53
|
+
<span>{count(now, total)}</span>
|
|
54
|
+
<span className="gb-auth-steps-name">{steps[now - 1]}</span>
|
|
55
|
+
</p>
|
|
56
|
+
<ol className="gb-auth-steps-bar" aria-label={label}>
|
|
57
|
+
{steps.map((name, i) => (
|
|
58
|
+
<li key={i} className={cx("gb-auth-seg", i + 1 < now && "gb-auth-seg--done")} aria-current={i + 1 === now ? "step" : undefined}>
|
|
59
|
+
<span>{name}{i + 1 < now ? `, ${doneLabel}` : null}</span>
|
|
60
|
+
</li>
|
|
61
|
+
))}
|
|
62
|
+
</ol>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Back and Continue, side by side, at the end of a step's form. Continue is `type="submit"`: the surface moves on in the
|
|
69
|
+
* form's onSubmit. `onBack` left out (the first step): Continue alone, full width, like Sign in.
|
|
70
|
+
*/
|
|
71
|
+
export function AuthStepActions({ onBack, backLabel = "Back", busy, children }: {
|
|
72
|
+
onBack?: () => void;
|
|
73
|
+
backLabel?: React.ReactNode;
|
|
74
|
+
/** While the step is being sent: both buttons off, so it is not sent twice and nobody leaves halfway. */
|
|
75
|
+
busy?: boolean;
|
|
76
|
+
/** Continue's words: "Continue", and on the last step what it does ("Send application"). */
|
|
77
|
+
children: React.ReactNode;
|
|
78
|
+
}) {
|
|
79
|
+
return (
|
|
80
|
+
<div className="gb-auth-actions">
|
|
81
|
+
{onBack ? <button type="button" className="gb-auth-back" onClick={onBack} disabled={busy}>{backLabel}</button> : null}
|
|
82
|
+
<button type="submit" className="gb-auth-submit" disabled={busy}>{children}</button>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** One card of `AuthChoices`. */
|
|
88
|
+
export interface AuthChoiceOption {
|
|
89
|
+
/** What the radio posts and `onChange` carries. Unique in the question. */
|
|
90
|
+
value: string;
|
|
91
|
+
title: React.ReactNode;
|
|
92
|
+
/** One line under the title: what it means. */
|
|
93
|
+
line?: React.ReactNode;
|
|
94
|
+
/** The small iris note: "30% recurring", "From 5 clients". */
|
|
95
|
+
note?: React.ReactNode;
|
|
96
|
+
disabled?: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The radios' value props, controlled or not. */
|
|
100
|
+
const checkedProps = (on: boolean, controlled: boolean) => (controlled ? { checked: on } : { defaultChecked: on });
|
|
101
|
+
|
|
102
|
+
export function AuthChoices({ name, legend, options, value, defaultValue, onChange, required, className }: {
|
|
103
|
+
/** The radios' name: what the form posts. */
|
|
104
|
+
name: string;
|
|
105
|
+
/** The step's question, as the group's legend: "You join as". */
|
|
106
|
+
legend: React.ReactNode;
|
|
107
|
+
options: readonly AuthChoiceOption[];
|
|
108
|
+
/** Controlled: the chosen `value` (with `onChange`). */
|
|
109
|
+
value?: string;
|
|
110
|
+
/** Not controlled: the one chosen at first. */
|
|
111
|
+
defaultValue?: string;
|
|
112
|
+
onChange?: (value: string) => void;
|
|
113
|
+
/** The browser asks for an answer before Continue goes. */
|
|
114
|
+
required?: boolean;
|
|
115
|
+
className?: string;
|
|
116
|
+
}) {
|
|
117
|
+
const controlled = value !== undefined;
|
|
118
|
+
return (
|
|
119
|
+
<fieldset className={cx("gb-auth-choices", className)}>
|
|
120
|
+
<legend className="gb-auth-q">{legend}</legend>
|
|
121
|
+
{options.map((o) => (
|
|
122
|
+
<label className="gb-auth-choice" key={o.value}>
|
|
123
|
+
<input className="gb-auth-choice-input" type="radio" name={name} value={o.value} required={required} disabled={o.disabled}
|
|
124
|
+
{...checkedProps((controlled ? value : defaultValue) === o.value, controlled)}
|
|
125
|
+
onChange={() => onChange?.(o.value)} />
|
|
126
|
+
<span className="gb-auth-choice-text">
|
|
127
|
+
<span className="gb-auth-choice-title">{o.title}</span>
|
|
128
|
+
{o.line ? <span className="gb-auth-choice-line">{o.line}</span> : null}
|
|
129
|
+
{o.note ? <span className="gb-auth-choice-note">{o.note}</span> : null}
|
|
130
|
+
</span>
|
|
131
|
+
</label>
|
|
132
|
+
))}
|
|
133
|
+
</fieldset>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** One pill of `AuthChips`. */
|
|
138
|
+
export interface AuthChipOption {
|
|
139
|
+
value: string;
|
|
140
|
+
label: React.ReactNode;
|
|
141
|
+
disabled?: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function AuthChips({ name, legend, options, value, defaultValue, onChange, className }: {
|
|
145
|
+
/** The checkboxes' name: the form posts one `name=value` per pill ticked. */
|
|
146
|
+
name: string;
|
|
147
|
+
/** The step's question: "Where do you share links?". */
|
|
148
|
+
legend: React.ReactNode;
|
|
149
|
+
options: readonly AuthChipOption[];
|
|
150
|
+
/** Controlled: the ticked values (with `onChange`). */
|
|
151
|
+
value?: readonly string[];
|
|
152
|
+
/** Not controlled: the ones ticked at first. */
|
|
153
|
+
defaultValue?: readonly string[];
|
|
154
|
+
/** Every ticked value after the change, in the pills' order. */
|
|
155
|
+
onChange?: (value: string[]) => void;
|
|
156
|
+
className?: string;
|
|
157
|
+
}) {
|
|
158
|
+
const controlled = value !== undefined;
|
|
159
|
+
const on = controlled ? value : defaultValue ?? [];
|
|
160
|
+
// The set after a change, read from the group itself: the same answer whether React or the browser holds the boxes.
|
|
161
|
+
const changed = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
162
|
+
const box = e.currentTarget.closest("fieldset");
|
|
163
|
+
if (!box || !onChange) return;
|
|
164
|
+
onChange(Array.from(box.querySelectorAll<HTMLInputElement>("input[type=checkbox]"))
|
|
165
|
+
.filter((i) => i.name === name && i.checked).map((i) => i.value));
|
|
166
|
+
};
|
|
167
|
+
return (
|
|
168
|
+
<fieldset className={cx("gb-auth-chips", className)}>
|
|
169
|
+
<legend className="gb-auth-q">{legend}</legend>
|
|
170
|
+
{options.map((o) => (
|
|
171
|
+
<label className="gb-auth-chip" key={o.value}>
|
|
172
|
+
<input className="gb-auth-chip-input" type="checkbox" name={name} value={o.value} disabled={o.disabled}
|
|
173
|
+
{...checkedProps(on.includes(o.value), controlled)} onChange={changed} />
|
|
174
|
+
<span>{o.label}</span>
|
|
175
|
+
</label>
|
|
176
|
+
))}
|
|
177
|
+
</fieldset>
|
|
178
|
+
);
|
|
179
|
+
}
|
package/src/auth.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gb-auth{--gb-surface: #ffffff;--gb-ink: var(--gemboss-text-strong, #1b1c1e);--gb-muted: #6d7175;--gb-line: #e1e3e5;--gb-field-line: #c9cccf;--gb-field-bg: #ffffff;--gb-field-hover: #fafafa;--gb-placeholder: #868b94;--gb-accent: #5661f5;--gb-btn: linear-gradient(120deg, #1b1c1e 0%, #000000 100%);--gb-btn-ink: #ffffff;--gb-wordmark: linear-gradient(120deg, #1b1c1e 0%, #000000 100%);--gb-hover: #f7f7f5;--gb-hover-line: #b9bbc0;--gb-err-bg: #fee2e2;--gb-err-ink: #b91c1c;--gb-err-line: transparent;--gb-card-shadow: 0 24px 64px rgba(15, 23, 42, .08);--gb-mark-bg: #0b0b0c;--gb-facet: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='0.45' stroke-linejoin='round'%3E%3Cpath d='M26,14 74,14 96,50 50,110 4,50Z'/%3E%3Cpath d='M4,50H96M26,14 34,50M74,14 66,50M34,50 50,110M66,50 50,110'/%3E%3C/g%3E%3C/svg%3E");--gb-page: radial-gradient(1200px 600px at 20% 10%, rgba(27, 28, 30, .05), transparent 60%), radial-gradient(1000px 500px at 80% 90%, rgba(86, 97, 245, .06), transparent 60%), #fafafb;--gb-page-flat: #ffffff;--gb-panel-bg: radial-gradient(900px 520px at 78% 12%, rgba(86, 97, 245, .26), transparent 62%), radial-gradient(700px 480px at 12% 96%, rgba(86, 97, 245, .12), transparent 60%), #0b0b0c;--gb-panel-ink: #f4f4f2;--gb-panel-muted: rgba(244, 244, 242, .72);--gb-panel-eyebrow: #8a93ff;--gb-panel-facet-o: .05;--gb-panel-grid-bg: linear-gradient(160deg, #1b1c22 0%, #0b0b0c 72%);--gb-panel-grid-line: rgba(138, 147, 255, .1);--gb-panel-grid-size: 34px;--gb-panel-grid-fade: radial-gradient(90% 80% at 30% 20%, #000, transparent 75%);color-scheme:light dark;position:fixed;top:var(--vvt, 0px);left:0;right:0;height:100vh;height:var(--vvh, 100dvh);container:gb-auth / size;overflow-y:auto;background:var(--gb-page);color:var(--gb-ink);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,system-ui,sans-serif}.gb-auth-split{display:grid;grid-template-columns:1fr;min-height:100%}.gb-auth-stage{box-sizing:border-box;display:flex;min-height:100%;padding:clamp(12px,3cqh,24px) clamp(16px,4vw,24px)}.gb-auth-panel-in{position:relative;box-sizing:border-box;width:100%;max-width:520px;padding:48px clamp(32px,5vw,64px)}.gb-auth-eyebrow{margin:0 0 20px;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:12px;font-weight:500;letter-spacing:.12em;text-transform:uppercase;color:var(--gb-panel-eyebrow)}.gb-auth-panel-h{margin:0 0 16px;font-size:clamp(28px,3.2vw,40px);line-height:1.15;letter-spacing:-.02em;font-weight:700;color:var(--gb-panel-ink)}.gb-auth-panel-p{margin:0;font-size:15px;line-height:1.6;color:var(--gb-panel-muted)}.gb-auth-panel{display:none}@container gb-auth (min-width: 900px) and (min-height: 520px){.gb-auth-split{grid-template-columns:minmax(420px,1fr) minmax(0,1.05fr)}.gb-auth-split .gb-auth-stage{background:var(--gb-surface)}.gb-auth-split .gb-auth-card{border:none;box-shadow:none;max-width:400px}.gb-auth-panel{display:flex;align-items:center;position:relative;overflow:hidden;background:var(--gb-panel-bg);color:var(--gb-panel-ink)}.gb-auth-panel:before{content:"";position:absolute;inset:-45% -38% auto auto;width:132%;aspect-ratio:1;background-image:var(--gb-facet);background-size:contain;background-repeat:no-repeat;opacity:var(--gb-panel-facet-o);pointer-events:none}.gb-auth-split .gb-auth-panel--grid{background:var(--gb-panel-grid-bg)}.gb-auth-panel.gb-auth-panel--grid:before{inset:0;width:auto;aspect-ratio:auto;background-image:linear-gradient(var(--gb-panel-grid-line) 1px,transparent 1px),linear-gradient(90deg,var(--gb-panel-grid-line) 1px,transparent 1px);background-size:var(--gb-panel-grid-size) var(--gb-panel-grid-size);background-repeat:repeat;opacity:1;-webkit-mask-image:var(--gb-panel-grid-fade);mask-image:var(--gb-panel-grid-fade)}.gb-auth-panel.gb-auth-panel--none:before{content:none}}.gb-auth-card{width:100%;max-width:380px;margin:auto;background:var(--gb-surface);border:1px solid var(--gb-line);border-radius:14px;padding:clamp(18px,3.5cqh,28px) 28px;box-shadow:var(--gb-card-shadow)}.gb-auth-header{text-align:center;margin-bottom:clamp(12px,3cqh,24px)}.gb-auth-mark{display:inline-flex;margin-bottom:clamp(6px,calc(6px + (100cqh - 480px)*.075),12px)}.gb-auth-mark svg,.gb-auth-mark img{width:clamp(32px,calc(32px + (100cqh - 480px)*.3),56px);height:clamp(32px,calc(32px + (100cqh - 480px)*.3),56px)}@container gb-auth (max-height: 479.98px){.gb-auth-mark{display:none}}.gb-auth-header h1{font-size:clamp(19px,2.75cqh,22px);font-weight:700;margin:0 0 clamp(0px,calc((100cqh - 560px)*.1),4px);background:var(--gb-wordmark);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}.gb-auth-header p{margin:0;font-size:13px;color:var(--gb-muted)}@container gb-auth (max-height: 599.98px){.gb-auth-header p{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}}.gb-auth-form{display:flex;flex-direction:column;gap:clamp(8px,1.5cqh,12px)}.gb-auth-form label{display:flex;flex-direction:column;gap:clamp(4px,.75cqh,6px);font-size:12px;font-weight:500;color:var(--gb-ink)}.gb-auth-input{box-sizing:border-box;height:32px;min-height:44px;min-width:0;padding:0 12px;font:inherit;font-size:13px;line-height:20px;border:1px solid;border-radius:8px}@media (max-width: 47.9975em){.gb-auth-input{font-size:16px}}@media (pointer: coarse){.gb-auth-input{height:auto}}.gb-auth-form input{width:100%;box-sizing:border-box;background-color:var(--gb-field-bg);border-color:var(--gb-field-line);color:var(--gb-ink)}.gb-auth-form input::placeholder{color:var(--gb-placeholder)}.gb-auth-form input:hover:not(:disabled){background-color:var(--gb-field-hover);border-color:var(--gb-hover-line)}.gb-auth-form input:focus-visible{outline:2px solid var(--gb-ink);outline-offset:1px;border-color:var(--gb-ink)}.gb-auth-field{display:flex;flex-direction:column;gap:clamp(4px,.75cqh,6px);font-size:12px;font-weight:500;color:var(--gb-ink)}.gb-auth-pw{position:relative;display:flex}.gb-auth-pw input{width:100%;padding-right:48px}.gb-auth-pw-toggle{min-height:44px;min-width:44px;position:absolute;right:0;top:0;bottom:0;display:inline-flex;align-items:center;justify-content:center;padding:0;margin:0;background:none;border:none;border-radius:8px;cursor:pointer;color:var(--gb-muted);transition:none}.gb-auth-pw-toggle:hover{color:var(--gb-ink)}.gb-auth-pw-toggle:focus-visible{outline:2px solid var(--gemboss-primary, #1b1c1e);outline-offset:-2px}.gb-auth-error{background:var(--gb-err-bg);border:1px solid var(--gb-err-line);color:var(--gb-err-ink);padding:8px 10px;font-size:13px;border-radius:6px}.gb-auth-form>.gb-auth-submit{margin-top:clamp(2px,.75cqh,6px);min-height:44px;font-size:14px;font-weight:600;border:none;border-radius:8px;background:var(--gb-btn);color:var(--gb-btn-ink);cursor:pointer;font-family:inherit;transition:opacity .15s ease,transform .15s ease}.gb-auth-form>.gb-auth-submit:hover:not(:disabled){transform:translateY(-1px)}.gb-auth-form>.gb-auth-submit:disabled{opacity:.6;cursor:not-allowed}.gb-auth-sso-btn{display:flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:0 16px;border:1px solid var(--gb-field-line);border-radius:8px;background:var(--gb-surface);color:var(--gb-ink);font-size:14px;font-weight:600;text-decoration:none;transition:background .15s,border-color .15s}.gb-auth-sso-btn:hover{background:var(--gb-hover);border-color:var(--gb-hover-line)}.gb-auth-sso-btn:focus-visible{outline:2px solid var(--gb-ink);outline-offset:1px}.gb-auth-sso-why{margin:8px 0 0;font-size:12px;line-height:1.5;color:var(--gb-muted);text-align:center}.gb-auth-sso .gb-auth-or{display:flex;align-items:center;gap:12px;margin:clamp(8px,1.75cqh,14px) 0;color:var(--gb-muted);font-size:12px}.gb-auth-sso .gb-auth-or:before,.gb-auth-sso .gb-auth-or:after{content:"";flex:1;height:1px;background:var(--gb-line)}.gb-auth-foot{margin:clamp(10px,2cqh,16px) 0 0;font-size:13px;color:var(--gb-muted);text-align:center;line-height:1.5}.gb-auth-foot a{display:inline-block;min-height:24px;line-height:24px;padding:0 2px;color:var(--gb-accent);font-weight:600;text-decoration:none}.gb-auth-foot a:hover,.gb-auth-foot a:focus-visible{text-decoration:underline}.gb-auth-card .gb-auth-help{margin:clamp(8px,1.75cqh,14px) 0 0;font-size:12px;color:var(--gb-muted);text-align:center;line-height:1.5}.gb-auth-card .gb-auth-help a{display:inline-block;min-height:24px;line-height:24px;color:var(--gb-accent);font-weight:600;text-decoration:none}.gb-auth-card .gb-auth-help a:hover,.gb-auth-card .gb-auth-help a:focus-visible{text-decoration:underline}@media (max-width: 480px){.gb-auth{background:var(--gb-page-flat)}.gb-auth-stage{padding:max(clamp(10px,3cqh,20px),env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(clamp(10px,3cqh,20px),env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))}.gb-auth-card{border:none;border-radius:0;box-shadow:none;padding:0}}@container gb-auth (max-height: 399.98px){.gb-auth-header{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}}@container gb-auth (max-height: 359.98px){.gb-auth-card .gb-auth-help,.gb-auth-foot{display:none}.gb-auth-stage{padding-top:max(8px,env(safe-area-inset-top));padding-bottom:max(8px,env(safe-area-inset-bottom))}}@container gb-auth (max-height: 359.98px) and (min-width: 481px){.gb-auth-card{padding-top:14px;padding-bottom:14px}}@media (prefers-color-scheme: dark){:root:not([data-theme=light]) .gb-auth{--gb-surface: #141517;--gb-ink: #f4f4f3;--gb-muted: #969c97;--gb-line: rgba(255, 255, 255, .11);--gb-field-line: rgba(255, 255, 255, .17);--gb-field-bg: #1b1c1f;--gb-field-hover: #212226;--gb-placeholder: #7f838c;--gb-accent: #8a93ff;--gb-btn: linear-gradient(120deg, #f4f4f3 0%, #dfe0e4 100%);--gb-btn-ink: #0b0b0c;--gb-wordmark: linear-gradient(120deg, #f4f4f3 0%, #c9cbd2 100%);--gb-hover: rgba(255, 255, 255, .06);--gb-hover-line: rgba(255, 255, 255, .28);--gb-err-bg: rgba(215, 44, 13, .16);--gb-err-ink: #ff9d88;--gb-err-line: rgba(245, 120, 95, .4);--gb-card-shadow: 0 24px 64px rgba(0, 0, 0, .55);--gb-mark-bg: #202127;--gb-page: radial-gradient(1200px 600px at 20% 10%, rgba(255, 255, 255, .05), transparent 60%), radial-gradient(1000px 500px at 80% 90%, rgba(138, 147, 255, .1), transparent 60%), #0b0b0c;--gb-page-flat: #0b0b0c}}:root[data-theme=dark] .gb-auth{--gb-surface: #141517;--gb-ink: #f4f4f3;--gb-muted: #969c97;--gb-line: rgba(255, 255, 255, .11);--gb-field-line: rgba(255, 255, 255, .17);--gb-field-bg: #1b1c1f;--gb-field-hover: #212226;--gb-placeholder: #7f838c;--gb-accent: #8a93ff;--gb-btn: linear-gradient(120deg, #f4f4f3 0%, #dfe0e4 100%);--gb-btn-ink: #0b0b0c;--gb-wordmark: linear-gradient(120deg, #f4f4f3 0%, #c9cbd2 100%);--gb-hover: rgba(255, 255, 255, .06);--gb-hover-line: rgba(255, 255, 255, .28);--gb-err-bg: rgba(215, 44, 13, .16);--gb-err-ink: #ff9d88;--gb-err-line: rgba(245, 120, 95, .4);--gb-card-shadow: 0 24px 64px rgba(0, 0, 0, .55);--gb-mark-bg: #202127;--gb-page: radial-gradient(1200px 600px at 20% 10%, rgba(255, 255, 255, .05), transparent 60%), radial-gradient(1000px 500px at 80% 90%, rgba(138, 147, 255, .1), transparent 60%), #0b0b0c;--gb-page-flat: #0b0b0c}
|
|
1
|
+
.gb-auth{--gb-surface: #ffffff;--gb-ink: var(--gemboss-text-strong, #1b1c1e);--gb-muted: #6d7175;--gb-line: #e1e3e5;--gb-field-line: #c9cccf;--gb-field-bg: #ffffff;--gb-field-hover: #fafafa;--gb-placeholder: #868b94;--gb-accent: #5661f5;--gb-btn: linear-gradient(120deg, #1b1c1e 0%, #000000 100%);--gb-btn-ink: #ffffff;--gb-wordmark: linear-gradient(120deg, #1b1c1e 0%, #000000 100%);--gb-hover: #f7f7f5;--gb-hover-line: #b9bbc0;--gb-err-bg: #fee2e2;--gb-err-ink: #b91c1c;--gb-err-line: transparent;--gb-card-shadow: 0 24px 64px rgba(15, 23, 42, .08);--gb-mark-bg: #0b0b0c;--gb-facet: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='0.45' stroke-linejoin='round'%3E%3Cpath d='M26,14 74,14 96,50 50,110 4,50Z'/%3E%3Cpath d='M4,50H96M26,14 34,50M74,14 66,50M34,50 50,110M66,50 50,110'/%3E%3C/g%3E%3C/svg%3E");--gb-page: radial-gradient(1200px 600px at 20% 10%, rgba(27, 28, 30, .05), transparent 60%), radial-gradient(1000px 500px at 80% 90%, rgba(86, 97, 245, .06), transparent 60%), #fafafb;--gb-page-flat: #ffffff;--gb-panel-bg: radial-gradient(900px 520px at 78% 12%, rgba(86, 97, 245, .26), transparent 62%), radial-gradient(700px 480px at 12% 96%, rgba(86, 97, 245, .12), transparent 60%), #0b0b0c;--gb-panel-ink: #f4f4f2;--gb-panel-muted: rgba(244, 244, 242, .72);--gb-panel-eyebrow: #8a93ff;--gb-panel-facet-o: .05;--gb-panel-grid-bg: linear-gradient(160deg, #1b1c22 0%, #0b0b0c 72%);--gb-panel-grid-line: rgba(138, 147, 255, .1);--gb-panel-grid-size: 34px;--gb-panel-grid-fade: radial-gradient(90% 80% at 30% 20%, #000, transparent 75%);color-scheme:light dark;position:fixed;top:var(--vvt, 0px);left:0;right:0;height:100vh;height:var(--vvh, 100dvh);container:gb-auth / size;overflow-y:auto;background:var(--gb-page);color:var(--gb-ink);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,system-ui,sans-serif}.gb-auth-split{display:grid;grid-template-columns:1fr;min-height:100%}.gb-auth-stage{box-sizing:border-box;display:flex;min-height:100%;padding:clamp(12px,3cqh,24px) clamp(16px,4vw,24px)}.gb-auth-panel-in{position:relative;box-sizing:border-box;width:100%;max-width:520px;padding:48px clamp(32px,5vw,64px)}.gb-auth-eyebrow{margin:0 0 20px;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:12px;font-weight:500;letter-spacing:.12em;text-transform:uppercase;color:var(--gb-panel-eyebrow)}.gb-auth-panel-h{margin:0 0 16px;font-size:clamp(28px,3.2vw,40px);line-height:1.15;letter-spacing:-.02em;font-weight:700;color:var(--gb-panel-ink)}.gb-auth-panel-p{margin:0;font-size:15px;line-height:1.6;color:var(--gb-panel-muted)}.gb-auth-panel{display:none}@container gb-auth (min-width: 900px) and (min-height: 520px){.gb-auth-split{grid-template-columns:minmax(420px,1fr) minmax(0,1.05fr)}.gb-auth-split .gb-auth-stage{background:var(--gb-surface)}.gb-auth-split .gb-auth-card{border:none;box-shadow:none;max-width:400px}.gb-auth-panel{display:flex;align-items:center;position:relative;overflow:hidden;background:var(--gb-panel-bg);color:var(--gb-panel-ink)}.gb-auth-panel:before{content:"";position:absolute;inset:-45% -38% auto auto;width:132%;aspect-ratio:1;background-image:var(--gb-facet);background-size:contain;background-repeat:no-repeat;opacity:var(--gb-panel-facet-o);pointer-events:none}.gb-auth-split .gb-auth-panel--grid{background:var(--gb-panel-grid-bg)}.gb-auth-panel.gb-auth-panel--grid:before{inset:0;width:auto;aspect-ratio:auto;background-image:linear-gradient(var(--gb-panel-grid-line) 1px,transparent 1px),linear-gradient(90deg,var(--gb-panel-grid-line) 1px,transparent 1px);background-size:var(--gb-panel-grid-size) var(--gb-panel-grid-size);background-repeat:repeat;opacity:1;-webkit-mask-image:var(--gb-panel-grid-fade);mask-image:var(--gb-panel-grid-fade)}.gb-auth-panel.gb-auth-panel--none:before{content:none}}.gb-auth-card{width:100%;max-width:380px;margin:auto;background:var(--gb-surface);border:1px solid var(--gb-line);border-radius:14px;padding:clamp(18px,3.5cqh,28px) 28px;box-shadow:var(--gb-card-shadow)}.gb-auth-header{text-align:center;margin-bottom:clamp(12px,3cqh,24px)}.gb-auth-mark{display:inline-flex;margin-bottom:clamp(6px,calc(6px + (100cqh - 480px)*.075),12px)}.gb-auth-mark svg,.gb-auth-mark img{width:clamp(32px,calc(32px + (100cqh - 480px)*.3),56px);height:clamp(32px,calc(32px + (100cqh - 480px)*.3),56px)}@container gb-auth (max-height: 479.98px){.gb-auth-mark{display:none}}.gb-auth-header h1{font-size:clamp(19px,2.75cqh,22px);font-weight:700;margin:0 0 clamp(0px,calc((100cqh - 560px)*.1),4px);background:var(--gb-wordmark);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}.gb-auth-header p{margin:0;font-size:13px;color:var(--gb-muted)}@container gb-auth (max-height: 599.98px){.gb-auth-header p{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}}.gb-auth-form{display:flex;flex-direction:column;gap:clamp(8px,1.5cqh,12px)}.gb-auth-form label{display:flex;flex-direction:column;gap:clamp(4px,.75cqh,6px);font-size:12px;font-weight:500;color:var(--gb-ink)}.gb-auth-input{box-sizing:border-box;height:32px;min-height:44px;min-width:0;padding:0 12px;font:inherit;font-size:13px;line-height:20px;border:1px solid;border-radius:8px}@media (max-width: 47.9975em){.gb-auth-input{font-size:16px}}@media (pointer: coarse){.gb-auth-input{height:auto}}.gb-auth-form input{width:100%;box-sizing:border-box;background-color:var(--gb-field-bg);border-color:var(--gb-field-line);color:var(--gb-ink)}.gb-auth-form input::placeholder{color:var(--gb-placeholder)}.gb-auth-form input:hover:not(:disabled){background-color:var(--gb-field-hover);border-color:var(--gb-hover-line)}.gb-auth-form input:focus-visible{outline:2px solid var(--gb-ink);outline-offset:1px;border-color:var(--gb-ink)}.gb-auth-field{display:flex;flex-direction:column;gap:clamp(4px,.75cqh,6px);font-size:12px;font-weight:500;color:var(--gb-ink)}.gb-auth-pw{position:relative;display:flex}.gb-auth-pw input{width:100%;padding-right:48px}.gb-auth-pw-toggle{min-height:44px;min-width:44px;position:absolute;right:0;top:0;bottom:0;display:inline-flex;align-items:center;justify-content:center;padding:0;margin:0;background:none;border:none;border-radius:8px;cursor:pointer;color:var(--gb-muted);transition:none}.gb-auth-pw-toggle:hover{color:var(--gb-ink)}.gb-auth-pw-toggle:focus-visible{outline:2px solid var(--gemboss-primary, #1b1c1e);outline-offset:-2px}.gb-auth-error{background:var(--gb-err-bg);border:1px solid var(--gb-err-line);color:var(--gb-err-ink);padding:8px 10px;font-size:13px;border-radius:6px}.gb-auth-form>.gb-auth-submit{margin-top:clamp(2px,.75cqh,6px);min-height:44px;font-size:14px;font-weight:600;border:none;border-radius:8px;background:var(--gb-btn);color:var(--gb-btn-ink);cursor:pointer;font-family:inherit;transition:opacity .15s ease,transform .15s ease}.gb-auth-form>.gb-auth-submit:hover:not(:disabled){transform:translateY(-1px)}.gb-auth-form>.gb-auth-submit:disabled{opacity:.6;cursor:not-allowed}.gb-auth-sso-btn{display:flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:0 16px;border:1px solid var(--gb-field-line);border-radius:8px;background:var(--gb-surface);color:var(--gb-ink);font-size:14px;font-weight:600;text-decoration:none;transition:background .15s,border-color .15s}.gb-auth-sso-btn:hover{background:var(--gb-hover);border-color:var(--gb-hover-line)}.gb-auth-sso-btn:focus-visible{outline:2px solid var(--gb-ink);outline-offset:1px}.gb-auth-notice{margin:0 0 12px;padding:8px 10px;border-radius:6px;background:var(--gb-hover);font-size:13px}.gb-auth-sso-why{margin:8px 0 0;font-size:12px;line-height:1.5;color:var(--gb-muted);text-align:center}.gb-auth-sso .gb-auth-or{display:flex;align-items:center;gap:12px;margin:clamp(8px,1.75cqh,14px) 0;color:var(--gb-muted);font-size:12px}.gb-auth-sso .gb-auth-or:before,.gb-auth-sso .gb-auth-or:after{content:"";flex:1;height:1px;background:var(--gb-line)}.gb-auth-foot{margin:clamp(10px,2cqh,16px) 0 0;font-size:13px;color:var(--gb-muted);text-align:center;line-height:1.5}.gb-auth-foot a{display:inline-block;min-height:24px;line-height:24px;padding:0 2px;color:var(--gb-accent);font-weight:600;text-decoration:none}.gb-auth-foot a:hover,.gb-auth-foot a:focus-visible{text-decoration:underline}.gb-auth-card .gb-auth-help{margin:clamp(8px,1.75cqh,14px) 0 0;font-size:12px;color:var(--gb-muted);text-align:center;line-height:1.5}.gb-auth-card .gb-auth-help a{display:inline-block;min-height:24px;line-height:24px;color:var(--gb-accent);font-weight:600;text-decoration:none}.gb-auth-card .gb-auth-help a:hover,.gb-auth-card .gb-auth-help a:focus-visible{text-decoration:underline}@media (max-width: 480px){.gb-auth{background:var(--gb-page-flat)}.gb-auth-stage{padding:max(clamp(10px,3cqh,20px),env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(clamp(10px,3cqh,20px),env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))}.gb-auth-card{border:none;border-radius:0;box-shadow:none;padding:0}}@container gb-auth (max-height: 399.98px){.gb-auth-header{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}}@container gb-auth (max-height: 359.98px){.gb-auth-card .gb-auth-help,.gb-auth-foot{display:none}.gb-auth-stage{padding-top:max(8px,env(safe-area-inset-top));padding-bottom:max(8px,env(safe-area-inset-bottom))}}@container gb-auth (max-height: 359.98px) and (min-width: 481px){.gb-auth-card{padding-top:14px;padding-bottom:14px}}@media (prefers-color-scheme: dark){:root:not([data-theme=light]) .gb-auth{--gb-surface: #141517;--gb-ink: #f4f4f3;--gb-muted: #969c97;--gb-line: rgba(255, 255, 255, .11);--gb-field-line: rgba(255, 255, 255, .17);--gb-field-bg: #1b1c1f;--gb-field-hover: #212226;--gb-placeholder: #7f838c;--gb-accent: #8a93ff;--gb-btn: linear-gradient(120deg, #f4f4f3 0%, #dfe0e4 100%);--gb-btn-ink: #0b0b0c;--gb-wordmark: linear-gradient(120deg, #f4f4f3 0%, #c9cbd2 100%);--gb-hover: rgba(255, 255, 255, .06);--gb-hover-line: rgba(255, 255, 255, .28);--gb-err-bg: rgba(215, 44, 13, .16);--gb-err-ink: #ff9d88;--gb-err-line: rgba(245, 120, 95, .4);--gb-card-shadow: 0 24px 64px rgba(0, 0, 0, .55);--gb-mark-bg: #202127;--gb-page: radial-gradient(1200px 600px at 20% 10%, rgba(255, 255, 255, .05), transparent 60%), radial-gradient(1000px 500px at 80% 90%, rgba(138, 147, 255, .1), transparent 60%), #0b0b0c;--gb-page-flat: #0b0b0c}}:root[data-theme=dark] .gb-auth{--gb-surface: #141517;--gb-ink: #f4f4f3;--gb-muted: #969c97;--gb-line: rgba(255, 255, 255, .11);--gb-field-line: rgba(255, 255, 255, .17);--gb-field-bg: #1b1c1f;--gb-field-hover: #212226;--gb-placeholder: #7f838c;--gb-accent: #8a93ff;--gb-btn: linear-gradient(120deg, #f4f4f3 0%, #dfe0e4 100%);--gb-btn-ink: #0b0b0c;--gb-wordmark: linear-gradient(120deg, #f4f4f3 0%, #c9cbd2 100%);--gb-hover: rgba(255, 255, 255, .06);--gb-hover-line: rgba(255, 255, 255, .28);--gb-err-bg: rgba(215, 44, 13, .16);--gb-err-ink: #ff9d88;--gb-err-line: rgba(245, 120, 95, .4);--gb-card-shadow: 0 24px 64px rgba(0, 0, 0, .55);--gb-mark-bg: #202127;--gb-page: radial-gradient(1200px 600px at 20% 10%, rgba(255, 255, 255, .05), transparent 60%), radial-gradient(1000px 500px at 80% 90%, rgba(138, 147, 255, .1), transparent 60%), #0b0b0c;--gb-page-flat: #0b0b0c}
|
package/src/auth.tsx
CHANGED
|
@@ -12,8 +12,17 @@
|
|
|
12
12
|
* the height ladder that sheds the tagline and the mark on short screens, the keyboard-aware height,
|
|
13
13
|
* the dark theme. Re-theme it by redefining the `--gb-*` tokens on `.gb-auth` (see auth.css), never
|
|
14
14
|
* by restyling its classes.
|
|
15
|
+
*
|
|
16
|
+
* The standard screen (24/10/2026, Chris's design canvas for GemBoss, GemCommunity and GemBoss Affiliates): the card,
|
|
17
|
+
* "Forgot password?" on the Password row (PasswordField `forgot`), a row under the card (`footer`: AuthFooter in
|
|
18
|
+
* auth-footer.tsx, with the theme, the language and Help · Terms · Privacy), and a real screenshot of the product on
|
|
19
|
+
* the panel (`panel.shot`). A sign-up of several steps adds auth-steps.tsx: the step header, Back + Continue, and the
|
|
20
|
+
* choice cards and chips that answer a step's one question.
|
|
15
21
|
*/
|
|
16
22
|
import "./auth.css"; // its own stylesheet travels with it (0.23.0): a surface that never renders it never loads it
|
|
23
|
+
// What the screen gained on 24/10/2026 (the panel's picture, "Forgot password?", the bottom row's place). Its own entry
|
|
24
|
+
// because auth.css rides in the frozen compatibility bundle, which had 21 bytes of room left (auth-extras.css says more).
|
|
25
|
+
import "./auth-extras.css";
|
|
17
26
|
import React, { useEffect, useRef, useState } from "react";
|
|
18
27
|
|
|
19
28
|
import { GemMark } from "./GemMark";
|
|
@@ -33,24 +42,60 @@ export type AuthBackdrop = "facet" | "grid" | "none";
|
|
|
33
42
|
// Whole class names, not `gb-auth-panel--${backdrop}`: written out, grep and the admin's orphan-rule gate can see them.
|
|
34
43
|
const BACKDROP: Record<AuthBackdrop, string> = { facet: "", grid: "gb-auth-panel--grid", none: "gb-auth-panel--none" };
|
|
35
44
|
|
|
45
|
+
/**
|
|
46
|
+
* A real page of the product in a white window, under the panel's words (24/10/2026). Chris asked for one sign-in for
|
|
47
|
+
* GemBoss, GemCommunity and GemBoss Affiliates that looks better than the words alone: the panel shows what the person
|
|
48
|
+
* is signing in TO (Affiliates its earnings chart, GemCommunity its members, GemBoss its funnels), in a window with a
|
|
49
|
+
* 28px bar and three grey dots so it reads as a screen, not as decoration.
|
|
50
|
+
*
|
|
51
|
+
* Lazy, like AuthPageField's pages: the panel is display:none below 900 wide or 520 tall, and a lazy image there is
|
|
52
|
+
* never fetched, so a phone does not download a picture it cannot see.
|
|
53
|
+
*/
|
|
54
|
+
export interface AuthShot {
|
|
55
|
+
/** The screenshot, served by the surface: a real page, wider than tall (16:10 reads best). */
|
|
56
|
+
src: string;
|
|
57
|
+
/** What it shows, for a screen reader ("This month's earnings, day by day"). `""` when the heading already says it. */
|
|
58
|
+
alt: string;
|
|
59
|
+
/** One line under the window. */
|
|
60
|
+
caption?: React.ReactNode;
|
|
61
|
+
/** The picture's own size, so the window holds its height before the image arrives. */
|
|
62
|
+
width?: number;
|
|
63
|
+
height?: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function AuthShotWindow({ src, alt, caption, width, height }: AuthShot) {
|
|
67
|
+
return (
|
|
68
|
+
<figure className="gb-auth-shot">
|
|
69
|
+
<div className="gb-auth-shot-win">
|
|
70
|
+
<img src={src} alt={alt} width={width} height={height} loading="lazy" decoding="async" />
|
|
71
|
+
</div>
|
|
72
|
+
{caption ? <figcaption>{caption}</figcaption> : null}
|
|
73
|
+
</figure>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
36
77
|
/**
|
|
37
78
|
* The whole screen. `children` is everything inside the card below the heading: the form, then any
|
|
38
79
|
* lines under it.
|
|
39
80
|
*/
|
|
40
|
-
export function AuthLayout({ brand, tagline, mark, panel, backdrop = "facet", art, className, children }: {
|
|
81
|
+
export function AuthLayout({ brand, tagline, mark, panel, backdrop = "facet", art, footer, className, children }: {
|
|
41
82
|
/** The page heading (h1) in the card. */
|
|
42
83
|
brand: React.ReactNode;
|
|
43
84
|
/** One line under the heading; the first thing shed on a short screen. */
|
|
44
85
|
tagline?: React.ReactNode;
|
|
45
86
|
/** Defaults to the GemBoss gem on the `--gb-mark-bg` tile. */
|
|
46
87
|
mark?: React.ReactNode;
|
|
47
|
-
/** The brand panel beside the card — shown only where there is room (900 wide AND 520 tall).
|
|
48
|
-
|
|
88
|
+
/** The brand panel beside the card — shown only where there is room (900 wide AND 520 tall). `shot` (24/10/2026):
|
|
89
|
+
* a screenshot of the product in a window under the words; see `AuthShot`. */
|
|
90
|
+
panel?: { eyebrow?: React.ReactNode; heading: React.ReactNode; body?: React.ReactNode; shot?: AuthShot };
|
|
49
91
|
/** The panel's ground pattern; see `AuthBackdrop`. Only drawn where the panel is (900 wide AND 520 tall). */
|
|
50
92
|
backdrop?: AuthBackdrop;
|
|
51
93
|
/** Drawn on the panel, under its words (16/10/2026): `AuthPageField`, or anything else that is decoration. Pair it
|
|
52
94
|
* with `backdrop="none"`. Only drawn where the panel is. */
|
|
53
95
|
art?: React.ReactNode;
|
|
96
|
+
/** The row at the bottom of the form's column, OUTSIDE the card (24/10/2026): `AuthFooter` (theme, language, Help ·
|
|
97
|
+
* Terms · Privacy). Those are about the page, not the form, so they sit under it rather than in it. */
|
|
98
|
+
footer?: React.ReactNode;
|
|
54
99
|
className?: string;
|
|
55
100
|
children?: React.ReactNode;
|
|
56
101
|
}) {
|
|
@@ -92,7 +137,9 @@ export function AuthLayout({ brand, tagline, mark, panel, backdrop = "facet", ar
|
|
|
92
137
|
return (
|
|
93
138
|
<main className={cx("gb-auth", className)} ref={shellRef}>
|
|
94
139
|
<div className="gb-auth-split">
|
|
95
|
-
|
|
140
|
+
{/* With a footer the column stacks (gb-auth-stage--foot): the card keeps its auto margins, so it still centres in
|
|
141
|
+
the room above, and the row sits at the bottom. Without one the markup is exactly what it was. */}
|
|
142
|
+
<div className={cx("gb-auth-stage", footer ? "gb-auth-stage--foot" : null)}>
|
|
96
143
|
<div className="gb-auth-card">
|
|
97
144
|
<header className="gb-auth-header">
|
|
98
145
|
<span className="gb-auth-mark" aria-hidden>
|
|
@@ -103,6 +150,7 @@ export function AuthLayout({ brand, tagline, mark, panel, backdrop = "facet", ar
|
|
|
103
150
|
</header>
|
|
104
151
|
{children}
|
|
105
152
|
</div>
|
|
153
|
+
{footer ? <div className="gb-auth-bottom">{footer}</div> : null}
|
|
106
154
|
</div>
|
|
107
155
|
{/* Left OUT of aria-hidden: the words are an invitation and a screen-reader user should hear
|
|
108
156
|
them. Nothing in it is focusable — it is decoration beside the form, not a second path. */}
|
|
@@ -113,6 +161,7 @@ export function AuthLayout({ brand, tagline, mark, panel, backdrop = "facet", ar
|
|
|
113
161
|
{panel.eyebrow ? <p className="gb-auth-eyebrow">{panel.eyebrow}</p> : null}
|
|
114
162
|
<h2 className="gb-auth-panel-h">{panel.heading}</h2>
|
|
115
163
|
{panel.body ? <p className="gb-auth-panel-p">{panel.body}</p> : null}
|
|
164
|
+
{panel.shot ? <AuthShotWindow {...panel.shot} /> : null}
|
|
116
165
|
</div>
|
|
117
166
|
</aside>
|
|
118
167
|
) : null}
|
|
@@ -178,6 +227,12 @@ export function AuthContinueWithGemBoss({ service, next = "/", issuer = GEMBOSS_
|
|
|
178
227
|
window.location.replace(gemBossSignInUrl(service, next, issuer, window.location.host));
|
|
179
228
|
}
|
|
180
229
|
}, [service, next, issuer]);
|
|
230
|
+
// Back from GemBoss into a page the browser kept in memory: the door is not still "Continuing with GemBoss…".
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
const back = (e: PageTransitionEvent) => { if (e.persisted) setGoing(false); };
|
|
233
|
+
window.addEventListener("pageshow", back);
|
|
234
|
+
return () => window.removeEventListener("pageshow", back);
|
|
235
|
+
}, []);
|
|
181
236
|
return (
|
|
182
237
|
<div className="gb-auth-sso">
|
|
183
238
|
<a className="gb-auth-sso-btn" href={href} onClick={() => setGoing(true)}>
|
|
@@ -240,17 +295,25 @@ function EyeIcon({ off }: { off: boolean }) {
|
|
|
240
295
|
* Password + reveal toggle inside the field. The input is NOT inside the label: a <button> inside a
|
|
241
296
|
* <label> still fires the label's activation, so every reveal re-focused the input and, on iOS
|
|
242
297
|
* Safari, scrolled the card. `htmlFor` keeps the word "Password" clickable without that.
|
|
298
|
+
*
|
|
299
|
+
* `forgot` (24/10/2026): "Forgot password?" on the label's row, at its right end, as the approved sign-in draws it. It
|
|
300
|
+
* is AFTER the field in the page, and only drawn up on the label's row (a grid, auth-extras.css): someone who Tabs from
|
|
301
|
+
* Email goes straight into Password, types, and presses Enter. Placed before the field it would sit between the two
|
|
302
|
+
* boxes every keyboard user fills.
|
|
243
303
|
*/
|
|
244
304
|
export function PasswordField({ id, label = "Password", toggleLabels = { show: "Show password", hide: "Hide password" },
|
|
245
|
-
inputClassName = "gb-auth-input", ...input }: InputProps & {
|
|
305
|
+
forgot, inputClassName = "gb-auth-input", ...input }: InputProps & {
|
|
246
306
|
id: string;
|
|
247
307
|
label?: React.ReactNode;
|
|
248
308
|
toggleLabels?: { show: string; hide: string };
|
|
309
|
+
/** The "Forgot password?" link: where it goes, its words (default "Forgot password?"), and an onClick for a page that
|
|
310
|
+
* handles it in place (call preventDefault there; the href still works before React has loaded). */
|
|
311
|
+
forgot?: { href: string; label?: React.ReactNode; onClick?: React.MouseEventHandler<HTMLAnchorElement> };
|
|
249
312
|
}) {
|
|
250
313
|
const [shown, setShown] = useState(false);
|
|
251
314
|
const name = shown ? toggleLabels.hide : toggleLabels.show;
|
|
252
315
|
return (
|
|
253
|
-
<div className="gb-auth-field">
|
|
316
|
+
<div className={forgot ? "gb-auth-field gb-auth-field--forgot" : "gb-auth-field"}>
|
|
254
317
|
<label htmlFor={id}>{label}</label>
|
|
255
318
|
<div className="gb-auth-pw">
|
|
256
319
|
<input className={inputClassName} id={id} type={shown ? "text" : "password"} {...input} />
|
|
@@ -270,6 +333,7 @@ export function PasswordField({ id, label = "Password", toggleLabels = { show: "
|
|
|
270
333
|
<EyeIcon off={shown} />
|
|
271
334
|
</button>
|
|
272
335
|
</div>
|
|
336
|
+
{forgot ? <a className="gb-auth-forgot" href={forgot.href} onClick={forgot.onClick}>{forgot.label ?? "Forgot password?"}</a> : null}
|
|
273
337
|
</div>
|
|
274
338
|
);
|
|
275
339
|
}
|
|
@@ -296,6 +360,19 @@ export function AuthHelp({ children }: { children?: React.ReactNode }) {
|
|
|
296
360
|
/** What the form says when the request never got an answer. */
|
|
297
361
|
export const SIGN_IN_OFFLINE = "Couldn't reach the server. Check your connection and try again.";
|
|
298
362
|
|
|
363
|
+
// The refusals that are about what was typed: a missing or malformed value, a wrong email or password. A lock (429), a
|
|
364
|
+
// closed door (503) or a forbidden (403) marks no field.
|
|
365
|
+
const FIELD_REFUSALS = [400, 401, 422];
|
|
366
|
+
|
|
367
|
+
/** A sign-in route's refusal read the way initSignIn() reads it, for an `onSignIn` that fetches the route itself:
|
|
368
|
+
* the body's `error`, `detail` or `message`, and whether it is about the fields (FIELD_REFUSALS).
|
|
369
|
+
* `if (!res.ok) return signInRefusal(res);` keeps a React form and a plain one saying the same thing. */
|
|
370
|
+
export async function signInRefusal(res: Response): Promise<{ message: string; fields: boolean }> {
|
|
371
|
+
const j = await res.json().catch(() => null);
|
|
372
|
+
const said = j && typeof j === "object" ? [j.error, j.detail, j.message].find((x) => typeof x === "string" && x) : undefined;
|
|
373
|
+
return { message: said || `Couldn't sign in (HTTP ${res.status}). Try again.`, fields: FIELD_REFUSALS.includes(res.status) };
|
|
374
|
+
}
|
|
375
|
+
|
|
299
376
|
/**
|
|
300
377
|
* The whole sign-in form of a fleet tool (23/10/2026), the part every tool used to write itself: Continue with GemBoss,
|
|
301
378
|
* then Email, Password, the error and Sign in. Chris, 23/10/2026, seeing "Your lark email" on one form and other words on
|
|
@@ -303,13 +380,19 @@ export const SIGN_IN_OFFLINE = "Couldn't reach the server. Check your connection
|
|
|
303
380
|
* a tool says which tool it is (`service`), where to land (`next`) and how to check the two values (`onSignIn`).
|
|
304
381
|
*
|
|
305
382
|
* `onSignIn` returns the sentence to show when it did not work (the server's own words, e.g. "The email or password is
|
|
306
|
-
* wrong."), or nothing once it has started moving the browser on: the button
|
|
307
|
-
* so a second press cannot send the password twice. It throwing reads as the
|
|
383
|
+
* wrong."; `signInRefusal(res)` reads them from a fetch), or nothing once it has started moving the browser on: the button
|
|
384
|
+
* stays on "Signing in…" until the page goes, so a second press cannot send the password twice. It throwing reads as the
|
|
385
|
+
* network being down.
|
|
308
386
|
*
|
|
309
387
|
* Without `service` there is no GemBoss button: only for a tool that GemBoss does not sign into yet.
|
|
310
388
|
* Plain-HTML twin: `initSignIn()` in auth-signin-plain.js, same markup (auth-signin-browser.test.ts compares the two).
|
|
311
389
|
*/
|
|
312
|
-
|
|
390
|
+
/** What `onSignIn` answers: nothing once it has moved on; the server's sentence (about what was typed, so both fields are
|
|
391
|
+
* marked); or `{ message, fields: false }` for a sentence that is not about the fields (a lock, a closed door). */
|
|
392
|
+
export type SignInAnswer = string | { message: string; fields?: boolean } | null | undefined | void;
|
|
393
|
+
|
|
394
|
+
export function AuthSignIn({ service, next, issuer = GEMBOSS_ISSUER, host, action, onSignIn, foot, forgot, idPrefix = "gb-signin",
|
|
395
|
+
error: givenError, errorFields = true, notice, autoFocus = false }: {
|
|
313
396
|
/** This tool's id in GemBoss's FLEET_SSO_SERVICES. */
|
|
314
397
|
service?: string;
|
|
315
398
|
/** The request's Host, from a server-rendered page: see AuthContinueWithGemBoss. */
|
|
@@ -318,22 +401,43 @@ export function AuthSignIn({ service, next = "/", issuer = GEMBOSS_ISSUER, host,
|
|
|
318
401
|
* should answer a plain form post with a redirect. The form is always `method="post"`, so that early press never
|
|
319
402
|
* becomes a GET with the password in the URL. */
|
|
320
403
|
action?: string;
|
|
321
|
-
/** Where on this tool to land after GemBoss: a path.
|
|
404
|
+
/** Where on this tool to land after GemBoss: a path. It is also posted with the form (`next`), so a press made before
|
|
405
|
+
* React loaded still lands there; left out, the GemBoss door goes to "/" and the form post lets the server choose. */
|
|
322
406
|
next?: string;
|
|
323
407
|
issuer?: string;
|
|
324
|
-
onSignIn: (credentials: { email: string; password: string }) => Promise<
|
|
408
|
+
onSignIn: (credentials: { email: string; password: string }) => Promise<SignInAnswer>;
|
|
325
409
|
/** One line under the form, e.g. "Internal use only." */
|
|
326
410
|
foot?: React.ReactNode;
|
|
411
|
+
/** "Forgot password?" on the Password row (24/10/2026): PasswordField's `forgot`. The plain twin reads `data-forgot`. */
|
|
412
|
+
forgot?: { href: string; label?: React.ReactNode };
|
|
327
413
|
/** Prefix of the inputs' ids: only matters with two sign-in forms on one page. */
|
|
328
414
|
idPrefix?: string;
|
|
415
|
+
/** The sentence the server answered a plain form post with (a press before React loaded; the page reads it from its
|
|
416
|
+
* `?error=`): shown as if `onSignIn` had said it. */
|
|
417
|
+
error?: string;
|
|
418
|
+
/** Whether `error` is about what was typed (default): false for a lock or a closed door, so the fields are not marked. */
|
|
419
|
+
errorFields?: boolean;
|
|
420
|
+
/** A line above the form before anyone presses ("Your session expired. Sign in again."); it goes on the first press. */
|
|
421
|
+
notice?: React.ReactNode;
|
|
422
|
+
/** Put the cursor in Email when the form is on the page: unless someone is already in a field, or the page is going on to
|
|
423
|
+
* GemBoss by itself (a phone's keyboard would open over the redirect). */
|
|
424
|
+
autoFocus?: boolean;
|
|
329
425
|
}) {
|
|
330
|
-
const [email, setEmail] = useState("");
|
|
331
|
-
const [password, setPassword] = useState("");
|
|
332
426
|
const [busy, setBusy] = useState(false);
|
|
333
|
-
const [error, setError] = useState<string | null>(null);
|
|
334
|
-
// The server refused what was typed: both fields are marked. A
|
|
335
|
-
|
|
336
|
-
const
|
|
427
|
+
const [error, setError] = useState<string | null>(givenError || null);
|
|
428
|
+
// The server refused what was typed: both fields are marked. A lock, a closed door or a dropped network marks neither
|
|
429
|
+
// (nothing in them is wrong).
|
|
430
|
+
const [wrong, setWrong] = useState(!!givenError && errorFields);
|
|
431
|
+
// A new `error` after mount (the page moved to another ?error= without remounting): shown, as the first one was.
|
|
432
|
+
const [given, setGiven] = useState(givenError);
|
|
433
|
+
if (given !== givenError) {
|
|
434
|
+
setGiven(givenError);
|
|
435
|
+
setError(givenError || null);
|
|
436
|
+
setWrong(!!givenError && errorFields);
|
|
437
|
+
}
|
|
438
|
+
const [noticeShown, setNoticeShown] = useState(true);
|
|
439
|
+
const errorId = `${idPrefix}-error`, noticeId = `${idPrefix}-notice`;
|
|
440
|
+
const showNotice = !!notice && noticeShown;
|
|
337
441
|
|
|
338
442
|
// Back to this page from the browser's memory after it moved on (bfcache keeps React's state): not still "Signing in…".
|
|
339
443
|
useEffect(() => {
|
|
@@ -342,36 +446,60 @@ export function AuthSignIn({ service, next = "/", issuer = GEMBOSS_ISSUER, host,
|
|
|
342
446
|
return () => window.removeEventListener("pageshow", back);
|
|
343
447
|
}, []);
|
|
344
448
|
|
|
449
|
+
// As HTML autofocus, but not under a field someone is already in (a click made while the page loaded) and not over the
|
|
450
|
+
// redirect when the GemBoss door continues by itself.
|
|
451
|
+
useEffect(() => {
|
|
452
|
+
if (!autoFocus) return;
|
|
453
|
+
const at = document.activeElement;
|
|
454
|
+
if (at && at !== document.body) return;
|
|
455
|
+
if (service && continuesByItself(document.cookie, window.location.search)) return;
|
|
456
|
+
document.getElementById(`${idPrefix}-email`)?.focus();
|
|
457
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- once, when the form arrives
|
|
458
|
+
}, []);
|
|
459
|
+
|
|
345
460
|
async function submit(e: React.FormEvent<HTMLFormElement>) {
|
|
346
461
|
e.preventDefault();
|
|
347
462
|
if (busy) return;
|
|
463
|
+
// What is in the fields now, read from the form: a password manager that filled them before React loaded fires no
|
|
464
|
+
// change event, so state would still say "" and the press would send an empty password (a counted wrong try).
|
|
465
|
+
const values = new FormData(e.currentTarget);
|
|
466
|
+
const email = String(values.get("email") ?? "").trim(), password = String(values.get("password") ?? "");
|
|
348
467
|
setBusy(true);
|
|
349
468
|
setError(null);
|
|
350
|
-
|
|
351
|
-
let
|
|
469
|
+
setNoticeShown(false);
|
|
470
|
+
let said: SignInAnswer;
|
|
471
|
+
let fields = true;
|
|
352
472
|
try {
|
|
353
|
-
said = await onSignIn({ email
|
|
473
|
+
said = await onSignIn({ email, password });
|
|
354
474
|
} catch {
|
|
355
475
|
said = SIGN_IN_OFFLINE;
|
|
356
|
-
|
|
476
|
+
fields = false;
|
|
357
477
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
478
|
+
// An answer with no words is still a refusal: the button must not stay on "Signing in…".
|
|
479
|
+
const message = typeof said === "string" ? said : said ? said.message || "Couldn't sign in. Try again." : "";
|
|
480
|
+
if (said && typeof said === "object" && said.fields === false) fields = false;
|
|
481
|
+
if (message) {
|
|
482
|
+
setError(message);
|
|
483
|
+
setWrong(fields);
|
|
361
484
|
setBusy(false);
|
|
362
485
|
}
|
|
363
486
|
}
|
|
364
487
|
|
|
365
|
-
// Both fields point at the error once there is one: a screen reader that Tabs back into either hears why.
|
|
366
|
-
|
|
488
|
+
// Both fields point at the error once there is one: a screen reader that Tabs back into either hears why. Email also
|
|
489
|
+
// points at the notice: it is on the page from the start, and a live region only speaks when it changes.
|
|
490
|
+
const invalid = error && wrong ? { "aria-invalid": true as const } : {};
|
|
491
|
+
const describedBy = (...ids: (string | false)[]) => ids.filter(Boolean).join(" ") || undefined;
|
|
367
492
|
return (
|
|
368
493
|
<>
|
|
369
|
-
{
|
|
494
|
+
{showNotice ? <p id={noticeId} className="gb-auth-notice" role="status">{notice}</p> : null}
|
|
495
|
+
{service ? <AuthContinueWithGemBoss service={service} next={next ?? "/"} issuer={issuer} host={host} /> : null}
|
|
370
496
|
<AuthForm method="post" action={action} onSubmit={submit}>
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
<
|
|
374
|
-
|
|
497
|
+
{next !== undefined ? <input type="hidden" name="next" value={next} /> : null}
|
|
498
|
+
{/* Not controlled: the browser keeps what is typed or filled, and submit reads the form. */}
|
|
499
|
+
<AuthField id={`${idPrefix}-email`} label="Email" type="email" name="email" autoComplete="username" required {...invalid}
|
|
500
|
+
aria-describedby={describedBy(showNotice && noticeId, !!error && errorId)} />
|
|
501
|
+
<PasswordField id={`${idPrefix}-password`} name="password" autoComplete="current-password" required forgot={forgot} {...invalid}
|
|
502
|
+
aria-describedby={describedBy(!!error && errorId)} />
|
|
375
503
|
<div id={errorId}><AuthError>{error}</AuthError></div>
|
|
376
504
|
<AuthSubmit disabled={busy}>{busy ? "Signing in…" : "Sign in"}</AuthSubmit>
|
|
377
505
|
</AuthForm>
|
package/src/dialog.tsx
CHANGED
|
@@ -25,6 +25,8 @@ const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean)
|
|
|
25
25
|
*
|
|
26
26
|
* - The backdrop closes it only when the press STARTED there too: a text selection dragged from the panel and released
|
|
27
27
|
* over the scrim lands its click on the dialog (the common ancestor), and must not close it (review #4062).
|
|
28
|
+
* - `[data-autofocus]` inside it gets the focus on opening, as in the kit's Popover (a picker's search box: `search.autoFocus`);
|
|
29
|
+
* without one the browser's rule applies, the first control, which is the head's ✕.
|
|
28
30
|
* - `focusPanel`: after opening, focus the dialog itself (it needs `tabIndex={-1}`) instead of its first control, so a
|
|
29
31
|
* second Enter does not follow the head's first link (Sheet's "Open full profile").
|
|
30
32
|
* - Unmounted while open (a route that drew it went away), focus still goes back to the opener.
|
|
@@ -54,6 +56,7 @@ export function useModalDialog(open: boolean, onClose: () => void, { focusPanel
|
|
|
54
56
|
d.showModal();
|
|
55
57
|
shown.current = true;
|
|
56
58
|
if (focusPanel) d.focus({ preventScroll: true });
|
|
59
|
+
else d.querySelector<HTMLElement>("[data-autofocus]")?.focus({ preventScroll: true });
|
|
57
60
|
}
|
|
58
61
|
if (!open && d.open) d.close();
|
|
59
62
|
}, [open, focusPanel]);
|