@milesroxas/design-hub 0.11.2 → 0.13.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.
Files changed (87) hide show
  1. package/README.md +8 -6
  2. package/core/prototype.test.ts +52 -0
  3. package/core/prototype.ts +59 -0
  4. package/core/review/model.ts +20 -0
  5. package/core/review/service.test.ts +262 -37
  6. package/core/review/service.ts +276 -52
  7. package/core/review/store.ts +12 -6
  8. package/core/review/suite-kv.ts +17 -0
  9. package/dist/core/prototype.d.ts +50 -0
  10. package/dist/core/prototype.js +38 -0
  11. package/dist/core/review/model.d.ts +22 -0
  12. package/dist/core/review/model.js +8 -0
  13. package/dist/core/review/service.d.ts +98 -18
  14. package/dist/core/review/service.js +248 -46
  15. package/dist/core/review/store.d.ts +10 -4
  16. package/dist/core/review/store.js +2 -2
  17. package/dist/core/review/suite-kv.d.ts +7 -0
  18. package/dist/core/review/suite-kv.js +12 -0
  19. package/dist/scripts/client.d.ts +3 -3
  20. package/dist/scripts/client.js +55 -69
  21. package/dist/scripts/lib/cli.js +5 -0
  22. package/dist/scripts/lib/dns.d.ts +32 -0
  23. package/dist/scripts/lib/dns.js +69 -1
  24. package/dist/scripts/lib/fake-host.d.ts +35 -11
  25. package/dist/scripts/lib/fake-host.js +27 -13
  26. package/dist/scripts/lib/host.d.ts +13 -25
  27. package/dist/scripts/lib/host.js +15 -324
  28. package/dist/scripts/lib/studio-deps.d.ts +16 -0
  29. package/dist/scripts/lib/studio-deps.js +41 -16
  30. package/dist/scripts/lib/studios.d.ts +17 -5
  31. package/dist/scripts/lib/studios.js +25 -5
  32. package/dist/scripts/lib/vercel-host.d.ts +17 -0
  33. package/dist/scripts/lib/vercel-host.js +410 -0
  34. package/dist/scripts/people.d.ts +7 -4
  35. package/dist/scripts/people.js +147 -39
  36. package/dist/scripts/share.js +3 -2
  37. package/dist/scripts/studio.d.ts +10 -4
  38. package/dist/scripts/studio.js +136 -22
  39. package/dist/server/api.d.ts +12 -13
  40. package/dist/server/api.js +141 -52
  41. package/dist/server/gate.d.ts +97 -0
  42. package/dist/server/gate.js +537 -0
  43. package/dist/server/hosts.d.ts +3 -3
  44. package/dist/server/hosts.js +10 -10
  45. package/dist/server/mark.d.ts +17 -0
  46. package/dist/server/mark.js +46 -1
  47. package/dist/server/session.d.ts +9 -1
  48. package/dist/server/session.js +10 -3
  49. package/dist/server/stores/backends.d.ts +22 -0
  50. package/dist/server/stores/backends.js +96 -0
  51. package/dist/server/{fake-upstash.js → stores/fake-upstash.js} +1 -1
  52. package/dist/server/stores/index.d.ts +41 -0
  53. package/dist/server/stores/index.js +63 -0
  54. package/dist/server/stores/pglite.d.ts +16 -0
  55. package/dist/server/stores/pglite.js +98 -0
  56. package/dist/server/stores/postgres.d.ts +63 -0
  57. package/dist/server/stores/postgres.js +153 -0
  58. package/dist/server/{upstash.d.ts → stores/upstash.d.ts} +1 -1
  59. package/dist/vercel/files.js +1 -1
  60. package/dist/vercel/proxy.d.ts +6 -78
  61. package/dist/vercel/proxy.js +18 -359
  62. package/dist/vite/plugin.d.ts +6 -2
  63. package/dist/vite/plugin.js +22 -4
  64. package/package.json +3 -1
  65. package/shell/Index.tsx +29 -0
  66. package/shell/review/People.tsx +79 -49
  67. package/shell/review/Review.tsx +49 -1
  68. package/shell/review/ThreadCard.tsx +13 -1
  69. package/shell/review/client.ts +54 -21
  70. package/shell/review/review.css +1 -0
  71. package/shell/review/unsent.test.ts +63 -0
  72. package/shell/review/unsent.ts +64 -0
  73. package/shell/review/view.ts +22 -6
  74. package/shell/studio/ClientHub.tsx +9 -36
  75. package/shell/studio/StudioHub.tsx +293 -0
  76. package/shell/studio/hub.css +80 -5
  77. package/shell/studio/page.tsx +57 -0
  78. package/shell/studio/studio.html +14 -0
  79. package/shell/studio/studio.tsx +19 -0
  80. package/skills/miles-deploy/SKILL.md +17 -6
  81. package/skills/miles-design-hub/SKILL.md +3 -3
  82. package/skills/miles-review/SKILL.md +1 -1
  83. package/templates/studio/.env.example +3 -0
  84. package/templates/studio/README.md +45 -13
  85. package/templates/studio/package.json +1 -1
  86. /package/dist/server/{fake-upstash.d.ts → stores/fake-upstash.d.ts} +0 -0
  87. /package/dist/server/{upstash.js → stores/upstash.js} +0 -0
@@ -0,0 +1,63 @@
1
+ import assert from 'node:assert/strict';
2
+ import { beforeEach, test } from 'node:test';
3
+ import { keepUnsent, keptOn, takeUnsent } from './unsent.ts';
4
+ import { draftOf, initialView, replyOf, view } from './view.ts';
5
+
6
+ // A tab's sessionStorage, as the browser gives it.
7
+ const store = new Map<string, string>();
8
+ Object.assign(globalThis, {
9
+ sessionStorage: {
10
+ getItem: (k: string) => store.get(k) ?? null,
11
+ setItem: (k: string, v: string) => store.set(k, v),
12
+ removeItem: (k: string) => store.delete(k),
13
+ },
14
+ });
15
+ beforeEach(() => store.clear());
16
+
17
+ const PAGE = '/rebrand/open-plan/';
18
+ const kept = { person: 'ed', path: PAGE, thread: null, body: 'Internal: the grid is off' };
19
+
20
+ test('a kept comment comes back only to the person who wrote it, on the page it was written on', () => {
21
+ keepUnsent(kept);
22
+ assert.deepEqual(takeUnsent('ed', PAGE), kept);
23
+ // Once: it is taken out as it comes back.
24
+ assert.equal(takeUnsent('ed', PAGE), null);
25
+ });
26
+
27
+ test('another person signing in in the tab, or another page, gets nothing, and the comment is dropped', () => {
28
+ keepUnsent(kept);
29
+ assert.equal(takeUnsent('rae', PAGE), null);
30
+ assert.equal(takeUnsent('ed', PAGE), null, 'dropped for its writer too');
31
+ // A same-named prototype of another project is another page.
32
+ keepUnsent(kept);
33
+ assert.equal(takeUnsent('ed', '/launch/open-plan/'), null);
34
+ assert.equal(takeUnsent('ed', PAGE), null);
35
+ });
36
+
37
+ test('the signed-out card reads whether a comment or a reply is kept for this page, without taking it', () => {
38
+ assert.equal(keptOn(PAGE), null);
39
+ keepUnsent(kept);
40
+ assert.deepEqual(keptOn(PAGE), { reply: false });
41
+ assert.equal(keptOn('/launch/open-plan/'), null);
42
+ keepUnsent({ ...kept, thread: 't1' });
43
+ assert.deepEqual(keptOn(PAGE), { reply: true });
44
+ assert.equal(takeUnsent('ed', PAGE)?.thread, 't1');
45
+ });
46
+
47
+ test('a value this page did not write, or no storage at all, keeps nothing and throws nothing', () => {
48
+ store.set('proto:unsent', '{"prototype":"open-plan","thread":null,"body":"x"}');
49
+ assert.equal(keptOn(PAGE), null);
50
+ assert.equal(takeUnsent('ed', PAGE), null);
51
+ store.set('proto:unsent', 'not json');
52
+ assert.equal(takeUnsent('ed', PAGE), null);
53
+ });
54
+
55
+ test('words given back fill one box once: the card that opens with them, and no card after it', () => {
56
+ const draft = view(initialView(false), { type: 'draft', draft: { target: null, offset: null, body: 'x' } });
57
+ assert.equal(draftOf(draft.card)?.body, 'x');
58
+ const next = view(view(draft, { type: 'close' }), { type: 'draft', draft: { target: null, offset: null } });
59
+ assert.equal(draftOf(next.card)?.body, undefined);
60
+ const reply = view(initialView(false), { type: 'open', id: 't1', body: 'y' });
61
+ assert.equal(replyOf(reply.card), 'y');
62
+ assert.equal(replyOf(view(view(reply, { type: 'escape' }), { type: 'open', id: 't1' }).card), undefined);
63
+ });
@@ -0,0 +1,64 @@
1
+ // A comment someone wrote and sent just as their session ended: the send
2
+ // met a 401, the panel signed out, and the words would be gone. It is kept
3
+ // in this tab (sessionStorage) with who wrote it and the page it was written
4
+ // on, and given back once, after a reload, only to that person on that page.
5
+ // Anyone else signing in in this tab, or another page, drops it unread.
6
+
7
+ const KEY = 'proto:unsent';
8
+
9
+ /**
10
+ * The words, who wrote them, the page's full path (base included, so a
11
+ * same-named prototype of another project is another page), and the thread
12
+ * they reply to (null: a new comment, which comes back on the whole page).
13
+ */
14
+ export type Unsent = { person: string; path: string; thread: string | null; body: string };
15
+
16
+ const isUnsent = (v: unknown): v is Unsent => {
17
+ const u = v as Partial<Unsent> | null;
18
+ return (
19
+ !!u &&
20
+ typeof u.person === 'string' &&
21
+ typeof u.path === 'string' &&
22
+ typeof u.body === 'string' &&
23
+ (u.thread === null || typeof u.thread === 'string')
24
+ );
25
+ };
26
+
27
+ function read(): Unsent | null {
28
+ try {
29
+ const kept: unknown = JSON.parse(sessionStorage.getItem(KEY) ?? 'null');
30
+ return isUnsent(kept) ? kept : null;
31
+ } catch {
32
+ // Storage off, or a value this page did not write: nothing is kept.
33
+ return null;
34
+ }
35
+ }
36
+
37
+ export function keepUnsent(unsent: Unsent): void {
38
+ try {
39
+ sessionStorage.setItem(KEY, JSON.stringify(unsent));
40
+ } catch {
41
+ // Storage off (a private window): there is nowhere to keep it.
42
+ }
43
+ }
44
+
45
+ /** Whether a comment is kept for this page, and whether it is a reply; read without taking it, for the signed-out card. */
46
+ export function keptOn(path: string): { reply: boolean } | null {
47
+ const kept = read();
48
+ return kept && kept.path === path ? { reply: kept.thread !== null } : null;
49
+ }
50
+
51
+ /**
52
+ * Once someone is signed in: the comment kept for them on this page, taken
53
+ * out of storage. Whatever is kept is dropped here either way, so it never
54
+ * reaches another person or another page.
55
+ */
56
+ export function takeUnsent(person: string, path: string): Unsent | null {
57
+ const kept = read();
58
+ try {
59
+ sessionStorage.removeItem(KEY);
60
+ } catch {
61
+ // Storage off: it was never there.
62
+ }
63
+ return kept && kept.person === person && kept.path === path ? kept : null;
64
+ }
@@ -1,14 +1,21 @@
1
1
  // What the review layer shows. Pure, so node:test runs it: no React, no DOM
2
2
  // beyond the Element type a draft points at.
3
3
 
4
- /** A new comment being placed: the element it is about and where on it, as fractions of its box, or neither for the whole page. */
5
- export type Draft = { target: Element | null; offset: { x: number; y: number } | null };
4
+ /**
5
+ * A new comment being placed: the element it is about and where on it, as
6
+ * fractions of its box, or neither for the whole page. `body` is words given
7
+ * back after a reload (unsent.ts), which its box starts with, once.
8
+ */
9
+ export type Draft = { target: Element | null; offset: { x: number; y: number } | null; body?: string };
6
10
 
7
11
  /** Which threads Studio lists: every one, or one audience. Matches core's Audience values. */
8
12
  export type Filter = 'all' | 'internal' | 'client';
9
13
 
10
- /** The one card on screen: a thread, a comment being written, or the people. */
11
- export type Card = { type: 'thread'; id: string } | { type: 'draft'; draft: Draft } | { type: 'people' };
14
+ /** The one card on screen: a thread (`body`: a reply given back after a reload, once), a comment being written, or the people. */
15
+ export type Card =
16
+ | { type: 'thread'; id: string; body?: string }
17
+ | { type: 'draft'; draft: Draft }
18
+ | { type: 'people' };
12
19
 
13
20
  /**
14
21
  * One value, so a transition (start, open a pin, close, hide) changes every
@@ -32,7 +39,7 @@ export type View = {
32
39
  export type ViewAction =
33
40
  | { type: 'start' }
34
41
  | { type: 'stop' }
35
- | { type: 'open'; id: string }
42
+ | { type: 'open'; id: string; body?: string }
36
43
  | { type: 'draft'; draft: Draft }
37
44
  | { type: 'people' }
38
45
  | { type: 'close' }
@@ -60,7 +67,12 @@ export function view(state: View, action: ViewAction): View {
60
67
  return { ...state, commenting: false, card: null };
61
68
  // A link to a comment opens its thread even when comments are hidden: the link is the request to see it.
62
69
  case 'open':
63
- return { ...state, hidden: false, commenting: true, card: { type: 'thread', id: action.id } };
70
+ return {
71
+ ...state,
72
+ hidden: false,
73
+ commenting: true,
74
+ card: { type: 'thread', id: action.id, ...(action.body ? { body: action.body } : {}) },
75
+ };
64
76
  case 'draft':
65
77
  return { ...state, card: { type: 'draft', draft: action.draft } };
66
78
  case 'people':
@@ -125,6 +137,10 @@ export function stepFrom<T extends Thread>(round: T[], id: string, by: number):
125
137
  return round[(at + by + round.length) % round.length];
126
138
  }
127
139
 
140
+ /** The reply given back to the open thread's box, when one was (unsent.ts). */
141
+ export const replyOf = (card: Card | null): string | undefined =>
142
+ card?.type === 'thread' ? card.body : undefined;
143
+
128
144
  /** The thread the card shows, when it shows one. */
129
145
  export const threadOf = (card: Card | null): string | null => (card?.type === 'thread' ? card.id : null);
130
146
 
@@ -1,49 +1,22 @@
1
1
  import { Icon } from '@kit/Icon';
2
2
  import { Button } from '@kit/ui';
3
- import { useEffect, useState } from 'react';
4
- import { call, type Me } from '../review/client';
3
+ import { type HubLoaded, HubPage, useHubData } from './page';
5
4
 
6
5
  /** What the hub shows of a project: the server sends no more. */
7
6
  type Listed = { slug: string; name: string };
8
7
 
9
- type Loaded =
10
- | { status: 'loading' }
11
- | { status: 'error'; signedOut: boolean }
12
- | { status: 'ready'; me: Me | null; projects: Listed[] };
13
-
14
- /** Who is signed in and this host's projects. */
15
- function useProjects(): Loaded {
16
- const [loaded, setLoaded] = useState<Loaded>({ status: 'loading' });
17
- useEffect(() => {
18
- let current = true;
19
- Promise.all([call<{ person: Me | null }>('me'), call<{ projects: Listed[] }>('projects')]).then(
20
- ([{ person }, { projects }]) => current && setLoaded({ status: 'ready', me: person, projects }),
21
- // By status, not body: the review API's 401 is JSON, the gate's in front of it is text.
22
- (error: { status?: number }) =>
23
- current && setLoaded({ status: 'error', signedOut: error.status === 401 }),
24
- );
25
- return () => {
26
- current = false;
27
- };
28
- }, []);
29
- return loaded;
30
- }
8
+ type Loaded = HubLoaded<{ projects: Listed[] }>;
31
9
 
32
10
  export function ClientHub() {
33
- const loaded = useProjects();
11
+ const loaded = useHubData<{ projects: Listed[] }>('projects');
34
12
  return (
35
- <main className="hub">
36
- <header className="hub-head">
37
- <h1>Projects</h1>
38
- <p className="hub-voice">What the studio has shared here, each in its own hub.</p>
39
- </header>
13
+ <HubPage
14
+ title="Projects"
15
+ voice="What the studio has shared here, each in its own hub."
16
+ me={loaded.status === 'ready' ? loaded.me : null}
17
+ >
40
18
  <Body loaded={loaded} />
41
- {loaded.status === 'ready' && loaded.me ? (
42
- <footer className="hub-foot">
43
- Signed in as {loaded.me.name}, {loaded.me.team}
44
- </footer>
45
- ) : null}
46
- </main>
19
+ </HubPage>
47
20
  );
48
21
  }
49
22
 
@@ -0,0 +1,293 @@
1
+ import { Icon } from '@kit/Icon';
2
+ import { Badge, Button } from '@kit/ui';
3
+ import { type ReactNode, useEffect, useId, useMemo, useRef, useState } from 'react';
4
+ import { HANDOFF_START } from '../../core/prototype';
5
+ import { createReviewStore, type Me, useReviewState } from '../review/client';
6
+ import { People } from '../review/People';
7
+ import { type HubLoaded, HubPage, useHubData } from './page';
8
+
9
+ /** What the studio hub shows of a project and a client: the server sends no more. */
10
+ type ListedProject = { slug: string; name: string; built: boolean };
11
+ type ListedClient = { slug: string; name: string; host: string; waiting: boolean; projects: ListedProject[] };
12
+
13
+ type Loaded = HubLoaded<{ clients: ListedClient[] }>;
14
+
15
+ export function StudioHub() {
16
+ const loaded = useHubData<{ clients: ListedClient[] }>('clients');
17
+ return (
18
+ <HubPage
19
+ title="Clients"
20
+ voice="Every client of the studio. Open one to work in its hub, signed in as you."
21
+ me={loaded.status === 'ready' ? loaded.me : null}
22
+ >
23
+ <Body loaded={loaded} />
24
+ </HubPage>
25
+ );
26
+ }
27
+
28
+ function Body({ loaded }: { loaded: Loaded }) {
29
+ if (loaded.status === 'loading') return <Loading />;
30
+ if (loaded.status === 'error') return <Failed signedOut={loaded.signedOut} />;
31
+ return (
32
+ <div className="studio-clients">
33
+ {loaded.clients.length ? (
34
+ loaded.clients.map((c) => <ClientSection key={c.slug} client={c} me={loaded.me} />)
35
+ ) : (
36
+ <section className="hub-empty">
37
+ <h2>No clients yet</h2>
38
+ <p>
39
+ Add the first from the studio folder with <code>design-hub client add</code>. It shows here as
40
+ soon as it is added.
41
+ </p>
42
+ </section>
43
+ )}
44
+ <StudioSection me={loaded.me} />
45
+ </div>
46
+ );
47
+ }
48
+
49
+ /**
50
+ * A section's People: its button, and the panel it opens below the section's
51
+ * rows with the review panel's People controls, for one client's people or
52
+ * the studio's own. The people load first, the button busy, so the panel
53
+ * opens once, filled; focus moves into it, and back to the button when it
54
+ * closes, so Tab never has to pass the section's projects to reach it.
55
+ */
56
+ function usePeopleSection(me: Me | null, client?: string): { toggle: ReactNode; panel: ReactNode } {
57
+ const store = useMemo(() => createReviewStore('', client), [client]);
58
+ const [open, setOpen] = useState(false);
59
+ const [busy, setBusy] = useState(false);
60
+ const [failed, setFailed] = useState(false);
61
+ const id = useId();
62
+ const button = useRef<HTMLButtonElement>(null);
63
+ const panel = useRef<HTMLDivElement>(null);
64
+ const load = async () => {
65
+ setBusy(true);
66
+ await store.loadPeople().then(
67
+ () => setFailed(false),
68
+ () => setFailed(true),
69
+ );
70
+ setBusy(false);
71
+ };
72
+ useEffect(() => {
73
+ if (open) panel.current?.querySelector<HTMLElement>('input, button')?.focus();
74
+ }, [open]);
75
+ const onToggle = () => {
76
+ if (!open) return void load().then(() => setOpen(true));
77
+ setOpen(false);
78
+ button.current?.focus();
79
+ };
80
+ const toggle = (
81
+ <Button
82
+ ref={button}
83
+ kind="tertiary"
84
+ size="sm"
85
+ icon="users-01"
86
+ iconSize={16}
87
+ label="People"
88
+ busy={busy && !open}
89
+ aria-expanded={open}
90
+ aria-controls={open ? id : undefined}
91
+ onClick={onToggle}
92
+ />
93
+ );
94
+ const body = (
95
+ <PeopleBody store={store} me={me} client={client} failed={failed} busy={busy} onRetry={load} />
96
+ );
97
+ return {
98
+ toggle,
99
+ panel: open ? (
100
+ <div id={id} ref={panel} className="studio-people">
101
+ {body}
102
+ </div>
103
+ ) : null,
104
+ };
105
+ }
106
+
107
+ type PeopleStore = ReturnType<typeof createReviewStore>;
108
+
109
+ /**
110
+ * What a section's panel holds: the People controls; a load that failed, in
111
+ * place, with Try again; or, once the session ended, the hub's signed-out card.
112
+ */
113
+ function PeopleBody({
114
+ store,
115
+ me,
116
+ client,
117
+ failed,
118
+ busy,
119
+ onRetry,
120
+ }: {
121
+ store: PeopleStore;
122
+ me: Me | null;
123
+ client?: string;
124
+ failed: boolean;
125
+ busy: boolean;
126
+ onRetry: () => void;
127
+ }) {
128
+ const s = useReviewState(store);
129
+ if (s.status === 'guest') return <Failed signedOut />;
130
+ if (failed && s.people === null)
131
+ return (
132
+ <section className="hub-empty" role="alert">
133
+ <h2>The people did not load</h2>
134
+ <p>{s.error ?? 'Try again in a minute.'}</p>
135
+ <Button kind="secondary" size="sm" label="Try again" busy={busy} onClick={onRetry} />
136
+ </section>
137
+ );
138
+ return (
139
+ <>
140
+ {s.error ? (
141
+ <div className="studio-people-error" role="alert">
142
+ <p>{s.error}</p>
143
+ <Button kind="tertiary" size="sm" label="Dismiss" onClick={store.clearError} />
144
+ </div>
145
+ ) : null}
146
+ <People
147
+ store={store}
148
+ me={me}
149
+ people={s.people}
150
+ access={s.access}
151
+ only={client ? 'client' : 'studio'}
152
+ menuClassName=""
153
+ />
154
+ </>
155
+ );
156
+ }
157
+
158
+ /** The studio's own people, who sign in here and see every client. */
159
+ function StudioSection({ me }: { me: Me | null }) {
160
+ const people = usePeopleSection(me);
161
+ return (
162
+ <section className="studio-client studio-own" aria-labelledby="studio-people">
163
+ <div className="studio-client-head">
164
+ <div className="studio-client-name">
165
+ <h2 id="studio-people">Studio people</h2>
166
+ <p className="studio-note">Sign in here and see every client.</p>
167
+ </div>
168
+ <div className="studio-actions">{people.toggle}</div>
169
+ </div>
170
+ {people.panel}
171
+ </section>
172
+ );
173
+ }
174
+
175
+ /** One client section's shape while the list loads, its head and two rows, so nothing moves when it arrives. */
176
+ function Loading() {
177
+ return (
178
+ <section className="studio-clients" aria-busy="true" aria-label="Loading clients">
179
+ <div className="studio-client">
180
+ <div className="studio-client-head">
181
+ <span className="studio-skeleton-name" />
182
+ <span className="studio-skeleton-open" />
183
+ </div>
184
+ <ul className="hub-list">
185
+ <li className="hub-skeleton studio-skeleton-row" />
186
+ <li className="hub-skeleton studio-skeleton-row" />
187
+ </ul>
188
+ </div>
189
+ </section>
190
+ );
191
+ }
192
+
193
+ /**
194
+ * An Open: a form the browser posts to the studio's host, which answers with
195
+ * the client's host to go to. Only the slugs go; the address comes from the server.
196
+ */
197
+ function Opener({ client, project, children }: { client: string; project?: string; children: ReactNode }) {
198
+ return (
199
+ <form className="studio-open" method="post" action={HANDOFF_START}>
200
+ <input type="hidden" name="client" value={client} />
201
+ {project ? <input type="hidden" name="project" value={project} /> : null}
202
+ {children}
203
+ </form>
204
+ );
205
+ }
206
+
207
+ function ClientSection({ client, me }: { client: ListedClient; me: Me | null }) {
208
+ const titleId = `client-${client.slug}`;
209
+ const people = usePeopleSection(me, client.slug);
210
+ return (
211
+ <section className="studio-client" aria-labelledby={titleId}>
212
+ <div className="studio-client-head">
213
+ <div className="studio-client-name">
214
+ <h2 id={titleId}>{client.name}</h2>
215
+ <p className="studio-host">{client.host}</p>
216
+ </div>
217
+ {/* A client still waiting for its address has no people op to run: its host is not proven yet. */}
218
+ {client.waiting ? (
219
+ <Badge tone="warning" dot>
220
+ Waiting for its address
221
+ </Badge>
222
+ ) : (
223
+ <div className="studio-actions">
224
+ {people.toggle}
225
+ <Opener client={client.slug}>
226
+ <Button kind="secondary" size="sm" type="submit" label="Open hub" />
227
+ </Opener>
228
+ </div>
229
+ )}
230
+ </div>
231
+ <Projects client={client} />
232
+ {client.waiting ? null : people.panel}
233
+ </section>
234
+ );
235
+ }
236
+
237
+ function Projects({ client }: { client: ListedClient }) {
238
+ if (!client.projects.length)
239
+ return (
240
+ <p className="studio-none">
241
+ {client.waiting ? 'Run client add again to finish it.' : 'No projects yet.'}
242
+ </p>
243
+ );
244
+ return (
245
+ <ul className="hub-list">
246
+ {client.projects.map((p) => (
247
+ <li key={p.slug}>
248
+ <ProjectRow client={client} project={p} />
249
+ </li>
250
+ ))}
251
+ </ul>
252
+ );
253
+ }
254
+
255
+ function ProjectRow({ client, project }: { client: ListedClient; project: ListedProject }) {
256
+ const label = (
257
+ <span className="studio-project">
258
+ <span className="hub-name">{project.name}</span>
259
+ <span className="studio-slug">/{project.slug}/</span>
260
+ </span>
261
+ );
262
+ if (!project.built || client.waiting)
263
+ return (
264
+ <div className="hub-row is-static">
265
+ {label}
266
+ <span className="studio-none">Not shared yet</span>
267
+ </div>
268
+ );
269
+ return (
270
+ <Opener client={client.slug} project={project.slug}>
271
+ <button type="submit" className="hub-row" aria-label={`Open ${project.name}`}>
272
+ {label}
273
+ <Icon name="arrow-right" size={16} className="hub-arrow" />
274
+ </button>
275
+ </Opener>
276
+ );
277
+ }
278
+
279
+ /** A failure in plain words: a reload brings the sign-in page back, or tries the list again. */
280
+ function Failed({ signedOut }: { signedOut: boolean }) {
281
+ return (
282
+ <section className="hub-empty" role="alert">
283
+ <h2>{signedOut ? 'You are signed out' : 'The clients did not load'}</h2>
284
+ <p>{signedOut ? 'Reload the page to see how to sign in again.' : 'Try again in a minute.'}</p>
285
+ <Button
286
+ kind="secondary"
287
+ size="sm"
288
+ label={signedOut ? 'Reload' : 'Try again'}
289
+ onClick={() => location.reload()}
290
+ />
291
+ </section>
292
+ );
293
+ }
@@ -1,5 +1,6 @@
1
- /* The client hub: one column of project rows in the index's measure and
2
- rhythm (shell.css, The index), on the hub's neutral system look. A studio
1
+ /* The client hub and the studio hub: one column of project rows in the
2
+ index's measure and rhythm (shell.css, The index), on the hub's neutral
3
+ system look. The studio hub groups the rows under a head per client. A studio
3
4
  site has no tokens.css, so the few motion values the hub and kit/ui read
4
5
  are set here, the same as the template's. */
5
6
  :root {
@@ -11,6 +12,8 @@
11
12
  --dur-press-in: 90ms;
12
13
  --dur-press-out: 160ms;
13
14
  --dur-hover: 120ms;
15
+ --dur-menu: 180ms;
16
+ --dur-menu-out: 120ms;
14
17
  }
15
18
 
16
19
  body { background: var(--bg-primary); }
@@ -27,10 +30,10 @@ body { background: var(--bg-primary); }
27
30
  .hub-name { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
28
31
  .hub-arrow { color: var(--fg-quaternary); transition: color var(--dur-hover) var(--ease-hover), translate var(--dur-hover) var(--ease-out); }
29
32
  @media (hover: hover) and (pointer: fine) {
30
- .hub-row:hover { background: var(--bg-primary_hover); }
33
+ .hub-row:not(.is-static):hover { background: var(--bg-primary_hover); }
31
34
  .hub-row:hover .hub-arrow { color: var(--fg-secondary); translate: 2px 0; }
32
35
  }
33
- .hub-row:active { transform: scale(0.97); transition-duration: var(--dur-hover), var(--dur-press-in); }
36
+ .hub-row:not(.is-static):active { transform: scale(0.97); transition-duration: var(--dur-hover), var(--dur-press-in); }
34
37
 
35
38
  /* Two rows' worth while the list loads, so the page keeps its shape. Tertiary, so it reads on the page in both modes. */
36
39
  .hub-skeleton { height: 56px; border-radius: var(--radius-md); background: var(--bg-tertiary); }
@@ -44,5 +47,77 @@ body { background: var(--bg-primary); }
44
47
 
45
48
  .hub-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border-secondary); color: var(--text-tertiary); }
46
49
 
47
- :root[data-motion="reduce"] .hub-row:active { transform: none; }
50
+ :root[data-motion="reduce"] .hub-row:not(.is-static):active { transform: none; }
48
51
  :root[data-motion="reduce"] .hub-row:hover .hub-arrow { translate: none; }
52
+
53
+ /* The studio hub: a section per client, its name and address beside its
54
+ Open, then its projects as the client hub's rows. A row whose project has
55
+ no build stays still: nothing to open. */
56
+ .studio-clients { display: flex; flex-direction: column; gap: 40px; }
57
+ .studio-client { display: flex; flex-direction: column; gap: 8px; }
58
+ .studio-client-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding-inline: 12px; }
59
+ .studio-client-name { display: flex; flex-direction: column; min-width: 0; }
60
+ .studio-client-name h2 { font-size: 16px; line-height: 24px; font-weight: 600; overflow-wrap: anywhere; text-wrap: balance; }
61
+ .studio-host, .studio-slug { font-family: var(--sys-font-mono); font-size: 12px; line-height: 18px; color: var(--text-tertiary); overflow-wrap: anywhere; }
62
+ .studio-client-head .badge { flex-shrink: 0; }
63
+ .studio-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
64
+ .studio-note { font-size: 13px; line-height: 18px; color: var(--text-tertiary); }
65
+ /* The studio's own people sit apart from the clients, under a rule. */
66
+ .studio-own { padding-top: 24px; border-top: 1px solid var(--border-secondary); }
67
+ .studio-open { margin: 0; flex-shrink: 0; }
68
+ .studio-open .hub-row { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
69
+ .studio-project { display: flex; flex-direction: column; min-width: 0; }
70
+ .studio-none { color: var(--text-tertiary); white-space: nowrap; }
71
+ .studio-client > .studio-none { padding-inline: 12px; white-space: normal; }
72
+ /* Open hub and People are 38px buttons; each reaches 44px to the touch, as the empty state's does. */
73
+ .studio-client-head .btn { position: relative; }
74
+ .studio-client-head .btn::before { content: ''; position: absolute; inset: -3px 0; }
75
+ /* The project row is a button: its name is "Open <project>", and the base focus ring sits inside its corners. */
76
+ .studio-open .hub-row:focus-visible { box-shadow: var(--focus-ring); }
77
+ /* While the list loads: one client's head and two rows at their filled sizes. */
78
+ .studio-skeleton-name { width: 160px; height: 42px; border-radius: var(--radius-sm); background: var(--bg-tertiary); }
79
+ .studio-skeleton-open { width: 90px; height: 38px; border-radius: var(--radius-sm); background: var(--bg-tertiary); }
80
+ .studio-skeleton-row { height: 62px; }
81
+
82
+ /* A section's people: the review panel's People controls (review/People.tsx)
83
+ on the hub's system look, in a bordered panel below the section's rows.
84
+ The class names are the panel's own; only their look is set here. */
85
+ .studio-people { display: flex; flex-direction: column; gap: 16px; margin-inline: 12px; padding: 16px; border: 1px solid var(--border-secondary); border-radius: var(--radius-lg); }
86
+ .studio-people p { margin: 0; text-wrap: pretty; }
87
+ .studio-people .rv-body { display: flex; flex-direction: column; gap: 16px; }
88
+ .studio-people .rv-muted { color: var(--text-tertiary); }
89
+ .studio-people .rv-disclosure { font-size: 13px; line-height: 18px; max-width: 60ch; }
90
+ .studio-people .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
91
+ .studio-people .field-label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--text-secondary); }
92
+ .studio-people .btn { position: relative; height: 40px; padding: 0 14px; }
93
+ /* Name, access and the button on one line, wide enough; stacked on a phone. */
94
+ .studio-people .rv-invite { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 200px) auto; align-items: end; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--border-secondary); }
95
+ @media (max-width: 600px) { .studio-people .rv-invite { grid-template-columns: minmax(0, 1fr); } }
96
+ /* A new link, as the review panel shows one: what it does, the link to copy, and Copy. */
97
+ .studio-people .rv-share { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius-md); background: var(--bg-secondary); }
98
+ .studio-people .rv-share-row { display: flex; gap: 8px; }
99
+ .studio-people .rv-share-row .input { flex: 1; min-width: 0; font-family: var(--sys-font-mono); font-size: 13px; }
100
+ /* 16px on a touch screen or a phone, as kit/base.css sets every input, so iOS does not zoom into the link. */
101
+ @media (pointer: coarse), (max-width: 767px) { .studio-people .rv-share-row .input { font-size: 16px; } }
102
+ .studio-people .btn.rv-copy { flex: none; width: 80px; padding: 0; }
103
+ .studio-people .rv-people { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
104
+ .studio-people .rv-people li { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--border-secondary); }
105
+ .studio-people .rv-people li:last-child { border-bottom: 0; padding-bottom: 0; }
106
+ .studio-people .rv-person { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
107
+ .studio-people .rv-person strong { font-weight: 600; color: var(--text-primary); }
108
+ .studio-people .rv-people [data-revoked] { opacity: 0.55; }
109
+ /* A row's text actions: 36px, the fill only under the pointer, each reaching 44px to the touch; wrapped lines keep 8px apart. */
110
+ .studio-people .rv-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 4px; }
111
+ .studio-people .rv-acts { margin-inline: -10px; }
112
+ .studio-people .rv-acts .rv-confirm { flex: 1 1 100%; padding: 0 10px; color: var(--text-secondary); }
113
+ .studio-people .rv-acts .select { width: auto; min-width: 160px; }
114
+ .studio-people .btn.rv-act { height: 36px; padding: 0 10px; color: var(--text-tertiary); font-weight: 500; }
115
+ .studio-people .btn.rv-act-danger { color: var(--text-error-primary); }
116
+ @media (hover: hover) and (pointer: fine) {
117
+ .studio-people .btn.rv-act:hover { color: var(--text-primary); }
118
+ .studio-people .btn.rv-act-danger:hover { color: var(--text-error-primary_hover); }
119
+ }
120
+ .studio-people .btn::before { content: ''; position: absolute; inset: -4px 0; }
121
+ .studio-people .btn:not(.rv-act)::before { inset: -2px 0; }
122
+ .studio-people-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 12px; border-radius: var(--radius-md); background: var(--bg-error-primary); color: var(--text-error-primary); }
123
+ .studio-people > .hub-empty { padding-inline: 0; }