@milesroxas/design-hub 0.11.1 → 0.12.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/README.md +4 -2
- package/core/prototype.test.ts +52 -0
- package/core/prototype.ts +59 -0
- package/core/review/model.ts +32 -3
- package/core/review/service.test.ts +240 -0
- package/core/review/service.ts +281 -50
- package/core/review/store.ts +10 -4
- package/dist/core/prototype.d.ts +50 -0
- package/dist/core/prototype.js +38 -0
- package/dist/core/review/model.d.ts +25 -1
- package/dist/core/review/model.js +18 -2
- package/dist/core/review/service.d.ts +98 -16
- package/dist/core/review/service.js +254 -45
- package/dist/core/review/store.d.ts +10 -4
- package/dist/scripts/client.d.ts +3 -3
- package/dist/scripts/client.js +52 -66
- package/dist/scripts/lib/dns.d.ts +32 -0
- package/dist/scripts/lib/dns.js +69 -1
- package/dist/scripts/lib/fake-host.d.ts +34 -9
- package/dist/scripts/lib/fake-host.js +7 -4
- package/dist/scripts/lib/review.d.ts +5 -2
- package/dist/scripts/lib/review.js +8 -2
- package/dist/scripts/lib/studios.d.ts +3 -1
- package/dist/scripts/lib/studios.js +2 -0
- package/dist/scripts/people.d.ts +8 -5
- package/dist/scripts/people.js +152 -41
- package/dist/scripts/share.js +1 -1
- package/dist/scripts/studio.d.ts +3 -3
- package/dist/scripts/studio.js +100 -10
- package/dist/server/api.d.ts +6 -8
- package/dist/server/api.js +129 -42
- package/dist/server/hosts.d.ts +3 -3
- package/dist/server/hosts.js +10 -10
- package/dist/server/session.d.ts +7 -0
- package/dist/server/session.js +8 -1
- package/dist/vercel/proxy.d.ts +7 -3
- package/dist/vercel/proxy.js +215 -49
- package/dist/vite/plugin.d.ts +6 -2
- package/dist/vite/plugin.js +21 -3
- package/package.json +1 -1
- package/shell/Index.tsx +29 -0
- package/shell/review/People.tsx +80 -61
- package/shell/review/Review.tsx +49 -1
- package/shell/review/ThreadCard.tsx +13 -1
- package/shell/review/client.ts +56 -22
- package/shell/review/review.css +1 -0
- package/shell/review/unsent.test.ts +63 -0
- package/shell/review/unsent.ts +64 -0
- package/shell/review/view.ts +22 -6
- package/shell/studio/ClientHub.tsx +9 -36
- package/shell/studio/StudioHub.tsx +293 -0
- package/shell/studio/hub.css +80 -5
- package/shell/studio/page.tsx +57 -0
- package/shell/studio/studio.html +14 -0
- package/shell/studio/studio.tsx +19 -0
- package/skills/miles-deploy/SKILL.md +16 -6
- package/skills/miles-design-hub/SKILL.md +3 -3
- package/skills/miles-review/SKILL.md +1 -1
- package/templates/studio/README.md +32 -13
- package/templates/studio/package.json +1 -1
package/shell/review/view.ts
CHANGED
|
@@ -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
|
-
/**
|
|
5
|
-
|
|
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 =
|
|
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 {
|
|
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 {
|
|
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 =
|
|
11
|
+
const loaded = useHubData<{ projects: Listed[] }>('projects');
|
|
34
12
|
return (
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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
|
+
}
|
package/shell/studio/hub.css
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/* The client hub: one column of project rows in the
|
|
2
|
-
rhythm (shell.css, The index), on the hub's neutral
|
|
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; }
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// What the client hub and the studio hub share: who is signed in with the
|
|
2
|
+
// one list the page shows, loaded together, and the page around it (its
|
|
3
|
+
// head, its body, and who is signed in at the foot).
|
|
4
|
+
import { type ReactNode, useEffect, useState } from 'react';
|
|
5
|
+
import { call, type Me } from '../review/client';
|
|
6
|
+
|
|
7
|
+
/** A hub's data: loading, failed (signed out, or anything else), or ready with who is signed in and the list. */
|
|
8
|
+
export type HubLoaded<T extends object> =
|
|
9
|
+
| { status: 'loading' }
|
|
10
|
+
| { status: 'error'; signedOut: boolean }
|
|
11
|
+
| ({ status: 'ready'; me: Me | null } & T);
|
|
12
|
+
|
|
13
|
+
/** Who is signed in, and the answer to `op`, the page's one list. */
|
|
14
|
+
export function useHubData<T extends object>(op: string): HubLoaded<T> {
|
|
15
|
+
const [loaded, setLoaded] = useState<HubLoaded<T>>({ status: 'loading' });
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
let current = true;
|
|
18
|
+
Promise.all([call<{ person: Me | null }>('me'), call<T>(op)]).then(
|
|
19
|
+
([{ person }, data]) => current && setLoaded({ status: 'ready', me: person, ...data }),
|
|
20
|
+
// By status, not body: the review API's 401 is JSON, the gate's in front of it is text.
|
|
21
|
+
(error: { status?: number }) =>
|
|
22
|
+
current && setLoaded({ status: 'error', signedOut: error.status === 401 }),
|
|
23
|
+
);
|
|
24
|
+
return () => {
|
|
25
|
+
current = false;
|
|
26
|
+
};
|
|
27
|
+
}, [op]);
|
|
28
|
+
return loaded;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The page: its title and voice, its body, and who is signed in once that is known. */
|
|
32
|
+
export function HubPage({
|
|
33
|
+
title,
|
|
34
|
+
voice,
|
|
35
|
+
me,
|
|
36
|
+
children,
|
|
37
|
+
}: {
|
|
38
|
+
title: string;
|
|
39
|
+
voice: string;
|
|
40
|
+
me: Me | null;
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
}) {
|
|
43
|
+
return (
|
|
44
|
+
<main className="hub">
|
|
45
|
+
<header className="hub-head">
|
|
46
|
+
<h1>{title}</h1>
|
|
47
|
+
<p className="hub-voice">{voice}</p>
|
|
48
|
+
</header>
|
|
49
|
+
{children}
|
|
50
|
+
{me ? (
|
|
51
|
+
<footer className="hub-foot">
|
|
52
|
+
Signed in as {me.name}, {me.team}
|
|
53
|
+
</footer>
|
|
54
|
+
) : null}
|
|
55
|
+
</main>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" class="sys">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
|
6
|
+
<meta name="robots" content="noindex, nofollow" />
|
|
7
|
+
<title>Clients</title>
|
|
8
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="root"></div>
|
|
12
|
+
<script type="module" src="./studio.tsx"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// A studio site's studio hub, at the root of the studio's own host
|
|
2
|
+
// (`studio.<apex>`): every client of the studio and its projects, each with
|
|
3
|
+
// an Open that signs the Studio person in on the client's host (a handoff).
|
|
4
|
+
// Built apart from the client hub, below /_studio/ (`studioConfig` in
|
|
5
|
+
// vite/plugin.ts), so no client's host ever serves it. It wears the hub's
|
|
6
|
+
// neutral system look, as the client hub does.
|
|
7
|
+
import '@kit/base.css';
|
|
8
|
+
import '@kit/prefs';
|
|
9
|
+
import '../system.css';
|
|
10
|
+
import './hub.css';
|
|
11
|
+
import { StrictMode } from 'react';
|
|
12
|
+
import { createRoot } from 'react-dom/client';
|
|
13
|
+
import { StudioHub } from './StudioHub';
|
|
14
|
+
|
|
15
|
+
createRoot(document.getElementById('root')!).render(
|
|
16
|
+
<StrictMode>
|
|
17
|
+
<StudioHub />
|
|
18
|
+
</StrictMode>,
|
|
19
|
+
);
|