@gemboss/ui 0.63.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 +98 -0
- package/README.md +98 -4
- package/catalog/editor.html +1 -1
- package/catalog/index.html +23 -20
- package/gemboss-ui.css +2 -2
- package/package.json +9 -1
- package/parts/components.css +1 -1
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/assistant/chat.tsx +67 -4
- package/src/assistant/dictation.ts +292 -0
- package/src/assistant/index.ts +4 -1
- package/src/audiences-table.css +1 -0
- package/src/audiences-table.tsx +167 -0
- package/src/chat-voice.css +1 -0
- 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 +462 -0
- package/src/email-editor/index.ts +16 -0
- package/src/email-editor/model.ts +361 -0
- package/src/email-editor/preview.tsx +208 -0
- package/src/email-editor.css +1 -0
- package/src/gem-at-work.css +1 -1
- package/src/gem-at-work.ts +273 -15
- package/src/index.ts +2 -1
- package/src/list-page.tsx +87 -4
- package/src/skill-feedback.css +1 -1
- package/src/skill-feedback.tsx +5 -1
- package/src/skill-history.tsx +2 -1
package/src/gem-at-work.ts
CHANGED
|
@@ -67,8 +67,21 @@ export interface GemActivity {
|
|
|
67
67
|
/** draft: a section this turn is adding (an `add` op), not on the page yet. Optional, so a v1 reader that never says it still
|
|
68
68
|
* reads as v1; a page built from scratch stacks these one below the other. */
|
|
69
69
|
created?: true;
|
|
70
|
+
/** Where the work is, by trade: how much of what this step touched or found is words, layout, pictures, buttons, the look, or a
|
|
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
|
+
* beside Gem and say what they fix. Optional, so a v1 reader that never says it still reads as v1. */
|
|
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?: "%" };
|
|
70
80
|
}
|
|
71
81
|
|
|
82
|
+
/** The crew's trades, as an activity names them (`trades`). */
|
|
83
|
+
export type GemTrade = "copy" | "layout" | "image" | "cro" | "check" | "style";
|
|
84
|
+
|
|
72
85
|
/** Where a target was drawn: the block it names, its section, the place after a section (a section on its way), or the page. */
|
|
73
86
|
export type GemAtWorkLevel = "element" | "section" | "after" | "page";
|
|
74
87
|
|
|
@@ -140,6 +153,20 @@ const ALONGSIDE: Record<Role, Role[]> = {
|
|
|
140
153
|
lead: ["copy", "layout"], copy: ["layout", "check"], layout: ["style", "check"], image: ["style", "layout"], cro: ["copy", "check"], check: ["layout", "style"], style: ["layout", "image"],
|
|
141
154
|
};
|
|
142
155
|
const BESIDE: Record<Role, string> = { lead: "working", copy: "reading", layout: "arranging", image: "looking", cro: "optimizing", check: "auto-checking", style: "tuning" };
|
|
156
|
+
/** WHERE THE WORK IS, THE CREW IS (Chris 06/11: "vấn đề ở đâu nhiều thì con trỏ liên quan hoạt động nhiều hơn"). Each trade an
|
|
157
|
+
* activity names (`trades`) warms up by its count and cools by half every HEAT_HALF_MS; one at least HEAT_MIN warm comes beside
|
|
158
|
+
* the work ahead of the usual pair, walks more often, and says what it fixes. */
|
|
159
|
+
const HEAT_HALF_MS = 45_000;
|
|
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" };
|
|
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" };
|
|
143
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. */
|
|
144
171
|
const STROLL_MS = 360_000;
|
|
145
172
|
/** Quiet this long and Gem's tag counts the step's seconds. */
|
|
@@ -289,6 +316,20 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
289
316
|
let beside: Member[] = [];
|
|
290
317
|
let beat = 0;
|
|
291
318
|
const walked = new Map<Member, number>();
|
|
319
|
+
/** How much work each trade has had lately (activities' `trades`), cooling by half every HEAT_HALF_MS. */
|
|
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;
|
|
292
333
|
/** The one at work on the stage now, and QA while it rides a sweep to its end. */
|
|
293
334
|
let atWork: Member | undefined;
|
|
294
335
|
let riding: Member | null = null;
|
|
@@ -409,6 +450,26 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
409
450
|
return crew;
|
|
410
451
|
}
|
|
411
452
|
function say(m: Member, doing?: string) { m.tag.textContent = m.role === "lead" && !doing ? m.name : `${m.name} · ${doing ?? m.doing}`; }
|
|
453
|
+
/** How much work a trade has had lately, as of now. */
|
|
454
|
+
function heatOf(role: Role, t = now()): number {
|
|
455
|
+
const h = heat.get(role);
|
|
456
|
+
return h ? h.v * 0.5 ** ((t - h.at) / HEAT_HALF_MS) : 0;
|
|
457
|
+
}
|
|
458
|
+
/** The trades warm enough to come beside the work, the warmest first. */
|
|
459
|
+
function hottest(): Role[] {
|
|
460
|
+
const t = now();
|
|
461
|
+
return CREW.map((c) => c.role).filter((r) => r !== "lead" && heatOf(r, t) >= HEAT_MIN).sort((a, b) => heatOf(b, t) - heatOf(a, t));
|
|
462
|
+
}
|
|
463
|
+
/** What a step says of where its work is (`trades`), counted as it is drawn: at most 5 a step, so one long edit does not hold it. */
|
|
464
|
+
function warm(a: GemActivity) {
|
|
465
|
+
if (!a.trades || typeof a.trades !== "object") return;
|
|
466
|
+
const t = now();
|
|
467
|
+
for (const [trade, n] of Object.entries(a.trades)) {
|
|
468
|
+
const role = trade as Role;
|
|
469
|
+
if (role === "lead" || !(role in BESIDE) || typeof n !== "number" || !(n > 0)) continue;
|
|
470
|
+
heat.set(role, { v: heatOf(role, t) + Math.min(5, n), at: t });
|
|
471
|
+
}
|
|
472
|
+
}
|
|
412
473
|
/** The one whose trade this is, now at work (named, at full strength); Gem with a crew of one. */
|
|
413
474
|
function who(role: Role): Member | undefined {
|
|
414
475
|
const c = arrive(), m = c.find((x) => x.role === role) ?? c[0];
|
|
@@ -436,6 +497,7 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
436
497
|
m.anim?.cancel();
|
|
437
498
|
const d = ms ?? Math.max(200, Math.min(560, 180 + Math.hypot(x - m.x, y - m.y) * 0.35));
|
|
438
499
|
m.x = x; m.y = y;
|
|
500
|
+
faceIn(m);
|
|
439
501
|
const to = `translate(${x}px,${y}px)`;
|
|
440
502
|
m.anim = move(m.el, [{ transform: from === "none" ? to : from }, { transform: to }], d);
|
|
441
503
|
}
|
|
@@ -444,15 +506,21 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
444
506
|
function onStage(r: Box, doer: Member | undefined, alongside = true) {
|
|
445
507
|
stage = r;
|
|
446
508
|
atWork = doer;
|
|
447
|
-
|
|
509
|
+
// The trades with the most work lately come first; the usual pair beside the one at work fills the rest.
|
|
510
|
+
const hot = hottest();
|
|
511
|
+
// Four on the page at most: QA riding a sweep is one of the two.
|
|
512
|
+
const pair = riding && riding !== doer ? 1 : 2;
|
|
513
|
+
const key = `${Math.round(r.x)}|${Math.round(r.y)}|${Math.round(r.w)}|${doer?.role ?? ""}|${alongside}|${hot.slice(0, 2).join(",")}|${pair}`;
|
|
448
514
|
if (key === stageKey || !crew.length) return;
|
|
449
515
|
stageKey = key;
|
|
450
|
-
beside = alongside ? ALONGSIDE[doer?.role ?? "lead"].map((role) => crew.find((m) => m.role === role))
|
|
516
|
+
beside = alongside ? [...new Set([...hot, ...ALONGSIDE[doer?.role ?? "lead"]])].map((role) => crew.find((m) => m.role === role))
|
|
517
|
+
.filter((m): m is Member => !!m && m !== doer && m !== riding && m.role !== "lead" && !onBlock.has(m)).slice(0, pair) : [];
|
|
451
518
|
for (const m of crew) if (m.role !== "lead" && m !== doer && m !== riding && !onBlock.has(m) && !beside.includes(m)) rest(m);
|
|
452
519
|
beside.forEach((m, i) => {
|
|
453
520
|
const p = waypoint(i, walked.get(m) ?? 0);
|
|
454
|
-
say(m, BESIDE[m.role]);
|
|
455
|
-
|
|
521
|
+
say(m, heatOf(m.role) >= HEAT_MIN ? FIXING[m.role] : BESIDE[m.role]);
|
|
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);
|
|
456
524
|
});
|
|
457
525
|
const lead = crew.find((m) => m.role === "lead");
|
|
458
526
|
if (lead) { const p = waypoint(2, walked.get(lead) ?? 0); travel(lead, p.x, p.y, 500); }
|
|
@@ -469,19 +537,88 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
469
537
|
if (i === 1) return { x: Math.min(roomRight, r.x + r.w + 12), y: top + (bottom - top) * along };
|
|
470
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) };
|
|
471
539
|
}
|
|
472
|
-
/** 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. */
|
|
473
542
|
function strollNext() {
|
|
474
543
|
if (!stage) return;
|
|
475
544
|
const lead = crew.find((m) => m.role === "lead");
|
|
476
|
-
|
|
545
|
+
// A trade with more work lately takes more of the beats (up to three turns to Gem's one).
|
|
546
|
+
const walkers = [...beside.filter((m) => !m.resting && !onBlock.has(m)), ...(lead ? [lead] : [])]
|
|
547
|
+
.flatMap((w) => Array<Member>(1 + Math.min(2, Math.floor(heatOf(w.role)))).fill(w));
|
|
477
548
|
beat += 1;
|
|
478
549
|
const m = walkers[beat % Math.max(1, walkers.length)];
|
|
479
550
|
if (!m || onBlock.has(m)) return;
|
|
551
|
+
if (m !== lead && pace && !revealing && inspect(m)) return;
|
|
480
552
|
const steps = (walked.get(m) ?? 0) + 1;
|
|
481
553
|
walked.set(m, steps);
|
|
482
554
|
const p = waypoint(m === lead ? 2 : beside.indexOf(m), steps);
|
|
483
555
|
travel(m, p.x, p.y, 1500);
|
|
484
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
|
+
}
|
|
485
622
|
|
|
486
623
|
function markFor(a: GemActivity): Mark | null {
|
|
487
624
|
const t = a.target ?? (a.created ? {} : undefined);
|
|
@@ -747,6 +884,8 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
747
884
|
stopTicker();
|
|
748
885
|
step = "";
|
|
749
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);
|
|
750
889
|
leave();
|
|
751
890
|
}
|
|
752
891
|
function leave() {
|
|
@@ -780,6 +919,10 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
780
919
|
const was = sections.map((e) => ({ e, opacity: e.style.opacity, clip: e.style.clipPath }));
|
|
781
920
|
revealing = was;
|
|
782
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);
|
|
783
926
|
who("lead");
|
|
784
927
|
tellStep("building the page");
|
|
785
928
|
showSkip();
|
|
@@ -793,8 +936,7 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
793
936
|
const all = [...e.querySelectorAll<HTMLElement>("[data-gem-el-id]")].filter((b) => b.getClientRects().length > 0);
|
|
794
937
|
const leaves = all.filter((b) => !b.querySelector("[data-gem-el-id]"));
|
|
795
938
|
const holders = all.filter((b) => b.querySelector("[data-gem-el-id]"));
|
|
796
|
-
const kinds =
|
|
797
|
-
for (const f of holders) if (paints(f)) kinds.set(f, "frame");
|
|
939
|
+
const kinds = buildable(e);
|
|
798
940
|
const own = new Map<HTMLElement, string>();
|
|
799
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"; }
|
|
800
942
|
for (const f of holders) if (!kinds.has(f)) f.style.opacity = own.get(f) ?? "";
|
|
@@ -807,8 +949,8 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
807
949
|
}
|
|
808
950
|
if (typeof e.animate === "function") e.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 300 / hurry, easing: EASE });
|
|
809
951
|
await wait(360 / hurry);
|
|
810
|
-
// A section of many blocks goes quicker per block (eight blocks' time at most at full pace).
|
|
811
|
-
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);
|
|
812
954
|
// A screenful at a time, each through the whole order, so the page only ever moves down.
|
|
813
955
|
for (const band of bandsOf([...kinds.keys()])) {
|
|
814
956
|
const area = bandBox(band);
|
|
@@ -822,16 +964,19 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
822
964
|
// being as it is dragged out. The expert for this step at it, two trades beside it; the next block starts once this
|
|
823
965
|
// one's box is out, one to three hands by how many there are.
|
|
824
966
|
onStage(area, who(TAKERS[kind][0]));
|
|
825
|
-
|
|
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);
|
|
826
969
|
const going = new Set<Promise<void>>();
|
|
827
|
-
for (const b of group) {
|
|
970
|
+
for (const [at, b] of group.entries()) {
|
|
828
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);
|
|
829
974
|
while (going.size >= lanes) await Promise.race(going);
|
|
830
975
|
let out = () => {};
|
|
831
976
|
const boxOut = new Promise<void>((done) => { out = done; });
|
|
832
|
-
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); });
|
|
833
978
|
going.add(job);
|
|
834
|
-
await boxOut;
|
|
979
|
+
await Promise.race([boxOut, wait(140 / quick)]);
|
|
835
980
|
}
|
|
836
981
|
await Promise.all(going);
|
|
837
982
|
}
|
|
@@ -844,12 +989,20 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
844
989
|
if (revealing !== was) return;
|
|
845
990
|
for (const { e, opacity, clip } of was) { e.style.opacity = opacity; e.style.clipPath = clip; }
|
|
846
991
|
revealing = null;
|
|
992
|
+
unbuild();
|
|
847
993
|
// More of the turn to draw: the crew stays on it.
|
|
848
994
|
if (queue.length) return;
|
|
849
995
|
stopTicker();
|
|
850
996
|
hideSkip();
|
|
851
997
|
leave();
|
|
852
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
|
+
}
|
|
853
1006
|
/** A section's blocks by the screenful, from the top: a section taller than the screen is built a part at a time. */
|
|
854
1007
|
function bandsOf(blocks: HTMLElement[]): HTMLElement[][] {
|
|
855
1008
|
const tall = Math.min(win.innerHeight, 1000) * 0.85, bands: HTMLElement[][] = [];
|
|
@@ -870,7 +1023,62 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
870
1023
|
const m = free.find((x) => x.role === role);
|
|
871
1024
|
if (m) { wake(m); return m; }
|
|
872
1025
|
}
|
|
873
|
-
|
|
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 };
|
|
874
1082
|
}
|
|
875
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
|
|
876
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,
|
|
@@ -894,6 +1102,11 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
894
1102
|
}
|
|
895
1103
|
const sel = piece("gb-gaw__sel", bx);
|
|
896
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
|
+
}
|
|
897
1110
|
const grow = [{ clipPath: "inset(-5px 100% 100% -5px)" }, { clipPath: "inset(-5px -5px -5px -5px)" }];
|
|
898
1111
|
const tint = picture ? piece("gb-gaw__veil", bx) : null;
|
|
899
1112
|
move(sel, grow, drag);
|
|
@@ -990,6 +1203,40 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
990
1203
|
}
|
|
991
1204
|
}
|
|
992
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
|
+
}
|
|
993
1240
|
function tellStep(text: string) {
|
|
994
1241
|
step = text;
|
|
995
1242
|
const lead = crew.find((m) => m.role === "lead");
|
|
@@ -1030,6 +1277,7 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
1030
1277
|
|
|
1031
1278
|
function play(a: GemActivity) {
|
|
1032
1279
|
try {
|
|
1280
|
+
warm(a);
|
|
1033
1281
|
cut();
|
|
1034
1282
|
if (a.kind !== "land") showSkip();
|
|
1035
1283
|
switch (a.kind) {
|
|
@@ -1046,6 +1294,14 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
1046
1294
|
case "fail": settle(a, "is-failed"); options.onStatus?.(a.text ?? a.label); break;
|
|
1047
1295
|
case "land": land(a); break;
|
|
1048
1296
|
}
|
|
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
|
|
1298
|
+
// themselves; while a section is built its blocks have their own hands).
|
|
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
|
+
}
|
|
1049
1305
|
} catch {
|
|
1050
1306
|
// The bottom of the ladder: the page as it is.
|
|
1051
1307
|
options.onFallback?.("page", a);
|
|
@@ -1058,6 +1314,8 @@ export function createGemAtWork(options: GemAtWorkOptions = {}): GemAtWork {
|
|
|
1058
1314
|
timers.clear();
|
|
1059
1315
|
stopTicker();
|
|
1060
1316
|
hideSkip();
|
|
1317
|
+
unnarrate();
|
|
1318
|
+
unbuild();
|
|
1061
1319
|
// The calm clock stops where it is: nothing queued is drawn, and whoever waits on it is let go.
|
|
1062
1320
|
epoch += 1;
|
|
1063
1321
|
draining = false;
|
package/src/index.ts
CHANGED
|
@@ -74,11 +74,12 @@ export { SaveBar, type SaveBarProps } from "./save-bar";
|
|
|
74
74
|
export { RangeBar, rangeBarGeometry, type RangeBarGeometry, type RangeBarProps } from "./range-bar";
|
|
75
75
|
export { ProgressRing, progressRingGeometry, RING_BOX, type ProgressRingGeometry, type ProgressRingProps } from "./progress-ring";
|
|
76
76
|
export { ProgressBar, progressBarValue, type ProgressBarProps, type ProgressBarTone } from "./progress-bar";
|
|
77
|
+
export { AudiencesTable, AudienceSourceChip, AUDIENCES_TABLE_LABELS, audienceCount, audienceDeltaTone, audiencesTableColumns, audiencesTableRows, type AudienceDeltaTone, type AudienceSource, type AudiencesTableLabels, type AudiencesTableProps, type AudiencesTableRow } from "./audiences-table";
|
|
77
78
|
export { SpotArt, SPOT_ART_NAMES, type SpotArtName, type SpotArtProps } from "./spot-art";
|
|
78
79
|
// 04/11/2026 (UI book OF-2): the drawn strip across the top of a "pick a kind" card, the New offer picker's first.
|
|
79
80
|
export { KindArt, KIND_GLYPHS, type KindArtProps, type KindGlyph } from "./kind-art";
|
|
80
81
|
// 05/11/2026 (ADR 0013): Gem at work, what Gem is doing drawn on the page it is doing it to; it reads only the activity contract.
|
|
81
|
-
export { createGemAtWork, GEM_ACTIVITY_VERSION, type GemActivity, type GemActivityKind, type GemActivityScope, type GemActivityTarget, type GemAtWork, type GemAtWorkLevel, type GemAtWorkOptions } from "./gem-at-work";
|
|
82
|
+
export { createGemAtWork, GEM_ACTIVITY_VERSION, type GemActivity, type GemActivityKind, type GemActivityScope, type GemActivityTarget, type GemAtWork, type GemAtWorkLevel, type GemAtWorkOptions, type GemTrade } from "./gem-at-work";
|
|
82
83
|
export { Stage, StageBubble, StageLine, StageTile, StageWindow, type StageTone } from "./stage";
|
|
83
84
|
export { GemHolo } from "./gem-holo";
|
|
84
85
|
export { StartingPoint, type StartingArt, type StartingDoor } from "./starting-point";
|
package/src/list-page.tsx
CHANGED
|
@@ -27,11 +27,52 @@
|
|
|
27
27
|
* `ui-empty--no-match` lives in collections.css (the parts gate holds a component to the CSS it imports).
|
|
28
28
|
*/
|
|
29
29
|
import "./list-page.css";
|
|
30
|
-
import React, { useId } from "react";
|
|
30
|
+
import React, { useEffect, useId, useLayoutEffect, useRef, useSyncExternalStore } from "react";
|
|
31
31
|
import { PageTabs } from "./page-tabs";
|
|
32
32
|
import { Icon } from "./icons";
|
|
33
33
|
import { Menu, MenuGroup, MenuItem, MenuSeparator } from "./menu";
|
|
34
34
|
|
|
35
|
+
// WHERE THE CARD STOOD (02/11/2026). A page's notices, toolbar and the line under its title often come with its read, so they
|
|
36
|
+
// appear above the loading card and push it down: the admin's layout shifts measured in RUM (gemboss_admin_vitals.cls_on), the
|
|
37
|
+
// card of GemSeel's Orders moved 271px on 19 of 96 visits with a CLS of 0.1 or more. With `holdKey` the card's place once read is
|
|
38
|
+
// kept on this device (per key and page width), and while the list loads again the card waits there, the room above it held;
|
|
39
|
+
// what comes with the read fills that room instead of moving the card. A first visit, or one where nothing can be kept, is as
|
|
40
|
+
// before. The place is taken once, as the read lands (what the next read will draw), not later: a banner that comes and goes
|
|
41
|
+
// after (a change made, a failed re-read) would hold room the next visit does not fill (review of #6432).
|
|
42
|
+
const useBeforePaint = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
43
|
+
const HOLDS = "gb.list-hold";
|
|
44
|
+
/** At most this many places are kept, the oldest dropped first. */
|
|
45
|
+
const HOLDS_KEPT = 200;
|
|
46
|
+
// The page's own width (the admin's rail takes some) and which side of 768px it is on: the header's spacing changes there.
|
|
47
|
+
const holdSlot = (key: string, page: Element) => {
|
|
48
|
+
const w = page.getBoundingClientRect().width;
|
|
49
|
+
return `${key}@${window.matchMedia("(min-width: 48em)").matches ? "w" : "n"}${Math.round(w / 40)}`;
|
|
50
|
+
};
|
|
51
|
+
function readHolds(): Record<string, number> {
|
|
52
|
+
try {
|
|
53
|
+
const v = JSON.parse(localStorage.getItem(HOLDS) ?? "{}");
|
|
54
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
55
|
+
} catch {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function readHold(slot: string): number {
|
|
60
|
+
const v = Number(readHolds()[slot]);
|
|
61
|
+
return Number.isFinite(v) && v > 0 ? v : 0;
|
|
62
|
+
}
|
|
63
|
+
function writeHold(slot: string, top: number): void {
|
|
64
|
+
try {
|
|
65
|
+
const holds = readHolds();
|
|
66
|
+
if (holds[slot] === top) return;
|
|
67
|
+
delete holds[slot];
|
|
68
|
+
holds[slot] = top;
|
|
69
|
+
const slots = Object.keys(holds);
|
|
70
|
+
for (const old of slots.slice(0, Math.max(0, slots.length - HOLDS_KEPT))) delete holds[old];
|
|
71
|
+
localStorage.setItem(HOLDS, JSON.stringify(holds));
|
|
72
|
+
} catch { /* a private window keeps nothing: no hold */ }
|
|
73
|
+
}
|
|
74
|
+
const noSubscription = () => () => {};
|
|
75
|
+
|
|
35
76
|
export interface ListPageAction {
|
|
36
77
|
content: string;
|
|
37
78
|
onAction?: () => void;
|
|
@@ -57,7 +98,7 @@ const WIDE_SECONDARY = 2;
|
|
|
57
98
|
|
|
58
99
|
export function ListPage({
|
|
59
100
|
title, subtitle, back, titleMeta, primaryAction, secondaryActions = [], actionGroups = [], notices, toolbar,
|
|
60
|
-
state = "ready", empty, noMatch, error, loadingRows = 3, loadingText = "Loading…", cardTitle, cardMeta, cardLead, card = true, cardProps, after, children, linkAs = "a",
|
|
101
|
+
state = "ready", empty, noMatch, error, loadingRows = 3, loadingText = "Loading…", cardTitle, cardMeta, cardLead, card = true, cardProps, after, children, linkAs = "a", holdKey,
|
|
61
102
|
}: {
|
|
62
103
|
title: React.ReactNode;
|
|
63
104
|
/** One line under the title: what the page holds, with its count first when it has one ("12 rules · 9 on."). */
|
|
@@ -111,9 +152,18 @@ export function ListPage({
|
|
|
111
152
|
children?: React.ReactNode;
|
|
112
153
|
/** The app's link (Next's Link), as IndexTable takes it. */
|
|
113
154
|
linkAs?: React.ElementType;
|
|
155
|
+
/** Keep the card's place once read under this key (the page and its shop, `gemseel:orders:<shop>`), and while the list loads
|
|
156
|
+
* again hold the room above the card, so what comes with the read does not push it down (WHERE THE CARD STOOD, above). */
|
|
157
|
+
holdKey?: string;
|
|
114
158
|
}) {
|
|
115
159
|
const Link = linkAs;
|
|
116
160
|
const uid = useId();
|
|
161
|
+
const pageRef = useRef<HTMLDivElement>(null);
|
|
162
|
+
const cardRef = useRef<HTMLElement>(null);
|
|
163
|
+
// A page the server drew was painted before this code ran: holding its card now would move it, the shift this is for. True only
|
|
164
|
+
// on the render that hydrates it (and on the server); its first loading is left as drawn, later ones are held.
|
|
165
|
+
const hydrating = useSyncExternalStore(noSubscription, () => false, () => true);
|
|
166
|
+
const paintedByServer = useRef(hydrating);
|
|
117
167
|
const wide = secondaryActions.slice(0, WIDE_SECONDARY);
|
|
118
168
|
const overflow = secondaryActions.slice(WIDE_SECONDARY);
|
|
119
169
|
const hasActions = Boolean(primaryAction) || secondaryActions.length > 0 || actionGroups.length > 0;
|
|
@@ -194,8 +244,41 @@ export function ListPage({
|
|
|
194
244
|
// A lead is card content, and a card that came and went would remount it (review of 3d).
|
|
195
245
|
const boxed = card || (cardLead != null && cardLead !== false) || (state !== "ready" && !(state === "empty" && empty != null));
|
|
196
246
|
|
|
247
|
+
// Loading: the card waits where it stood once read. Its margin is set on the element before the first paint, on top of its own,
|
|
248
|
+
// and set again whenever the page changes height while it loads (a band above it that reads on its own), so its top stays the
|
|
249
|
+
// kept one; it is put back before the paint that shows the read.
|
|
250
|
+
useBeforePaint(() => {
|
|
251
|
+
if (state !== "loading") { paintedByServer.current = false; return; }
|
|
252
|
+
const page = pageRef.current;
|
|
253
|
+
const box = cardRef.current;
|
|
254
|
+
if (!holdKey || paintedByServer.current || !page || !box) return;
|
|
255
|
+
const want = readHold(holdSlot(holdKey, page));
|
|
256
|
+
if (!want) return;
|
|
257
|
+
const own = box.style.marginTop;
|
|
258
|
+
const base = parseFloat(getComputedStyle(box).marginTop) || 0;
|
|
259
|
+
let added = 0;
|
|
260
|
+
const place = () => {
|
|
261
|
+
const top = box.getBoundingClientRect().top - page.getBoundingClientRect().top;
|
|
262
|
+
const next = Math.max(0, added + want - top);
|
|
263
|
+
if (Math.abs(next - added) >= 1) { added = next; box.style.marginTop = `${base + added}px`; }
|
|
264
|
+
};
|
|
265
|
+
place();
|
|
266
|
+
const watch = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(place);
|
|
267
|
+
watch?.observe(page);
|
|
268
|
+
return () => { watch?.disconnect(); box.style.marginTop = own; };
|
|
269
|
+
}, [holdKey, state]);
|
|
270
|
+
// Read (a list, an empty one, or none matching; not a failed read): keep where the card stands as the read lands.
|
|
271
|
+
useBeforePaint(() => {
|
|
272
|
+
if (!holdKey || state === "loading" || state === "error" || !boxed) return;
|
|
273
|
+
const page = pageRef.current;
|
|
274
|
+
const box = cardRef.current;
|
|
275
|
+
if (!page || !box) return;
|
|
276
|
+
const top = Math.round(box.getBoundingClientRect().top - page.getBoundingClientRect().top);
|
|
277
|
+
if (top > 0) writeHold(holdSlot(holdKey, page), top);
|
|
278
|
+
}, [holdKey, state, boxed]);
|
|
279
|
+
|
|
197
280
|
return (
|
|
198
|
-
<div className="ui-list-page">
|
|
281
|
+
<div className="ui-list-page" ref={pageRef}>
|
|
199
282
|
<header className={`ui-list-page__head${back ? " ui-list-page__head--back" : ""}`}>
|
|
200
283
|
{back ? (
|
|
201
284
|
<Link href={back.href} className="ui-btn ui-btn--icon ui-list-page__back" aria-label={`Back to ${back.label}`} title={back.label}>
|
|
@@ -224,7 +307,7 @@ export function ListPage({
|
|
|
224
307
|
{notices ? <div className="ui-list-page__notices">{notices}</div> : null}
|
|
225
308
|
{toolbar ? <div className="ui-list-page__toolbar">{toolbar}</div> : null}
|
|
226
309
|
{boxed ? (
|
|
227
|
-
<section {...cardProps} className={["ui-card ui-list-page__card", cardProps?.className].filter(Boolean).join(" ")}>
|
|
310
|
+
<section {...cardProps} ref={cardRef} className={["ui-card ui-list-page__card", cardProps?.className].filter(Boolean).join(" ")}>
|
|
228
311
|
{cardTitle ? <div className="ui-list-page__card-head"><h2 className="ui-list-page__card-title">{cardTitle}</h2>{cardMeta}</div> : null}
|
|
229
312
|
{cardLead}
|
|
230
313
|
{body}
|
package/src/skill-feedback.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.ui-skillfb__bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px}.ui-skillfb__act{margin-left:auto}.ui-skillfb__head{display:flex;flex-wrap:wrap;align-items:baseline;gap:8px;margin:8px 0 0;font-size:13px;font-weight:600}.ui-skillfb__list{list-style:none;margin:0;padding:0;display:grid;gap:8px}.ui-skillfb__row{display:grid;gap:4px;padding:12px;border:1px solid var(--gemboss-divider, #e3e3e3);border-radius:12px}.ui-skillfb__meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;font-size:13px}.ui-skillfb__aside{margin-left:auto;display:inline-flex;flex-wrap:wrap;align-items:center;gap:6px}.ui-skillfb__quote{margin:0;padding-left:8px;border-left:3px solid var(--gemboss-warning-border, #f5d569);font-size:12px;color:var(--gemboss-text-muted, #686b71)}.ui-skillfb__body{margin:0;font-size:13px;line-height:20px;white-space:pre-wrap;overflow-wrap:anywhere}.ui-skillfb__fine{margin:0;font-size:12px;color:var(--gemboss-text-muted, #686b71)}
|
|
1
|
+
.ui-skillfb__bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px}.ui-skillfb__act{margin-left:auto}.ui-skillfb__head{display:flex;flex-wrap:wrap;align-items:baseline;gap:8px;margin:8px 0 0;font-size:13px;font-weight:600}.ui-skillfb__list{list-style:none;margin:0;padding:0;display:grid;gap:8px}.ui-skillfb__row{display:grid;gap:4px;padding:12px;border:1px solid var(--gemboss-divider, #e3e3e3);border-radius:12px}.ui-skillfb__meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;font-size:13px}.ui-skillfb__when{display:inline-flex;flex-wrap:wrap;align-items:center;gap:6px;font-size:12px;color:var(--gemboss-text-muted, #686b71)}.ui-skillfb__aside{margin-left:auto;display:inline-flex;flex-wrap:wrap;align-items:center;gap:6px}.ui-skillfb__quote{margin:0;padding-left:8px;border-left:3px solid var(--gemboss-warning-border, #f5d569);font-size:12px;color:var(--gemboss-text-muted, #686b71)}.ui-skillfb__body{margin:0;font-size:13px;line-height:20px;white-space:pre-wrap;overflow-wrap:anywhere}.ui-skillfb__fine{margin:0;font-size:12px;color:var(--gemboss-text-muted, #686b71)}
|
package/src/skill-feedback.tsx
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* on and marked Used once a version took it in) and GemBoss's runs to look at (Assistant › Skills › History, S3: a run that was blocked,
|
|
5
5
|
* stopped or failed, the team's note on it, "Used in v4" once a published proposal answered it) are the same row:
|
|
6
6
|
*
|
|
7
|
-
* badges + who
|
|
7
|
+
* badges + who + when ................................. aside (Used · Undo, or Improve with Gem)
|
|
8
8
|
* a quote (the words the comment is about)
|
|
9
9
|
* the body (the comment, the note)
|
|
10
10
|
* fine print (the article, the store · when · engine)
|
|
@@ -22,6 +22,9 @@ export interface SkillFeedbackRow {
|
|
|
22
22
|
badges?: ReactNode;
|
|
23
23
|
/** Who or what it is from, in bold after the chips ("Lily", "by H1 · Nothing the store cannot prove"). */
|
|
24
24
|
who?: ReactNode;
|
|
25
|
+
/** Right after who, in the quiet small type: when it was left, and its state (Fixed, Resolved). Not bold, unlike who (0.64.0;
|
|
26
|
+
* content-radar had put them inside the name). */
|
|
27
|
+
when?: ReactNode;
|
|
25
28
|
/** At the row's end: Used and its Undo, or the act that answers it. */
|
|
26
29
|
aside?: ReactNode;
|
|
27
30
|
quote?: ReactNode;
|
|
@@ -40,6 +43,7 @@ export function SkillFeedbackList({ rows, label }: { rows: readonly SkillFeedbac
|
|
|
40
43
|
<div className="ui-skillfb__meta">
|
|
41
44
|
{r.badges}
|
|
42
45
|
{r.who ? <b>{r.who}</b> : null}
|
|
46
|
+
{r.when ? <span className="ui-skillfb__when">{r.when}</span> : null}
|
|
43
47
|
{r.aside ? <span className="ui-skillfb__aside">{r.aside}</span> : null}
|
|
44
48
|
</div>
|
|
45
49
|
{r.quote ? <p className="ui-skillfb__quote">{r.quote}</p> : null}
|
package/src/skill-history.tsx
CHANGED
|
@@ -60,7 +60,8 @@ export interface SkillVersionRow {
|
|
|
60
60
|
* not record it, content-radar's shared files): no badge. */
|
|
61
61
|
source?: string;
|
|
62
62
|
meta?: string;
|
|
63
|
-
note
|
|
63
|
+
/** Its note, phrasing content (text, or a <span> per line: content-radar adds what the version changed). 0.64.0: a node. */
|
|
64
|
+
note?: ReactNode;
|
|
64
65
|
actions?: ReactNode;
|
|
65
66
|
/** An opened View or Compare under the row. */
|
|
66
67
|
children?: ReactNode;
|