@gemboss/ui 0.64.0 → 0.65.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 +48 -0
- package/README.md +43 -5
- package/catalog/editor.html +1 -1
- package/catalog/index.html +1 -1
- package/gemboss-ui.css +2 -2
- package/package.json +3 -1
- package/parts/components.css +1 -1
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/editor/color-choices.ts +9 -0
- package/src/editor/controls.tsx +5 -2
- package/src/editor/field-control.tsx +453 -0
- package/src/editor/field-frame.tsx +182 -0
- package/src/editor/field-spec.ts +345 -0
- package/src/editor/index.ts +16 -0
- package/src/editor.css +1 -1
- package/src/email-editor/editor.tsx +37 -9
- package/src/email-editor/model.ts +5 -1
- package/src/email-editor.css +1 -1
- package/src/gem-at-work.css +1 -1
- package/src/gem-at-work.ts +223 -11
- package/src/list-page.tsx +87 -4
|
@@ -54,8 +54,19 @@ export interface EmailEditorProps {
|
|
|
54
54
|
dirty?: boolean;
|
|
55
55
|
onSave: () => void;
|
|
56
56
|
onSendTest: () => void;
|
|
57
|
-
/** Words for "Send me a test" while it runs or after it ran ("Sent to you@store.com"). */
|
|
57
|
+
/** Words for "Send me a test" while it runs or after it ran ("Sent to you@store.com"); also what a save or an approval answered. */
|
|
58
58
|
testNote?: React.ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* The surface's own buttons in the bar, between "Send me a test" and Save (GemBoss: "Approve v3", a Manager's). The editor holds no
|
|
61
|
+
* rule about who may press what: a button a person cannot use is not passed.
|
|
62
|
+
*/
|
|
63
|
+
actions?: React.ReactNode;
|
|
64
|
+
/**
|
|
65
|
+
* The mail as the sender builds it (GemReach's preview route): its HTML, read-only. Given, the bar offers "As sent" beside Dark, and
|
|
66
|
+
* the stage shows that HTML in a sandboxed frame (no script, no access to the page) at the device's width. `loading` while it is
|
|
67
|
+
* being built again after a change; `error` when it could not be built (a variable with no value, a link that is not one).
|
|
68
|
+
*/
|
|
69
|
+
sent?: { html: string | null; loading?: boolean; error?: React.ReactNode };
|
|
59
70
|
/** Where the column's width is remembered in this browser. */
|
|
60
71
|
widthKey?: string;
|
|
61
72
|
}
|
|
@@ -116,7 +127,7 @@ const glyph = (k: AddKind) => (
|
|
|
116
127
|
|
|
117
128
|
export function EmailEditor({
|
|
118
129
|
draft, onChange, brand, back, chat, people = [], productsFor, opens, checks: serverChecks, saveState = "idle", dirty = false,
|
|
119
|
-
onSave, onSendTest, testNote, widthKey = "gb.email-editor.left",
|
|
130
|
+
onSave, onSendTest, testNote, actions, sent, widthKey = "gb.email-editor.left",
|
|
120
131
|
}: EmailEditorProps) {
|
|
121
132
|
const [tab, showTab] = useState<Tab>("sections");
|
|
122
133
|
// Opened once, the chat stays mounted under the other tabs (below): said where the tab changes, never in an effect a render late.
|
|
@@ -125,6 +136,9 @@ export function EmailEditor({
|
|
|
125
136
|
const [selected, setSelected] = useState<number | null>(null);
|
|
126
137
|
const [device, setDevice] = useState<EmailDevice>("desktop");
|
|
127
138
|
const [dark, setDark] = useState(false);
|
|
139
|
+
// "As sent": the sender's own HTML instead of the editable blocks (only when the surface gives it).
|
|
140
|
+
const [asSentOn, setAsSent] = useState(false);
|
|
141
|
+
const asSent = !!sent && asSentOn;
|
|
128
142
|
const [adding, setAdding] = useState<number | null>(null);
|
|
129
143
|
const [personId, setPersonId] = useState(people[0]?.id ?? "");
|
|
130
144
|
const [pane, setPane] = useState<EditorPane>("preview");
|
|
@@ -262,12 +276,17 @@ export function EmailEditor({
|
|
|
262
276
|
center={<span className="gb-emailed-view">
|
|
263
277
|
<Segmented<EmailDevice> ariaLabel="Preview size" value={device} onChange={setDevice}
|
|
264
278
|
options={[{ value: "desktop", label: "Desktop" }, { value: "mobile", label: "Mobile" }]} />
|
|
265
|
-
<ToggleBar<"dark"> ariaLabel="Preview colours" pressed={dark ? ["dark"] : []
|
|
266
|
-
|
|
279
|
+
<ToggleBar<"dark" | "sent"> ariaLabel="Preview colours" pressed={[...(dark && !asSent ? ["dark" as const] : []), ...(asSent ? ["sent" as const] : [])]}
|
|
280
|
+
onToggle={(v) => (v === "sent" ? setAsSent((x) => !x) : setDark((x) => !x))}
|
|
281
|
+
options={[
|
|
282
|
+
{ value: "dark", label: "Dark", title: asSent ? "As sent shows the light version; a dark inbox applies its dark colours" : "How the email reads in a dark inbox", disabled: asSent },
|
|
283
|
+
...(sent ? [{ value: "sent" as const, label: "As sent", title: "The email exactly as it is built to be sent, for this person" }] : []),
|
|
284
|
+
]} />
|
|
267
285
|
</span>}
|
|
268
286
|
right={<>
|
|
269
287
|
<EditorSaveState state={saveState} idleText={dirty ? "Not saved" : undefined} />
|
|
270
288
|
<button type="button" className="ui-btn" onClick={onSendTest}>Send me a test</button>
|
|
289
|
+
{actions}
|
|
271
290
|
<button type="button" className="ui-btn ui-btn--primary" onClick={onSave} disabled={saveState === "saving"}>Save</button>
|
|
272
291
|
</>}
|
|
273
292
|
/>}
|
|
@@ -292,14 +311,23 @@ export function EmailEditor({
|
|
|
292
311
|
{checksOpen ? (
|
|
293
312
|
<div className="gb-emailed-checklist" onClick={(e) => e.stopPropagation()}>
|
|
294
313
|
<StatusList label="Checks" items={[...checks].sort((a, b) => Number(a.ok) - Number(b.ok)).map((c) => ({
|
|
295
|
-
key: c.id, label: c.label, text: c.ok ? "Passes" : c.detail ?? "Needs a look", tone: c.ok ? "ok" : "warning",
|
|
314
|
+
key: c.id, label: c.label, text: c.ok ? "Passes" : c.detail ?? "Needs a look", tone: c.ok ? "ok" : c.severity === "error" ? "critical" : "warning",
|
|
296
315
|
}))} />
|
|
297
316
|
</div>
|
|
298
317
|
) : null}
|
|
299
|
-
{
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
318
|
+
{asSent && sent ? (
|
|
319
|
+
// The sender's HTML, read-only: sandboxed with nothing allowed (no script, no forms, not this page's origin).
|
|
320
|
+
<div className={device === "mobile" ? "gb-emailed-sent is-mobile" : "gb-emailed-sent"} aria-busy={sent.loading ? "true" : undefined}>
|
|
321
|
+
{sent.error ? <p className="gb-emailed-sent-err" role="alert">{sent.error}</p> : null}
|
|
322
|
+
{sent.html ? <iframe className="gb-emailed-sent-frame" title="The email as it is sent" sandbox="" srcDoc={sent.html} /> : null}
|
|
323
|
+
{!sent.html && !sent.error ? <p className="gb-emailed-sent-err">{sent.loading ? "Building the email…" : "Not built yet."}</p> : null}
|
|
324
|
+
</div>
|
|
325
|
+
) : <>
|
|
326
|
+
{/* The envelope reads as picked only where its settings are shown (Settings, no block picked); -1 picks nothing. */}
|
|
327
|
+
<EmailPreview draft={draft} brand={brand} data={data} products={products} device={device} dark={dark} selected={sel ?? (tab === "settings" ? null : -1)}
|
|
328
|
+
onSelect={(i) => select(i)} onAddAfter={(i) => openAdd(i + 1)} />
|
|
329
|
+
<button type="button" className="gb-emailed-addend gb-emailed-addmail" onClick={(e) => { e.stopPropagation(); openAdd(body.length); }}>+ Add a block at the end</button>
|
|
330
|
+
</>}
|
|
303
331
|
</div>}
|
|
304
332
|
>
|
|
305
333
|
<EditorPaneTabs value={pane} onChange={setPane} labels={{ chat: "Edit", preview: "Email" }} />
|
|
@@ -284,7 +284,11 @@ export const BUILT_IN_VARIABLES: readonly string[] = ["unsubscribe_url", "prefer
|
|
|
284
284
|
// ── checks ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
285
285
|
|
|
286
286
|
/** One check, by GemReach's id and name (src/templates/check-ids.ts), so the pill and the server's report say the same thing. */
|
|
287
|
-
export interface EmailCheck {
|
|
287
|
+
export interface EmailCheck {
|
|
288
|
+
id: string; label: string; ok: boolean; detail?: string;
|
|
289
|
+
/** The sender's word (GemReach): `error` stops the approval, `warning` is a look. Absent: a look (the editor's own checks). */
|
|
290
|
+
severity?: "error" | "warning";
|
|
291
|
+
}
|
|
288
292
|
|
|
289
293
|
/** Contrast between two #hex colours (WCAG, 1–21), GemReach's `contrast`. */
|
|
290
294
|
export function contrast(a: string, b: string): number {
|
package/src/email-editor.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gb-emailed .gemboss-editor-tb-left{gap:8px;min-width:0}.gb-emailed-crumb{max-width:22ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gemboss-text-muted);font-weight:550}.gb-emailed-slash{color:var(--gemboss-divider)}.gb-emailed-name{max-width:28ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gemboss-text-strong)}.gb-emailed-chip,.gb-emailed-tag{flex:none;padding:1px 8px;border-radius:var(--gemboss-radius-sm);background:var(--gemboss-active-bg);font-size:var(--gemboss-fs-caption);font-weight:600;white-space:nowrap}.gb-emailed-tag{padding:1px 6px;background:var(--gemboss-accent-soft);color:var(--gemboss-accent-strong);font-size:var(--gemboss-fs-micro)}.gb-emailed-view{display:inline-flex;gap:6px}.gb-emailed-col{display:flex;flex-direction:column;min-height:0}.gb-emailed-chat{flex:1;min-height:0;display:flex;flex-direction:column}.gb-emailed-chat[hidden]{display:none}.gb-emailed-pane{flex:1;min-height:0;overflow:auto;padding:12px;display:flex;flex-direction:column;gap:8px}.gb-emailed-pane>.gemboss-ei-head{margin:-12px -12px 4px}.gb-emailed-blocks{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.gb-emailed-row{display:flex;align-items:stretch;border-radius:10px;box-shadow:inset 0 0 0 1px var(--gemboss-divider);background:var(--gemboss-surface)}.gb-emailed-row.is-sel{background:var(--gemboss-accent-soft);box-shadow:inset 0 0 0 1.5px var(--gemboss-accent)}.gb-emailed-row.is-hidden{opacity:.55}.gb-emailed-row-main{flex:1;min-width:0;display:flex;align-items:center;gap:8px;padding:8px 10px;border:0;background:none;font:inherit;color:var(--gemboss-text);text-align:left;cursor:pointer;border-radius:10px}.gb-emailed-row-main:focus-visible,.gb-emailed-row-acts button:focus-visible,.gb-emailed-addend:focus-visible,.gb-emailed-checks:focus-visible,.gb-email-blk:focus-visible,.gb-email-env:focus-visible,.gb-email-add:focus-visible{outline:2px solid var(--ui-focus);outline-offset:2px}.gb-emailed-row-t{flex:1;min-width:0;display:flex;flex-direction:column}.gb-emailed-row-t b{font-weight:550;color:var(--gemboss-text-strong)}.gb-emailed-row-t span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gb-emailed-row-acts{display:flex;align-items:center;gap:2px;padding-right:6px}.gb-emailed-row-acts button{width:26px;height:26px;border:0;border-radius:var(--gemboss-radius-sm);background:none;color:var(--gemboss-text-muted);font:inherit;cursor:pointer}.gb-emailed-row-acts button:hover:not(:disabled){background:var(--gemboss-hover);color:var(--gemboss-text)}.gb-emailed-row-acts button:disabled{opacity:.35;cursor:default}.gb-emailed-addend{min-height:36px;padding:0 12px;border:1.5px dashed var(--gemboss-divider);border-radius:10px;background:transparent;color:var(--gemboss-text);font:inherit;font-weight:550;cursor:pointer}.gb-emailed-addend:hover{border-color:var(--gemboss-accent);color:var(--gemboss-accent-strong)}.gb-emailed-addend span{color:var(--gemboss-text-muted);font-weight:450}.gb-emailed-sum{margin-top:4px;padding:12px;border-radius:10px;background:var(--gemboss-primary-soft);display:flex;flex-direction:column;gap:6px;align-items:flex-start}.gb-emailed-sum b{color:var(--gemboss-text-strong)}.gb-emailed-muted{margin:0;font-size:var(--gemboss-fs-caption);line-height:18px;color:var(--gemboss-text-muted)}.gb-emailed-pick{padding:10px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--gemboss-divider);display:flex;flex-direction:column;gap:8px}.gb-emailed-pick-head{display:flex;align-items:center;gap:8px}.gb-emailed-pick-head span{flex:1;color:var(--gemboss-text-muted);font-size:var(--gemboss-fs-caption)}.gb-emailed-form{display:flex;flex-direction:column;gap:12px;padding-top:4px}.gb-emailed-area{min-height:88px}.gb-emailed-vars{display:flex;flex-wrap:wrap;gap:4px;margin-top:-6px}.gb-emailed-personal{padding:10px 12px;border-radius:10px;background:var(--gemboss-accent-wash);box-shadow:inset 0 0 0 1px var(--gemboss-accent-tint);display:flex;flex-direction:column;align-items:flex-start;gap:4px;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gb-emailed-personal b{font-size:var(--gemboss-fs-body);color:var(--gemboss-text-strong)}.gb-emailed-from{color:var(--gemboss-text-muted)}.gb-emailed-stage{background:var(--gemboss-preview-canvas)}.gb-emailed-scroll{flex:1;min-width:0;overflow:auto;padding:24px}.gb-emailed-meta,.gb-emailed-checklist{max-width:640px;margin:0 auto 12px;display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px}.gb-emailed-checklist{display:block;padding:12px;border-radius:12px;background:var(--gemboss-surface)}.gb-emailed-checks,.gb-emailed-as,.gb-emailed-note{padding:4px 10px;border:0;border-radius:var(--gemboss-radius-full);background:var(--gemboss-warning-soft);color:var(--gemboss-warning);font:inherit;font-size:var(--gemboss-fs-caption);font-weight:600}.gb-emailed-checks{cursor:pointer}.gb-emailed-checks.is-ok{background:var(--gemboss-success-soft);color:var(--gemboss-success-strong)}.gb-emailed-as,.gb-emailed-note{background:var(--gemboss-surface);color:var(--gemboss-text);font-weight:450}.gb-emailed-addmail{display:block;max-width:640px;width:100%;margin:12px auto 0;background:var(--gemboss-surface)}.gb-email-col{max-width:640px;margin:0 auto;display:flex;flex-direction:column;gap:12px;color:var(--gemboss-text)}.gb-email-col.is-mobile{max-width:375px}.gb-email-env{padding:12px 16px;border-radius:12px;background:var(--gemboss-surface);display:flex;flex-direction:column;gap:2px;cursor:pointer}.gb-email-env[aria-pressed=true]{box-shadow:inset 0 0 0 1.5px var(--gemboss-accent)}.gb-email-env-k,.gb-email-env-pre{color:var(--gemboss-text-muted)}.gb-email-mail{--gb-ink: var(--gb-email-ink, var(--gemboss-text));--gb-muted: var(--gb-email-muted, var(--gemboss-text-muted));--gb-line: var(--gb-email-line, var(--gemboss-divider-soft));border-radius:12px;background:var(--gb-email-bg, var(--gemboss-surface));color:var(--gb-ink);overflow:hidden;display:flex;flex-direction:column}.is-dark>.gb-email-mail{--gb-ink: var(--gemboss-dark-text);--gb-muted: var(--gemboss-dark-muted);--gb-line: var(--gemboss-dark-divider);background:var(--gemboss-dark-surface)}.gb-email-blk{position:relative;cursor:pointer}.gb-email-blk:hover{box-shadow:inset 0 0 0 1px var(--gemboss-accent-mid)}.gb-email-blk.is-sel{box-shadow:inset 0 0 0 2px var(--gemboss-accent)}.gb-email-addrow{position:relative;height:0;display:flex;justify-content:center;z-index:1}.gb-email-add{position:absolute;top:-14px;width:28px;height:28px;border:0;border-radius:50%;background:var(--gemboss-accent);color:var(--gemboss-on-primary);font:inherit;font-size:18px;line-height:1;cursor:pointer;box-shadow:var(--gemboss-shadow-raised)}.gb-email-logo{height:56px;display:grid;place-items:center;border-bottom:1px solid var(--gb-line);font-weight:700;letter-spacing:.2em;color:var(--gb-ink)}.gb-email-logo img{max-height:32px}.gb-email-al-left{text-align:left;justify-content:flex-start}.gb-email-al-center{text-align:center;justify-content:center}.gb-email-al-right{text-align:right;justify-content:flex-end}.gb-email-img img{display:block;width:100%;height:auto}.gb-email-img.is-empty{height:150px;display:grid;place-items:center;background:var(--gemboss-warning-soft);color:var(--gb-muted);font-size:var(--gemboss-fs-caption)}.gb-email-text{padding:24px 32px 8px;display:flex;flex-direction:column;gap:8px}.gb-email-h{margin:0;font-size:22px;line-height:28px;font-weight:700;color:var(--gb-ink)}.gb-email-p{margin:0;line-height:20px;color:var(--gb-ink)}.gb-email-strong{font-weight:650}.gb-email-muted{color:var(--gb-muted)}.gb-email-link{text-decoration:underline}.gb-email-var{padding:0 2px;border-radius:3px;background:var(--gemboss-warning-soft);color:var(--gemboss-warning)}.gb-email-products,.gb-email-review,.gb-email-band{padding:8px 32px;display:flex;flex-direction:column;gap:10px}.gb-email-review{align-items:center;text-align:center;padding-block:16px}.gb-email-pgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.gb-email-pgrid[data-count="1"]{grid-template-columns:minmax(0,1fr)}.gb-email-pgrid[data-count="3"]{grid-template-columns:repeat(3,minmax(0,1fr))}.is-mobile .gb-email-pgrid{grid-template-columns:minmax(0,1fr)}.gb-email-pcard{border:1px solid var(--gb-line);border-radius:10px;overflow:hidden}.gb-email-pcard.is-one{margin:8px 32px;display:flex}.gb-email-pimg{height:80px;background:var(--gemboss-warning-soft)}.gb-email-pimg img{width:100%;height:100%;object-fit:cover}.gb-email-pbody{padding:8px 10px;display:flex;flex-direction:column}.gb-email-pbody span{color:var(--gb-muted)}.gb-email-btnrow{padding:12px 32px 24px;display:flex;justify-content:center}.gb-email-products .gb-email-btnrow,.gb-email-review .gb-email-btnrow,.gb-email-text .gb-email-btnrow,.gb-email-band .gb-email-btnrow{padding:4px 0 8px}.gb-email-btn{padding:12px 24px;border-radius:8px;background:var(--gb-email-btn, var(--gemboss-primary));color:var(--gb-email-btn-ink, var(--gemboss-on-primary));font-weight:600}.gb-email-stars{display:inline-flex;gap:4px;fill:none;stroke:var(--gemboss-warning);stroke-width:1.4}.gb-email-foot{padding:12px 32px 20px;border-top:1px solid var(--gb-line);text-align:center;font-size:var(--gemboss-fs-caption);color:var(--gb-muted)}.gb-email-foot p{margin:0 0 4px}.gb-email-quote{margin:8px 32px;padding:16px;border-radius:8px;background:var(--gemboss-primary-soft);font-style:italic}.gb-email-quote cite{display:block;margin-top:8px;font-style:normal;font-weight:600}.gb-email-list{margin:0;padding:8px 32px 8px 54px}.gb-email-cols{padding:8px 32px;display:grid;grid-template-columns:1fr 1fr;gap:16px}.gb-email-rule{margin:8px 32px;border:0;border-top:1px solid var(--gb-line)}.is-mobile .gb-email-text,.is-mobile .gb-email-products,.is-mobile .gb-email-review,.is-mobile .gb-email-btnrow,.is-mobile .gb-email-foot{padding-inline:20px}@media (max-width: 47.9975em){.gb-emailed-crumb,.gb-emailed-slash{display:none}.gb-emailed-scroll{padding:12px}.gb-email-pgrid{grid-template-columns:minmax(0,1fr)}.gb-emailed-row-main,.gb-emailed-addend,.gb-emailed-row-acts button{min-height:44px}.gb-emailed-row-acts button{min-width:44px}}
|
|
1
|
+
.gb-emailed .gemboss-editor-tb-left{gap:8px;min-width:0}.gb-emailed-crumb{max-width:22ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gemboss-text-muted);font-weight:550}.gb-emailed-slash{color:var(--gemboss-divider)}.gb-emailed-name{max-width:28ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gemboss-text-strong)}.gb-emailed-chip,.gb-emailed-tag{flex:none;padding:1px 8px;border-radius:var(--gemboss-radius-sm);background:var(--gemboss-active-bg);font-size:var(--gemboss-fs-caption);font-weight:600;white-space:nowrap}.gb-emailed-tag{padding:1px 6px;background:var(--gemboss-accent-soft);color:var(--gemboss-accent-strong);font-size:var(--gemboss-fs-micro)}.gb-emailed-view{display:inline-flex;gap:6px}.gb-emailed-col{display:flex;flex-direction:column;min-height:0}.gb-emailed-chat{flex:1;min-height:0;display:flex;flex-direction:column}.gb-emailed-chat[hidden]{display:none}.gb-emailed-pane{flex:1;min-height:0;overflow:auto;padding:12px;display:flex;flex-direction:column;gap:8px}.gb-emailed-pane>.gemboss-ei-head{margin:-12px -12px 4px}.gb-emailed-blocks{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.gb-emailed-row{display:flex;align-items:stretch;border-radius:10px;box-shadow:inset 0 0 0 1px var(--gemboss-divider);background:var(--gemboss-surface)}.gb-emailed-row.is-sel{background:var(--gemboss-accent-soft);box-shadow:inset 0 0 0 1.5px var(--gemboss-accent)}.gb-emailed-row.is-hidden{opacity:.55}.gb-emailed-row-main{flex:1;min-width:0;display:flex;align-items:center;gap:8px;padding:8px 10px;border:0;background:none;font:inherit;color:var(--gemboss-text);text-align:left;cursor:pointer;border-radius:10px}.gb-emailed-row-main:focus-visible,.gb-emailed-row-acts button:focus-visible,.gb-emailed-addend:focus-visible,.gb-emailed-checks:focus-visible,.gb-email-blk:focus-visible,.gb-email-env:focus-visible,.gb-email-add:focus-visible{outline:2px solid var(--ui-focus);outline-offset:2px}.gb-emailed-row-t{flex:1;min-width:0;display:flex;flex-direction:column}.gb-emailed-row-t b{font-weight:550;color:var(--gemboss-text-strong)}.gb-emailed-row-t span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gb-emailed-row-acts{display:flex;align-items:center;gap:2px;padding-right:6px}.gb-emailed-row-acts button{width:26px;height:26px;border:0;border-radius:var(--gemboss-radius-sm);background:none;color:var(--gemboss-text-muted);font:inherit;cursor:pointer}.gb-emailed-row-acts button:hover:not(:disabled){background:var(--gemboss-hover);color:var(--gemboss-text)}.gb-emailed-row-acts button:disabled{opacity:.35;cursor:default}.gb-emailed-addend{min-height:36px;padding:0 12px;border:1.5px dashed var(--gemboss-divider);border-radius:10px;background:transparent;color:var(--gemboss-text);font:inherit;font-weight:550;cursor:pointer}.gb-emailed-addend:hover{border-color:var(--gemboss-accent);color:var(--gemboss-accent-strong)}.gb-emailed-addend span{color:var(--gemboss-text-muted);font-weight:450}.gb-emailed-sum{margin-top:4px;padding:12px;border-radius:10px;background:var(--gemboss-primary-soft);display:flex;flex-direction:column;gap:6px;align-items:flex-start}.gb-emailed-sum b{color:var(--gemboss-text-strong)}.gb-emailed-muted{margin:0;font-size:var(--gemboss-fs-caption);line-height:18px;color:var(--gemboss-text-muted)}.gb-emailed-pick{padding:10px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--gemboss-divider);display:flex;flex-direction:column;gap:8px}.gb-emailed-pick-head{display:flex;align-items:center;gap:8px}.gb-emailed-pick-head span{flex:1;color:var(--gemboss-text-muted);font-size:var(--gemboss-fs-caption)}.gb-emailed-form{display:flex;flex-direction:column;gap:12px;padding-top:4px}.gb-emailed-area{min-height:88px}.gb-emailed-vars{display:flex;flex-wrap:wrap;gap:4px;margin-top:-6px}.gb-emailed-personal{padding:10px 12px;border-radius:10px;background:var(--gemboss-accent-wash);box-shadow:inset 0 0 0 1px var(--gemboss-accent-tint);display:flex;flex-direction:column;align-items:flex-start;gap:4px;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gb-emailed-personal b{font-size:var(--gemboss-fs-body);color:var(--gemboss-text-strong)}.gb-emailed-from{color:var(--gemboss-text-muted)}.gb-emailed-stage{background:var(--gemboss-preview-canvas)}.gb-emailed-scroll{flex:1;min-width:0;overflow:auto;padding:24px}.gb-emailed-meta,.gb-emailed-checklist{max-width:640px;margin:0 auto 12px;display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px}.gb-emailed-checklist{display:block;padding:12px;border-radius:12px;background:var(--gemboss-surface)}.gb-emailed-checks,.gb-emailed-as,.gb-emailed-note{padding:4px 10px;border:0;border-radius:var(--gemboss-radius-full);background:var(--gemboss-warning-soft);color:var(--gemboss-warning);font:inherit;font-size:var(--gemboss-fs-caption);font-weight:600}.gb-emailed-checks{cursor:pointer}.gb-emailed-checks.is-ok{background:var(--gemboss-success-soft);color:var(--gemboss-success-strong)}.gb-emailed-as,.gb-emailed-note{background:var(--gemboss-surface);color:var(--gemboss-text);font-weight:450}.gb-emailed-addmail{display:block;max-width:640px;width:100%;margin:12px auto 0;background:var(--gemboss-surface)}.gb-emailed-sent{max-width:640px;margin:0 auto;display:flex;flex-direction:column;gap:8px}.gb-emailed-sent.is-mobile{max-width:375px}.gb-emailed-sent[aria-busy=true]{opacity:.6}.gb-emailed-sent-frame{display:block;width:100%;height:72vh;min-height:480px;border:0;border-radius:var(--gemboss-radius-md);background:var(--gemboss-surface)}.gb-emailed-sent-err{margin:0;color:var(--gemboss-text-muted);font-size:var(--gemboss-fs-caption)}.gb-email-col{max-width:640px;margin:0 auto;display:flex;flex-direction:column;gap:12px;color:var(--gemboss-text)}.gb-email-col.is-mobile{max-width:375px}.gb-email-env{padding:12px 16px;border-radius:12px;background:var(--gemboss-surface);display:flex;flex-direction:column;gap:2px;cursor:pointer}.gb-email-env[aria-pressed=true]{box-shadow:inset 0 0 0 1.5px var(--gemboss-accent)}.gb-email-env-k,.gb-email-env-pre{color:var(--gemboss-text-muted)}.gb-email-mail{--gb-ink: var(--gb-email-ink, var(--gemboss-text));--gb-muted: var(--gb-email-muted, var(--gemboss-text-muted));--gb-line: var(--gb-email-line, var(--gemboss-divider-soft));border-radius:12px;background:var(--gb-email-bg, var(--gemboss-surface));color:var(--gb-ink);overflow:hidden;display:flex;flex-direction:column}.is-dark>.gb-email-mail{--gb-ink: var(--gemboss-dark-text);--gb-muted: var(--gemboss-dark-muted);--gb-line: var(--gemboss-dark-divider);background:var(--gemboss-dark-surface)}.gb-email-blk{position:relative;cursor:pointer}.gb-email-blk:hover{box-shadow:inset 0 0 0 1px var(--gemboss-accent-mid)}.gb-email-blk.is-sel{box-shadow:inset 0 0 0 2px var(--gemboss-accent)}.gb-email-addrow{position:relative;height:0;display:flex;justify-content:center;z-index:1}.gb-email-add{position:absolute;top:-14px;width:28px;height:28px;border:0;border-radius:50%;background:var(--gemboss-accent);color:var(--gemboss-on-primary);font:inherit;font-size:18px;line-height:1;cursor:pointer;box-shadow:var(--gemboss-shadow-raised)}.gb-email-logo{height:56px;display:grid;place-items:center;border-bottom:1px solid var(--gb-line);font-weight:700;letter-spacing:.2em;color:var(--gb-ink)}.gb-email-logo img{max-height:32px}.gb-email-al-left{text-align:left;justify-content:flex-start}.gb-email-al-center{text-align:center;justify-content:center}.gb-email-al-right{text-align:right;justify-content:flex-end}.gb-email-img img{display:block;width:100%;height:auto}.gb-email-img.is-empty{height:150px;display:grid;place-items:center;background:var(--gemboss-warning-soft);color:var(--gb-muted);font-size:var(--gemboss-fs-caption)}.gb-email-text{padding:24px 32px 8px;display:flex;flex-direction:column;gap:8px}.gb-email-h{margin:0;font-size:22px;line-height:28px;font-weight:700;color:var(--gb-ink)}.gb-email-p{margin:0;line-height:20px;color:var(--gb-ink)}.gb-email-strong{font-weight:650}.gb-email-muted{color:var(--gb-muted)}.gb-email-link{text-decoration:underline}.gb-email-var{padding:0 2px;border-radius:3px;background:var(--gemboss-warning-soft);color:var(--gemboss-warning)}.gb-email-products,.gb-email-review,.gb-email-band{padding:8px 32px;display:flex;flex-direction:column;gap:10px}.gb-email-review{align-items:center;text-align:center;padding-block:16px}.gb-email-pgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.gb-email-pgrid[data-count="1"]{grid-template-columns:minmax(0,1fr)}.gb-email-pgrid[data-count="3"]{grid-template-columns:repeat(3,minmax(0,1fr))}.is-mobile .gb-email-pgrid{grid-template-columns:minmax(0,1fr)}.gb-email-pcard{border:1px solid var(--gb-line);border-radius:10px;overflow:hidden}.gb-email-pcard.is-one{margin:8px 32px;display:flex}.gb-email-pimg{height:80px;background:var(--gemboss-warning-soft)}.gb-email-pimg img{width:100%;height:100%;object-fit:cover}.gb-email-pbody{padding:8px 10px;display:flex;flex-direction:column}.gb-email-pbody span{color:var(--gb-muted)}.gb-email-btnrow{padding:12px 32px 24px;display:flex;justify-content:center}.gb-email-products .gb-email-btnrow,.gb-email-review .gb-email-btnrow,.gb-email-text .gb-email-btnrow,.gb-email-band .gb-email-btnrow{padding:4px 0 8px}.gb-email-btn{padding:12px 24px;border-radius:8px;background:var(--gb-email-btn, var(--gemboss-primary));color:var(--gb-email-btn-ink, var(--gemboss-on-primary));font-weight:600}.gb-email-stars{display:inline-flex;gap:4px;fill:none;stroke:var(--gemboss-warning);stroke-width:1.4}.gb-email-foot{padding:12px 32px 20px;border-top:1px solid var(--gb-line);text-align:center;font-size:var(--gemboss-fs-caption);color:var(--gb-muted)}.gb-email-foot p{margin:0 0 4px}.gb-email-quote{margin:8px 32px;padding:16px;border-radius:8px;background:var(--gemboss-primary-soft);font-style:italic}.gb-email-quote cite{display:block;margin-top:8px;font-style:normal;font-weight:600}.gb-email-list{margin:0;padding:8px 32px 8px 54px}.gb-email-cols{padding:8px 32px;display:grid;grid-template-columns:1fr 1fr;gap:16px}.gb-email-rule{margin:8px 32px;border:0;border-top:1px solid var(--gb-line)}.is-mobile .gb-email-text,.is-mobile .gb-email-products,.is-mobile .gb-email-review,.is-mobile .gb-email-btnrow,.is-mobile .gb-email-foot{padding-inline:20px}@media (max-width: 47.9975em){.gb-emailed-crumb,.gb-emailed-slash{display:none}.gb-emailed-scroll{padding:12px}.gb-email-pgrid{grid-template-columns:minmax(0,1fr)}.gb-emailed-row-main,.gb-emailed-addend,.gb-emailed-row-acts button{min-height:44px}.gb-emailed-row-acts button{min-width:44px}}
|
package/src/gem-at-work.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gb-gaw{position:absolute;left:0;top:0;width:0;height:0;overflow:visible;pointer-events:none;z-index:2147483000;--gb-gaw-ring: var(--gemboss-accent, #5661f5);--gb-gaw-bad: var(--gemboss-danger, #d72c0d);font:600 11px/1 -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}.gb-gaw>*{position:absolute;box-sizing:border-box}.gb-gaw__cursor{left:0;top:0;width:14px;height:18px;z-index:2;will-change:transform}.gb-gaw__cursor svg{display:block;width:14px;height:18px;max-width:none;max-height:none;overflow:visible;filter:drop-shadow(0 1px 1px rgba(0,0,0,.28))}.gb-gaw__cursor path{fill:var(--c, var(--gb-gaw-ring));stroke:#fff;stroke-width:1.3;stroke-linejoin:round}.gb-gaw__tag{position:absolute;left:11px;top:15px;padding:4px 6px;border-radius:3px;background:var(--c, var(--gb-gaw-ring));color:var(--ink, #fff);white-space:nowrap;box-shadow:0 1px 2px #0003}.gb-gaw__cursor.is-failed path{fill:var(--gb-gaw-bad)}.gb-gaw__cursor.is-failed .gb-gaw__tag{background:var(--gb-gaw-bad);color:#fff}.gb-gaw__ring{border:1.5px solid var(--gb-gaw-ring);border-radius:2px}.gb-gaw__label{position:absolute;left:-2px;top:-21px;padding:5px 7px;border-radius:3px 3px 0 0;background:var(--gb-gaw-ring);color:#fff;white-space:nowrap}.gb-gaw__ring--slot{border-color:transparent}.gb-gaw__ring.is-applied .gb-gaw__label:after{content:" \2713"}.gb-gaw__ring.is-failed{border-color:var(--gb-gaw-bad)}.gb-gaw__ring.is-failed .gb-gaw__label{background:var(--gb-gaw-bad)}.gb-gaw__slot{min-height:120px;padding:18px 22px;border:1.5px dashed var(--gb-gaw-ring);border-radius:6px;background:var(--gemboss-accent-wash, #f7f8ff);box-shadow:0 6px 20px #1f1e1d14}.gb-gaw__slot--new{padding:26px 30px;border:0;border-radius:12px;background:var(--gemboss-accent-wash, #f7f8ff);box-shadow:0 1px 2px #1f1e1d0a,0 8px 24px #1f1e1d0f}.gb-gaw__ghost-h,.gb-gaw__ghost-p{width:fit-content;max-width:100%}.gb-gaw__ghost-h{margin:0 0 10px;color:#1b1c1e;font-size:28px;font-weight:600;line-height:1.2}.gb-gaw__ghost-p{margin:0 0 6px;color:#3d4250;font-size:16px;font-weight:400;line-height:1.5}.gb-gaw__sel{border:1px solid var(--gb-gaw-ring)}.gb-gaw__sel i{position:absolute;width:6px;height:6px;background:#fff;border:1px solid var(--gb-gaw-ring)}.gb-gaw__sel i:nth-child(1){left:-3.5px;top:-3.5px}.gb-gaw__sel i:nth-child(2){right:-3.5px;top:-3.5px}.gb-gaw__sel i:nth-child(3){left:-3.5px;bottom:-3.5px}.gb-gaw__sel i:nth-child(4){right:-3.5px;bottom:-3.5px}.gb-gaw__dim{position:absolute;left:-1px;top:calc(100% + 4px);padding:2px 4px;border-radius:2px;background:var(--gb-gaw-ring);color:#fff;font:600 9.5px/1 ui-monospace,SF Mono,Menlo,Consolas,monospace;white-space:nowrap}.gb-gaw__guide{background
|
|
1
|
+
.gb-gaw{position:absolute;left:0;top:0;width:0;height:0;overflow:visible;pointer-events:none;z-index:2147483000;--gb-gaw-ring: var(--gemboss-accent, #5661f5);--gb-gaw-bad: var(--gemboss-danger, #d72c0d);font:600 11px/1 -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}.gb-gaw>*{position:absolute;box-sizing:border-box}.gb-gaw__cursor{left:0;top:0;width:14px;height:18px;z-index:2;will-change:transform}.gb-gaw__cursor svg{display:block;width:14px;height:18px;max-width:none;max-height:none;overflow:visible;filter:drop-shadow(0 1px 1px rgba(0,0,0,.28))}.gb-gaw__cursor path{fill:var(--c, var(--gb-gaw-ring));stroke:#fff;stroke-width:1.3;stroke-linejoin:round}.gb-gaw__tag{position:absolute;left:11px;top:15px;padding:4px 6px;border-radius:3px;background:var(--c, var(--gb-gaw-ring));color:var(--ink, #fff);white-space:nowrap;box-shadow:0 1px 2px #0003}.gb-gaw__cursor.is-left .gb-gaw__tag{left:auto;right:6px}.gb-gaw__cursor.is-failed path{fill:var(--gb-gaw-bad)}.gb-gaw__cursor.is-failed .gb-gaw__tag{background:var(--gb-gaw-bad);color:#fff}.gb-gaw__ring{border:1.5px solid var(--gb-gaw-ring);border-radius:2px}.gb-gaw__label{position:absolute;left:-2px;top:-21px;padding:5px 7px;border-radius:3px 3px 0 0;background:var(--gb-gaw-ring);color:#fff;white-space:nowrap}.gb-gaw__ring--slot{border-color:transparent}.gb-gaw__ring.is-applied .gb-gaw__label:after{content:" \2713"}.gb-gaw__ring.is-failed{border-color:var(--gb-gaw-bad)}.gb-gaw__ring.is-failed .gb-gaw__label{background:var(--gb-gaw-bad)}.gb-gaw__slot{min-height:120px;padding:18px 22px;border:1.5px dashed var(--gb-gaw-ring);border-radius:6px;background:var(--gemboss-accent-wash, #f7f8ff);box-shadow:0 6px 20px #1f1e1d14}.gb-gaw__slot--new{padding:26px 30px;border:0;border-radius:12px;background:var(--gemboss-accent-wash, #f7f8ff);box-shadow:0 1px 2px #1f1e1d0a,0 8px 24px #1f1e1d0f}.gb-gaw__ghost-h,.gb-gaw__ghost-p{width:fit-content;max-width:100%}.gb-gaw__ghost-h{margin:0 0 10px;color:#1b1c1e;font-size:28px;font-weight:600;line-height:1.2}.gb-gaw__ghost-p{margin:0 0 6px;color:#3d4250;font-size:16px;font-weight:400;line-height:1.5}.gb-gaw__sel{border:1px solid var(--gb-gaw-ring)}.gb-gaw__sel i{position:absolute;width:6px;height:6px;background:#fff;border:1px solid var(--gb-gaw-ring)}.gb-gaw__sel i:nth-child(1){left:-3.5px;top:-3.5px}.gb-gaw__sel i:nth-child(2){right:-3.5px;top:-3.5px}.gb-gaw__sel i:nth-child(3){left:-3.5px;bottom:-3.5px}.gb-gaw__sel i:nth-child(4){right:-3.5px;bottom:-3.5px}.gb-gaw__dim{position:absolute;left:-1px;top:calc(100% + 4px);padding:2px 4px;border-radius:2px;background:var(--gb-gaw-ring);color:#fff;font:600 9.5px/1 ui-monospace,SF Mono,Menlo,Consolas,monospace;white-space:nowrap}.gb-gaw__guide{background:#ff7a45;opacity:.75}.gb-gaw__caret{background:var(--gb-gaw-ring)}.gb-gaw__caret--inline{position:static;display:inline-block;width:2px;height:.9em;margin-left:2px;vertical-align:-.1em}.gb-gaw__veil{background:#a9b1fb;opacity:.92}.gb-gaw__scan{background:var(--gb-gaw-ring);box-shadow:0 0 14px 4px #5661f559}.gb-gaw__glow{border:2px solid var(--gb-gaw-ring);border-radius:2px;box-shadow:0 0 0 4px #5661f52e;opacity:0}@media (prefers-reduced-motion: reduce){.gb-gaw__cursor,.gb-gaw__scan,.gb-gaw__guide{display:none}}.gb-gaw-skip{position:fixed;right:16px;bottom:16px;z-index:2147483001;padding:7px 12px;border:0;border-radius:999px;background:#16171adb;color:#fff;font:600 12px/1 -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;cursor:pointer;box-shadow:0 2px 8px #0000002e}.gb-gaw-skip:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:2px}.gb-gaw__say,.gb-gaw-goal,.gb-gaw-count{z-index:2147483001;pointer-events:none;padding:6px 10px;border-radius:6px;background:#16171ae0;color:#fff;font:500 12px/1.35 system-ui,sans-serif;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:420px;box-shadow:0 2px 8px #0000002e}.gb-gaw__say{position:absolute;left:0;top:0}.gb-gaw-goal{position:fixed;left:16px;bottom:16px}.gb-gaw-goal i,.gb-gaw-count i{display:block;height:3px;margin-top:5px;border-radius:2px;background:var(--gemboss-accent, #5661f5);transform-origin:left}.gb-gaw__plus{color:#fff;background:var(--gb-gaw-ring);font:700 11px/12px monospace;text-align:center}.gb-gaw-ruler{position:fixed;left:0;right:0;height:14px;z-index:2147483000;pointer-events:none;background:repeating-linear-gradient(90deg,#fff 0 1px,transparent 1px 10px) bottom / 100% 4px no-repeat #16171a}.gb-gaw-ruler span{position:absolute;color:#fff;font:9px monospace}.gb-gaw-count{position:fixed;left:50%;bottom:16px;transform:translate(-50%)}.gb-gaw-count b{display:inline-block;width:8px;height:8px;border-radius:50%}
|
package/src/gem-at-work.ts
CHANGED
|
@@ -71,6 +71,12 @@ export interface GemActivity {
|
|
|
71
71
|
* check (the reader's count of an edit's fields or a check's findings). The crew follows it: the trades with the most work walk
|
|
72
72
|
* beside Gem and say what they fix. Optional, so a v1 reader that never says it still reads as v1. */
|
|
73
73
|
trades?: Partial<Record<GemTrade, number>>;
|
|
74
|
+
/** What Gem is doing here, in one short line from the step itself ("Like the original: 61%", "Saved the page (revision 4)"),
|
|
75
|
+
* drawn by the work (Chris 08/11: a visual narration that shows what the system is doing, not effects to pass the time). */
|
|
76
|
+
say?: string;
|
|
77
|
+
/** How far the turn's goal is, measured, not guessed (a clone's likeness to its original, sections built): drawn as a meter
|
|
78
|
+
* with where it started this turn. `unit: "%"` reads `done` as a percent of `total`. */
|
|
79
|
+
goal?: { label: string; done: number; total: number; unit?: "%" };
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
/** The crew's trades, as an activity names them (`trades`). */
|
|
@@ -152,6 +158,14 @@ const BESIDE: Record<Role, string> = { lead: "working", copy: "reading", layout:
|
|
|
152
158
|
* the work ahead of the usual pair, walks more often, and says what it fixes. */
|
|
153
159
|
const HEAT_HALF_MS = 45_000;
|
|
154
160
|
const HEAT_MIN = 0.75;
|
|
161
|
+
/** WHILE SECTIONS ARE BUILT, MANY HANDS (Chris 08/11, the reel "AI agents build my website": a couple of dozen cursors at once, a
|
|
162
|
+
* block in under a second, rulers, guides and "+" where the next goes). Up to this many blocks go at once, the extra hands are
|
|
163
|
+
* arrows in their trade's colour with no tag, and each block goes this much quicker than a calm build's. */
|
|
164
|
+
const BUILD_LANES = 8;
|
|
165
|
+
const HANDS_MAX = 6;
|
|
166
|
+
const BUILD_PACE = 1.6;
|
|
167
|
+
/** What one of the crew says while it goes over a block (`inspect`): its own trade's look at it (the copy expert reads the words). */
|
|
168
|
+
const LOOKING: Record<Role, string> = { lead: "working", copy: "reading", layout: "checking the spacing", image: "checking the picture", cro: "checking the button", check: "checking", style: "checking the look" };
|
|
155
169
|
const FIXING: Record<Role, string> = { lead: "working", copy: "fixing the words", layout: "fixing the layout", image: "fixing the pictures", cro: "fixing the buttons", check: "checking again", style: "fixing the look" };
|
|
156
170
|
/** The crew walks this long after Gem last said anything; past it a turn has gone silent (a tab left open), and it stands. */
|
|
157
171
|
const STROLL_MS = 360_000;
|
|
@@ -304,6 +318,18 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
304
318
|
const walked = new Map<Member, number>();
|
|
305
319
|
/** How much work each trade has had lately (activities' `trades`), cooling by half every HEAT_HALF_MS. */
|
|
306
320
|
const heat = new Map<Role, { v: number; at: number }>();
|
|
321
|
+
/** Who is going over a block, until when; and how far each trade has gone down its list of blocks. */
|
|
322
|
+
const inspecting = new Map<Member, number>();
|
|
323
|
+
/** The build's extra hands, its ruler, its counter (blocks built of how many), and the "+" where the next blocks go. */
|
|
324
|
+
let hands: Member[] = [];
|
|
325
|
+
let ruler: HTMLElement | null = null, counter: HTMLElement | null = null;
|
|
326
|
+
let built = { done: 0, total: 0 };
|
|
327
|
+
const plus = new Map<HTMLElement, HTMLElement>();
|
|
328
|
+
const looked = new Map<Role, number>();
|
|
329
|
+
/** The line by the work (`say`), and the goal's meter in the corner (`goal`) with what it read when the turn first said it. */
|
|
330
|
+
let sayEl: HTMLElement | null = null;
|
|
331
|
+
let goalEl: HTMLElement | null = null;
|
|
332
|
+
let goalAt: { label: string; from: number; frac: number } | null = null;
|
|
307
333
|
/** The one at work on the stage now, and QA while it rides a sweep to its end. */
|
|
308
334
|
let atWork: Member | undefined;
|
|
309
335
|
let riding: Member | null = null;
|
|
@@ -471,6 +497,7 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
471
497
|
m.anim?.cancel();
|
|
472
498
|
const d = ms ?? Math.max(200, Math.min(560, 180 + Math.hypot(x - m.x, y - m.y) * 0.35));
|
|
473
499
|
m.x = x; m.y = y;
|
|
500
|
+
faceIn(m);
|
|
474
501
|
const to = `translate(${x}px,${y}px)`;
|
|
475
502
|
m.anim = move(m.el, [{ transform: from === "none" ? to : from }, { transform: to }], d);
|
|
476
503
|
}
|
|
@@ -492,7 +519,8 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
492
519
|
beside.forEach((m, i) => {
|
|
493
520
|
const p = waypoint(i, walked.get(m) ?? 0);
|
|
494
521
|
say(m, heatOf(m.role) >= HEAT_MIN ? FIXING[m.role] : BESIDE[m.role]);
|
|
495
|
-
|
|
522
|
+
// One coming on flies in from the middle of the screen, as the reel's crew does.
|
|
523
|
+
if (m.resting) { m.anim?.cancel(); const v = view(); m.x = v.x + v.w / 2; m.y = v.y + v.h / 2; m.el.style.transform = `translate(${m.x}px,${m.y}px)`; wake(m); travel(m, p.x, p.y, 520); } else travel(m, p.x, p.y, 600);
|
|
496
524
|
});
|
|
497
525
|
const lead = crew.find((m) => m.role === "lead");
|
|
498
526
|
if (lead) { const p = waypoint(2, walked.get(lead) ?? 0); travel(lead, p.x, p.y, 500); }
|
|
@@ -509,7 +537,8 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
509
537
|
if (i === 1) return { x: Math.min(roomRight, r.x + r.w + 12), y: top + (bottom - top) * along };
|
|
510
538
|
return { x: Math.min(roomRight, r.x + r.w * (0.42 + 0.4 * (1 - along))), y: Math.max(r.y - 40, v.y + bar + 6) };
|
|
511
539
|
}
|
|
512
|
-
/** A beat: the next of them
|
|
540
|
+
/** A beat: the next of them goes over a block of its trade where the work is (`inspect`), or, with none to look at, takes its
|
|
541
|
+
* next steps along its edge. Gem keeps above the work. */
|
|
513
542
|
function strollNext() {
|
|
514
543
|
if (!stage) return;
|
|
515
544
|
const lead = crew.find((m) => m.role === "lead");
|
|
@@ -519,11 +548,77 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
519
548
|
beat += 1;
|
|
520
549
|
const m = walkers[beat % Math.max(1, walkers.length)];
|
|
521
550
|
if (!m || onBlock.has(m)) return;
|
|
551
|
+
if (m !== lead && pace && !revealing && inspect(m)) return;
|
|
522
552
|
const steps = (walked.get(m) ?? 0) + 1;
|
|
523
553
|
walked.set(m, steps);
|
|
524
554
|
const p = waypoint(m === lead ? 2 : beside.indexOf(m), steps);
|
|
525
555
|
travel(m, p.x, p.y, 1500);
|
|
526
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* ONE OF THE CREW GOES OVER A BLOCK OF ITS TRADE WHERE THE WORK IS (Chris 08/11: "chuột di chuyển lờ đờ sang ngang hoặc theo chiều
|
|
559
|
+
* dọc… không còn thú vị"; the first demos had them at the blocks, dragging boxes). The copy expert goes to the words, the image
|
|
560
|
+
* expert to the pictures, CRO to the buttons, layout and styling to the frames: along a curve to the block's corner, pressed, a
|
|
561
|
+
* box dragged round it with its four handles, held a moment, let go. It stands at the corners, never on the words; it says what
|
|
562
|
+
* it looks at, or what it fixes while its trade is warm. True while it is still at it.
|
|
563
|
+
*/
|
|
564
|
+
function inspect(m: Member): boolean {
|
|
565
|
+
const t = now();
|
|
566
|
+
if ((inspecting.get(m) ?? 0) > t) return true;
|
|
567
|
+
const near = blocksAt(stage!);
|
|
568
|
+
// Its own kind of block first, then any it may take; QA checks whatever is there.
|
|
569
|
+
const own = near.filter((b) => TAKERS[b.kind][0] === m.role);
|
|
570
|
+
const list = m.role === "check" ? near : own.length ? own : near.filter((b) => TAKERS[b.kind].includes(m.role));
|
|
571
|
+
if (!list.length) return false;
|
|
572
|
+
const n = (looked.get(m.role) ?? -1) + 1;
|
|
573
|
+
looked.set(m.role, n);
|
|
574
|
+
const b = list[n % list.length]!, bx = box(b.el);
|
|
575
|
+
const go = 520 + ((beat * 37) % 5) * 70, drag = Math.max(420, Math.min(820, 240 + (bx.w + bx.h) * 0.3));
|
|
576
|
+
inspecting.set(m, t + (go + drag + 1100) * pace);
|
|
577
|
+
say(m, heatOf(m.role) >= HEAT_MIN ? FIXING[m.role] : m.role === "copy" && b.kind === "heading" ? "reading the headline" : LOOKING[m.role]);
|
|
578
|
+
arc(m, bx.x - 6, bx.y - 6, go);
|
|
579
|
+
later(() => {
|
|
580
|
+
if (!crew.includes(m) || m.resting || onBlock.has(m) || revealing || !b.el.isConnected) return;
|
|
581
|
+
m.el.querySelector("svg")?.animate([{ transform: "scale(1)" }, { transform: "scale(.82)", offset: 0.12 }, { transform: "scale(.82)", offset: 0.9 }, { transform: "scale(1)" }],
|
|
582
|
+
{ duration: (drag + 160) * pace, easing: EASE });
|
|
583
|
+
travel(m, bx.x + bx.w + 6, bx.y + bx.h + 6, drag);
|
|
584
|
+
const sel = piece("gb-gaw__sel", bx);
|
|
585
|
+
sel.innerHTML = "<i></i><i></i><i></i><i></i>";
|
|
586
|
+
move(sel, [{ clipPath: "inset(-5px 100% 100% -5px)" }, { clipPath: "inset(-5px -5px -5px -5px)" }], drag);
|
|
587
|
+
later(() => gone(sel, 320), (drag + 650) * pace);
|
|
588
|
+
}, go * pace);
|
|
589
|
+
return true;
|
|
590
|
+
}
|
|
591
|
+
/** The blocks the screen shows in the sections where the work is: each block with no block inside, and a frame that paints. */
|
|
592
|
+
function blocksAt(r: Box): Array<{ el: HTMLElement; kind: BlockKind }> {
|
|
593
|
+
const v = view(), top = v.y + topBar(), out: Array<{ el: HTMLElement; kind: BlockKind }> = [];
|
|
594
|
+
for (const s of topSections()) {
|
|
595
|
+
const sb = box(s);
|
|
596
|
+
if (sb.y > r.y + r.h || sb.y + sb.h < r.y) continue;
|
|
597
|
+
for (const b of s.querySelectorAll<HTMLElement>("[data-gem-el-id]")) {
|
|
598
|
+
const holder = !!b.querySelector("[data-gem-el-id]");
|
|
599
|
+
if ((holder && !paints(b)) || !b.getClientRects().length) continue;
|
|
600
|
+
const bb = box(b);
|
|
601
|
+
if (bb.w < 24 || bb.h < 12 || bb.y < top || bb.y + bb.h > v.y + v.h - 40 || bb.x < v.x || bb.x + bb.w > v.x + v.w) continue;
|
|
602
|
+
out.push({ el: b, kind: holder ? "frame" : kindOfBlock(b) });
|
|
603
|
+
if (out.length >= 40) return out;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return out;
|
|
607
|
+
}
|
|
608
|
+
/** Near the right edge of the screen its tag goes on its left, so it is never cut off. */
|
|
609
|
+
function faceIn(m: Member) { const v = view(); m.el.classList.toggle("is-left", m.x > v.x + v.w - 240); }
|
|
610
|
+
/** A walk on a curve, bending one way then the other, as a hand moves a mouse. */
|
|
611
|
+
function arc(m: Member, x: number, y: number, ms: number) {
|
|
612
|
+
const fromX = m.x, fromY = m.y, dx = x - fromX, dy = y - fromY, len = Math.hypot(dx, dy) || 1;
|
|
613
|
+
const bend = Math.min(90, len * 0.22) * (beat % 2 ? 1 : -1);
|
|
614
|
+
const mx = (fromX + x) / 2 - (dy / len) * bend, my = (fromY + y) / 2 + (dx / len) * bend;
|
|
615
|
+
const from = getComputedStyle(m.el).transform;
|
|
616
|
+
m.anim?.cancel();
|
|
617
|
+
m.x = x; m.y = y;
|
|
618
|
+
faceIn(m);
|
|
619
|
+
m.anim = move(m.el, [{ transform: from === "none" ? `translate(${fromX}px,${fromY}px)` : from }, { transform: `translate(${mx}px,${my}px)`, offset: 0.5 },
|
|
620
|
+
{ transform: `translate(${x}px,${y}px)` }], ms);
|
|
621
|
+
}
|
|
527
622
|
|
|
528
623
|
function markFor(a: GemActivity): Mark | null {
|
|
529
624
|
const t = a.target ?? (a.created ? {} : undefined);
|
|
@@ -789,6 +884,8 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
789
884
|
stopTicker();
|
|
790
885
|
step = "";
|
|
791
886
|
if (!queue.length) hideSkip();
|
|
887
|
+
// The last line and the goal stay a moment past the light, then go with the crew.
|
|
888
|
+
unnarrate(1200);
|
|
792
889
|
leave();
|
|
793
890
|
}
|
|
794
891
|
function leave() {
|
|
@@ -822,6 +919,10 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
822
919
|
const was = sections.map((e) => ({ e, opacity: e.style.opacity, clip: e.style.clipPath }));
|
|
823
920
|
revealing = was;
|
|
824
921
|
for (const e of sections) e.style.opacity = "0";
|
|
922
|
+
// The build's ruler across the top, and its counter: the blocks it builds, as many as there are.
|
|
923
|
+
built = { done: 0, total: sections.reduce((t, e) => t + buildable(e).size, 0) };
|
|
924
|
+
if (pace && mode === "full") showRuler();
|
|
925
|
+
count(0);
|
|
825
926
|
who("lead");
|
|
826
927
|
tellStep("building the page");
|
|
827
928
|
showSkip();
|
|
@@ -835,8 +936,7 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
835
936
|
const all = [...e.querySelectorAll<HTMLElement>("[data-gem-el-id]")].filter((b) => b.getClientRects().length > 0);
|
|
836
937
|
const leaves = all.filter((b) => !b.querySelector("[data-gem-el-id]"));
|
|
837
938
|
const holders = all.filter((b) => b.querySelector("[data-gem-el-id]"));
|
|
838
|
-
const kinds =
|
|
839
|
-
for (const f of holders) if (paints(f)) kinds.set(f, "frame");
|
|
939
|
+
const kinds = buildable(e);
|
|
840
940
|
const own = new Map<HTMLElement, string>();
|
|
841
941
|
for (const b of all) { own.set(b, b.style.opacity); was.push({ e: b, opacity: b.style.opacity, clip: b.style.clipPath }); b.style.opacity = "0"; }
|
|
842
942
|
for (const f of holders) if (!kinds.has(f)) f.style.opacity = own.get(f) ?? "";
|
|
@@ -849,8 +949,8 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
849
949
|
}
|
|
850
950
|
if (typeof e.animate === "function") e.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 300 / hurry, easing: EASE });
|
|
851
951
|
await wait(360 / hurry);
|
|
852
|
-
// A section of many blocks goes quicker per block (eight blocks' time at most at full pace).
|
|
853
|
-
const quick = hurry * Math.max(1, kinds.size / 8);
|
|
952
|
+
// A section of many blocks goes quicker per block (eight blocks' time at most at full pace), and many hands quicker still.
|
|
953
|
+
const quick = hurry * BUILD_PACE * Math.max(1, kinds.size / 8);
|
|
854
954
|
// A screenful at a time, each through the whole order, so the page only ever moves down.
|
|
855
955
|
for (const band of bandsOf([...kinds.keys()])) {
|
|
856
956
|
const area = bandBox(band);
|
|
@@ -864,16 +964,19 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
864
964
|
// being as it is dragged out. The expert for this step at it, two trades beside it; the next block starts once this
|
|
865
965
|
// one's box is out, one to three hands by how many there are.
|
|
866
966
|
onStage(area, who(TAKERS[kind][0]));
|
|
867
|
-
|
|
967
|
+
// Many hands: a lane for every block, up to BUILD_LANES, each starting a moment after the last; the next few marked "+".
|
|
968
|
+
const lanes = Math.min(BUILD_LANES, group.length);
|
|
868
969
|
const going = new Set<Promise<void>>();
|
|
869
|
-
for (const b of group) {
|
|
970
|
+
for (const [at, b] of group.entries()) {
|
|
870
971
|
if (revealing !== was) return;
|
|
972
|
+
for (const next of group.slice(at + 1, at + 4)) markNext(next);
|
|
973
|
+
plus.get(b)?.remove(); plus.delete(b);
|
|
871
974
|
while (going.size >= lanes) await Promise.race(going);
|
|
872
975
|
let out = () => {};
|
|
873
976
|
const boxOut = new Promise<void>((done) => { out = done; });
|
|
874
|
-
const job: Promise<void> = buildBlock(b, kind, own.get(b) ?? "", quick, () => out()).finally(() => { going.delete(job); out(); });
|
|
977
|
+
const job: Promise<void> = buildBlock(b, kind, own.get(b) ?? "", quick, () => out()).finally(() => { going.delete(job); out(); count(1); });
|
|
875
978
|
going.add(job);
|
|
876
|
-
await boxOut;
|
|
979
|
+
await Promise.race([boxOut, wait(140 / quick)]);
|
|
877
980
|
}
|
|
878
981
|
await Promise.all(going);
|
|
879
982
|
}
|
|
@@ -886,12 +989,20 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
886
989
|
if (revealing !== was) return;
|
|
887
990
|
for (const { e, opacity, clip } of was) { e.style.opacity = opacity; e.style.clipPath = clip; }
|
|
888
991
|
revealing = null;
|
|
992
|
+
unbuild();
|
|
889
993
|
// More of the turn to draw: the crew stays on it.
|
|
890
994
|
if (queue.length) return;
|
|
891
995
|
stopTicker();
|
|
892
996
|
hideSkip();
|
|
893
997
|
leave();
|
|
894
998
|
}
|
|
999
|
+
/** What a section's build draws, block by block: each block holding no block, by its kind, and each frame that paints. */
|
|
1000
|
+
function buildable(e: Element): Map<HTMLElement, BlockKind> {
|
|
1001
|
+
const all = [...e.querySelectorAll<HTMLElement>("[data-gem-el-id]")].filter((b) => b.getClientRects().length > 0);
|
|
1002
|
+
const kinds = new Map<HTMLElement, BlockKind>(all.filter((b) => !b.querySelector("[data-gem-el-id]")).map((b) => [b, kindOfBlock(b)]));
|
|
1003
|
+
for (const f of all) if (f.querySelector("[data-gem-el-id]") && paints(f)) kinds.set(f, "frame");
|
|
1004
|
+
return kinds;
|
|
1005
|
+
}
|
|
895
1006
|
/** A section's blocks by the screenful, from the top: a section taller than the screen is built a part at a time. */
|
|
896
1007
|
function bandsOf(blocks: HTMLElement[]): HTMLElement[][] {
|
|
897
1008
|
const tall = Math.min(win.innerHeight, 1000) * 0.85, bands: HTMLElement[][] = [];
|
|
@@ -912,7 +1023,62 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
912
1023
|
const m = free.find((x) => x.role === role);
|
|
913
1024
|
if (m) { wake(m); return m; }
|
|
914
1025
|
}
|
|
915
|
-
|
|
1026
|
+
// The crew all busy: one of the trade's extra hands, a free one or a new one flown in from the middle of the screen.
|
|
1027
|
+
const role = TAKERS[kind][0];
|
|
1028
|
+
const spare = hands.find((h) => h.role === role && !onBlock.has(h));
|
|
1029
|
+
if (spare) { wake(spare); return spare; }
|
|
1030
|
+
if (!crew.length || !pace || hands.length >= HANDS_MAX) return undefined;
|
|
1031
|
+
const c = CREW.find((x) => x.role === role)!, v = view(), el = doc.createElement("div");
|
|
1032
|
+
el.className = "gb-gaw__cursor is-hand";
|
|
1033
|
+
el.style.setProperty("--c", c.c);
|
|
1034
|
+
el.innerHTML = ARROW;
|
|
1035
|
+
ensureLayer().append(el);
|
|
1036
|
+
const x = v.x + v.w / 2, y = v.y + v.h / 2;
|
|
1037
|
+
el.style.transform = `translate(${x}px,${y}px)`;
|
|
1038
|
+
move(el, [{ opacity: "0" }, { opacity: "1" }], 200);
|
|
1039
|
+
const m: Member = { ...c, el, tag: doc.createElement("span"), x, y, anim: null, fade: null, resting: false };
|
|
1040
|
+
hands.push(m);
|
|
1041
|
+
return m;
|
|
1042
|
+
}
|
|
1043
|
+
/** A "+" at the corner of a block whose turn is next: where it is about to go. */
|
|
1044
|
+
function markNext(b: HTMLElement) {
|
|
1045
|
+
if (plus.has(b) || !pace || mode !== "full") return;
|
|
1046
|
+
const bx = box(b), p = piece("gb-gaw__plus", { x: bx.x - 6, y: bx.y - 6, w: 12, h: 12 });
|
|
1047
|
+
p.textContent = "+";
|
|
1048
|
+
move(p, [{ opacity: "0" }, { opacity: "1" }], 160);
|
|
1049
|
+
plus.set(b, p);
|
|
1050
|
+
}
|
|
1051
|
+
/** The build's counter at the foot of the screen: its hands, in their trades' colours, and the blocks built of how many. */
|
|
1052
|
+
function count(k: number) {
|
|
1053
|
+
built.done += k;
|
|
1054
|
+
if (!built.total || mode !== "full") return;
|
|
1055
|
+
if (!counter) { counter = doc.createElement("div"); counter.className = "gb-gaw-count"; counter.setAttribute("aria-hidden", "true"); root.append(counter); }
|
|
1056
|
+
const at = [...crew.filter((m) => !m.resting), ...hands];
|
|
1057
|
+
const dots = at.slice(0, 8).map((m) => { const d = doc.createElement("b"); d.style.background = CREW.find((c) => c.role === m.role)!.c; return d; });
|
|
1058
|
+
const bar = doc.createElement("i");
|
|
1059
|
+
counter.replaceChildren(...dots, doc.createTextNode(` ${at.length} at work · ${Math.min(built.done, built.total)} / ${built.total} blocks`), bar);
|
|
1060
|
+
bar.style.transform = `scaleX(${Math.min(1, built.done / built.total)})`;
|
|
1061
|
+
}
|
|
1062
|
+
/** A pixel ruler across the top of the screen while sections are built, as a design tool has (under a bar that sticks to the top). */
|
|
1063
|
+
function showRuler() {
|
|
1064
|
+
if (ruler) return;
|
|
1065
|
+
ruler = doc.createElement("div");
|
|
1066
|
+
ruler.className = "gb-gaw-ruler";
|
|
1067
|
+
ruler.setAttribute("aria-hidden", "true");
|
|
1068
|
+
ruler.style.top = `${topBar()}px`;
|
|
1069
|
+
for (let x = 100; x < win.innerWidth; x += 100) { const t = doc.createElement("span"); t.textContent = String(x); t.style.left = `${x + 2}px`; ruler.append(t); }
|
|
1070
|
+
root.append(ruler);
|
|
1071
|
+
move(ruler, [{ opacity: "0" }, { opacity: "1" }], 240);
|
|
1072
|
+
}
|
|
1073
|
+
/** The build's extra hands, its ruler, counter and "+" go (its end, a skip). */
|
|
1074
|
+
function unbuild() {
|
|
1075
|
+
for (const h of hands) gone(h.el, 260);
|
|
1076
|
+
hands = [];
|
|
1077
|
+
for (const p of plus.values()) p.remove();
|
|
1078
|
+
plus.clear();
|
|
1079
|
+
ruler?.remove(); ruler = null;
|
|
1080
|
+
counter?.remove(); counter = null;
|
|
1081
|
+
built = { done: 0, total: 0 };
|
|
916
1082
|
}
|
|
917
1083
|
/** One block of the saved page, as the board draws it: the expert goes to its top-left corner, holds the mouse down and drags its
|
|
918
1084
|
* box out to the bottom-right corner, its size shown once it is out; then its words wipe in from the left behind a caret, or,
|
|
@@ -936,6 +1102,11 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
936
1102
|
}
|
|
937
1103
|
const sel = piece("gb-gaw__sel", bx);
|
|
938
1104
|
sel.innerHTML = "<i></i><i></i><i></i><i></i>";
|
|
1105
|
+
// The guides a design tool draws while a box is dragged: across the screen from its top edge and its left edge.
|
|
1106
|
+
if (mode === "full") {
|
|
1107
|
+
const v = view();
|
|
1108
|
+
for (const g of [piece("gb-gaw__guide", { x: v.x, y: bx.y, w: v.w, h: 1 }), piece("gb-gaw__guide", { x: bx.x, y: v.y, w: 1, h: v.h })]) later(() => gone(g, 240), drag + 200);
|
|
1109
|
+
}
|
|
939
1110
|
const grow = [{ clipPath: "inset(-5px 100% 100% -5px)" }, { clipPath: "inset(-5px -5px -5px -5px)" }];
|
|
940
1111
|
const tint = picture ? piece("gb-gaw__veil", bx) : null;
|
|
941
1112
|
move(sel, grow, drag);
|
|
@@ -1032,6 +1203,40 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
1032
1203
|
}
|
|
1033
1204
|
}
|
|
1034
1205
|
/** Gem's tag: the step it is on; quiet for a while, the step's real seconds ("Generating a picture · 12s"). */
|
|
1206
|
+
/** A line by the work: what Gem is doing there, in the step's own words. */
|
|
1207
|
+
function narrate(text: string) {
|
|
1208
|
+
if (!sayEl) { sayEl = doc.createElement("div"); sayEl.className = "gb-gaw__say"; ensureLayer().append(sayEl); }
|
|
1209
|
+
if (sayEl.textContent !== text) { sayEl.textContent = text; move(sayEl, [{ opacity: "0" }, { opacity: "1" }], 220); }
|
|
1210
|
+
placeSay();
|
|
1211
|
+
}
|
|
1212
|
+
/** Just above the work (or where the person is looking before there is any), inside the screen and under a sticky bar. */
|
|
1213
|
+
function placeSay() {
|
|
1214
|
+
if (!sayEl) return;
|
|
1215
|
+
const v = view(), bar = topBar(), r = stage ?? { x: v.x + 24, y: v.y + bar + 60, w: 0, h: 0 };
|
|
1216
|
+
const x = Math.max(v.x + 12, Math.min(r.x, v.x + v.w - Math.min(440, sayEl.offsetWidth + 12)));
|
|
1217
|
+
// Above the work; with no room above it, under the ring's own label at its top edge.
|
|
1218
|
+
const y = r.y - 34 >= v.y + bar + 8 ? r.y - 34 : Math.min(Math.max(r.y, v.y + bar) + 30, v.y + v.h - 96);
|
|
1219
|
+
sayEl.style.transform = `translate(${Math.round(x)}px,${Math.round(y)}px)`;
|
|
1220
|
+
}
|
|
1221
|
+
/** The goal's meter: its label, where it started this turn and where it is now, and a bar that moves from one to the other. */
|
|
1222
|
+
function showGoal(g: NonNullable<GemActivity["goal"]>) {
|
|
1223
|
+
if (!g || typeof g.label !== "string" || !g.label || !(g.total > 0) || !(g.done >= 0)) return;
|
|
1224
|
+
const frac = Math.max(0, Math.min(1, g.done / g.total)), pct = g.unit === "%";
|
|
1225
|
+
if (goalAt?.label !== g.label) goalAt = { label: g.label, from: g.done, frac };
|
|
1226
|
+
if (!goalEl) { goalEl = doc.createElement("div"); goalEl.className = "gb-gaw-goal"; goalEl.setAttribute("aria-hidden", "true"); root.append(goalEl); }
|
|
1227
|
+
const at = pct ? `${Math.round(g.done)}%` : `${g.done}/${g.total}`;
|
|
1228
|
+
const was = pct && Math.round(goalAt.from) !== Math.round(g.done) ? `${Math.round(goalAt.from)}% → ` : "";
|
|
1229
|
+
const bar = doc.createElement("i");
|
|
1230
|
+
goalEl.replaceChildren(doc.createTextNode(`${g.label} ${was}${at}`), bar);
|
|
1231
|
+
move(bar, [{ transform: `scaleX(${goalAt.frac})` }, { transform: `scaleX(${frac})` }], 700);
|
|
1232
|
+
goalAt.frac = frac;
|
|
1233
|
+
}
|
|
1234
|
+
/** The line and the meter go: with the turn (after the light) or at once (Skip). */
|
|
1235
|
+
function unnarrate(after = 0) {
|
|
1236
|
+
if (sayEl) { if (after) gone(sayEl, 300, after); else sayEl.remove(); sayEl = null; }
|
|
1237
|
+
if (goalEl) { if (after) gone(goalEl, 400, after + 1000); else goalEl.remove(); goalEl = null; }
|
|
1238
|
+
goalAt = null;
|
|
1239
|
+
}
|
|
1035
1240
|
function tellStep(text: string) {
|
|
1036
1241
|
step = text;
|
|
1037
1242
|
const lead = crew.find((m) => m.role === "lead");
|
|
@@ -1092,6 +1297,11 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
1092
1297
|
// A check, a save or a refusal that says where the work is changes who walks beside it now (the others move the stage
|
|
1093
1298
|
// themselves; while a section is built its blocks have their own hands).
|
|
1094
1299
|
if (a.trades && stage && !revealing && (a.kind === "check" || a.kind === "apply" || a.kind === "fail")) onStage(stage, atWork);
|
|
1300
|
+
// What the step says it is doing, by the work; how far the goal is, in the corner. A landing has its own way out (land).
|
|
1301
|
+
if (a.kind !== "land") {
|
|
1302
|
+
if (typeof a.say === "string" && a.say.trim()) narrate(a.say.trim().slice(0, 120)); else placeSay();
|
|
1303
|
+
if (a.goal) showGoal(a.goal);
|
|
1304
|
+
}
|
|
1095
1305
|
} catch {
|
|
1096
1306
|
// The bottom of the ladder: the page as it is.
|
|
1097
1307
|
options.onFallback?.("page", a);
|
|
@@ -1104,6 +1314,8 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
1104
1314
|
timers.clear();
|
|
1105
1315
|
stopTicker();
|
|
1106
1316
|
hideSkip();
|
|
1317
|
+
unnarrate();
|
|
1318
|
+
unbuild();
|
|
1107
1319
|
// The calm clock stops where it is: nothing queued is drawn, and whoever waits on it is let go.
|
|
1108
1320
|
epoch += 1;
|
|
1109
1321
|
draining = false;
|