@milesroxas/design-hub 0.9.0 → 0.11.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 +13 -11
- package/core/controls.test.ts +176 -0
- package/core/controls.ts +195 -0
- package/core/files.test.ts +76 -0
- package/core/files.ts +131 -0
- package/core/prototype.test.ts +124 -7
- package/core/prototype.ts +133 -24
- package/core/review/model.ts +144 -2
- package/core/review/policy.test.ts +79 -22
- package/core/review/policy.ts +36 -8
- package/core/review/service.test.ts +1525 -322
- package/core/review/service.ts +810 -183
- package/core/review/store.test.ts +91 -0
- package/core/review/store.ts +143 -26
- package/dist/core/controls.d.ts +55 -0
- package/dist/core/controls.js +174 -0
- package/dist/core/files.d.ts +39 -0
- package/dist/core/files.js +107 -0
- package/dist/core/prototype.d.ts +61 -12
- package/dist/core/prototype.js +105 -26
- package/dist/core/review/model.d.ts +87 -2
- package/dist/core/review/model.js +97 -1
- package/dist/core/review/policy.d.ts +11 -4
- package/dist/core/review/policy.js +14 -2
- package/dist/core/review/service.d.ts +222 -43
- package/dist/core/review/service.js +727 -182
- package/dist/core/review/store.d.ts +84 -24
- package/dist/core/review/store.js +66 -26
- package/dist/scripts/bootstrap.d.ts +4 -34
- package/dist/scripts/bootstrap.js +9 -244
- package/dist/scripts/cli.js +6 -0
- package/dist/scripts/client.d.ts +45 -0
- package/dist/scripts/client.js +320 -0
- package/dist/scripts/commands.js +6 -0
- package/dist/scripts/comments.d.ts +8 -26
- package/dist/scripts/comments.js +27 -14
- package/dist/scripts/guard.d.ts +11 -0
- package/dist/scripts/guard.js +44 -0
- package/dist/scripts/lib/builds.d.ts +40 -0
- package/dist/scripts/lib/builds.js +198 -0
- package/dist/scripts/lib/cli.js +3 -1
- package/dist/scripts/lib/deploy.d.ts +6 -90
- package/dist/scripts/lib/deploy.js +24 -137
- package/dist/scripts/lib/dns.d.ts +49 -0
- package/dist/scripts/lib/dns.js +141 -0
- package/dist/scripts/lib/fake-host.d.ts +168 -0
- package/dist/scripts/lib/fake-host.js +244 -0
- package/dist/scripts/lib/host.d.ts +87 -0
- package/dist/scripts/lib/host.js +362 -0
- package/dist/scripts/lib/linked.d.ts +51 -0
- package/dist/scripts/lib/linked.js +124 -0
- package/dist/scripts/lib/names.d.ts +35 -0
- package/dist/scripts/lib/names.js +77 -0
- package/dist/scripts/lib/review.d.ts +23 -2
- package/dist/scripts/lib/review.js +32 -15
- package/dist/scripts/lib/rules.d.ts +1 -0
- package/dist/scripts/lib/rules.js +1 -0
- package/dist/scripts/lib/studio-deps.d.ts +35 -0
- package/dist/scripts/lib/studio-deps.js +79 -0
- package/dist/scripts/lib/studios.d.ts +70 -0
- package/dist/scripts/lib/studios.js +187 -0
- package/dist/scripts/lib/update.d.ts +33 -0
- package/dist/scripts/lib/update.js +40 -0
- package/dist/scripts/lib/vercel.d.ts +1 -23
- package/dist/scripts/lib/vercel.js +6 -81
- package/dist/scripts/people.d.ts +7 -11
- package/dist/scripts/people.js +51 -46
- package/dist/scripts/preflight.d.ts +8 -1
- package/dist/scripts/preflight.js +36 -19
- package/dist/scripts/project.d.ts +86 -0
- package/dist/scripts/project.js +141 -0
- package/dist/scripts/share.d.ts +105 -30
- package/dist/scripts/share.js +82 -154
- package/dist/scripts/skills.d.ts +18 -2
- package/dist/scripts/skills.js +22 -3
- package/dist/scripts/studio.d.ts +75 -0
- package/dist/scripts/studio.js +401 -0
- package/dist/scripts/upgrade.d.ts +10 -2
- package/dist/scripts/upgrade.js +44 -14
- package/dist/server/api.d.ts +22 -11
- package/dist/server/api.js +125 -44
- package/dist/server/blob.d.ts +10 -0
- package/dist/server/blob.js +53 -0
- package/dist/server/checks.js +2 -2
- package/dist/server/dev.js +4 -4
- package/dist/server/env.d.ts +2 -0
- package/dist/server/env.js +9 -0
- package/dist/server/fake-upstash.js +52 -3
- package/dist/server/hosts.d.ts +11 -0
- package/dist/server/hosts.js +31 -0
- package/dist/server/local.d.ts +7 -1
- package/dist/server/local.js +10 -1
- package/dist/server/mark.d.ts +41 -0
- package/dist/server/mark.js +111 -0
- package/dist/server/session.d.ts +17 -9
- package/dist/server/session.js +22 -45
- package/dist/server/upstash.js +20 -0
- package/dist/vercel/files.d.ts +11 -0
- package/dist/vercel/files.js +68 -0
- package/dist/vercel/index.d.ts +4 -3
- package/dist/vercel/index.js +12 -8
- package/dist/vercel/proxy.d.ts +69 -4
- package/dist/vercel/proxy.js +171 -107
- package/dist/vite/plugin.d.ts +24 -1
- package/dist/vite/plugin.js +46 -2
- package/kit/Artboard.tsx +21 -8
- package/kit/Space.tsx +4 -3
- package/kit/Variants.tsx +193 -65
- package/kit/ViewTools.tsx +77 -11
- package/kit/audience.ts +85 -0
- package/kit/dials.css +59 -0
- package/kit/dials.tsx +272 -35
- package/kit/harness.css +34 -0
- package/kit/prefs.ts +23 -1
- package/package.json +3 -2
- package/shell/ClientViewNote.tsx +31 -3
- package/shell/Guide.tsx +11 -5
- package/shell/Index.tsx +32 -10
- package/shell/Notice.tsx +1 -1
- package/shell/controls.ts +26 -0
- package/shell/hub.ts +5 -1
- package/shell/main.tsx +33 -6
- package/shell/review/Review.tsx +2 -2
- package/shell/review/ThreadCard.tsx +5 -5
- package/shell/review/client.ts +28 -11
- package/shell/review/view.test.ts +19 -0
- package/shell/review/view.ts +25 -0
- package/shell/shell.css +8 -0
- package/shell/studio/ClientHub.tsx +98 -0
- package/shell/studio/hub.css +48 -0
- package/shell/studio/index.html +14 -0
- package/shell/studio/main.tsx +17 -0
- package/skills/miles-brand/SKILL.md +11 -1
- package/skills/miles-deploy/SKILL.md +121 -64
- package/skills/miles-design-hub/SKILL.md +11 -9
- package/skills/miles-prototype/SKILL.md +34 -1
- package/skills/miles-review/SKILL.md +5 -7
- package/skills/miles-worktrees/SKILL.md +3 -3
- package/templates/conductor/settings.toml +1 -1
- package/templates/studio/.env.example +9 -0
- package/templates/studio/.vercelignore +5 -0
- package/templates/studio/README.md +84 -0
- package/templates/studio/_gitignore +7 -0
- package/templates/studio/api/files.ts +4 -0
- package/templates/studio/api/review.ts +4 -0
- package/templates/studio/build.mjs +4 -0
- package/templates/studio/package.json +16 -0
- package/templates/studio/proxy.ts +4 -0
- package/templates/studio/studio.json +9 -0
- package/templates/studio/vercel.json +27 -0
package/kit/dials.tsx
CHANGED
|
@@ -10,9 +10,21 @@ import {
|
|
|
10
10
|
} from 'dialkit';
|
|
11
11
|
import 'dialkit/styles.css';
|
|
12
12
|
import './dials.css';
|
|
13
|
-
import { type RefObject, useLayoutEffect } from 'react';
|
|
13
|
+
import { type RefObject, useEffect, useLayoutEffect, useState } from 'react';
|
|
14
14
|
import { createRoot } from 'react-dom/client';
|
|
15
|
+
import {
|
|
16
|
+
type ControlAudience,
|
|
17
|
+
dialAudience,
|
|
18
|
+
dialId,
|
|
19
|
+
keepDials,
|
|
20
|
+
readConfig,
|
|
21
|
+
withDefaults,
|
|
22
|
+
} from '../core/controls.ts';
|
|
23
|
+
import { isStudioPerson, markControl, useControls } from './audience';
|
|
15
24
|
import { type IconName, iconMarkup } from './Icon';
|
|
25
|
+
import { isClientView, setClientView } from './prefs';
|
|
26
|
+
|
|
27
|
+
export { client } from '../core/controls.ts';
|
|
16
28
|
|
|
17
29
|
// What the panel calls itself. DialKit hard-codes its own name as the root
|
|
18
30
|
// title; the prototypes say what the thing is instead.
|
|
@@ -45,17 +57,21 @@ export function ensureDialRoot() {
|
|
|
45
57
|
// DialKit hides its panel in production builds unless told otherwise; the
|
|
46
58
|
// deployed prototypes are for tuning, so the dials ship with them.
|
|
47
59
|
createRoot(host).render(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
<>
|
|
61
|
+
<DialRoot
|
|
62
|
+
position={parked ? 'top-left' : 'top-right'}
|
|
63
|
+
theme="dark"
|
|
64
|
+
defaultOpen={open}
|
|
65
|
+
productionEnabled
|
|
66
|
+
/>
|
|
67
|
+
<DialEyes />
|
|
68
|
+
</>,
|
|
54
69
|
);
|
|
55
70
|
// DialKit portals the panel to <body>; it appears once the first panel registers.
|
|
56
71
|
const settle = (root: HTMLElement) => {
|
|
57
72
|
retitle(root);
|
|
58
73
|
placeLinks(root);
|
|
74
|
+
tagEmpty(root);
|
|
59
75
|
new MutationObserver((records) => {
|
|
60
76
|
for (const { type, target } of records) {
|
|
61
77
|
// DialKit keeps the panel's scroll offset when it collapses, which pushes the trigger icon off-centre.
|
|
@@ -65,6 +81,7 @@ export function ensureDialRoot() {
|
|
|
65
81
|
}
|
|
66
82
|
retitle(root);
|
|
67
83
|
placeLinks(root);
|
|
84
|
+
tagEmpty(root);
|
|
68
85
|
}).observe(root, { subtree: true, childList: true, attributeFilter: ['data-collapsed'] });
|
|
69
86
|
};
|
|
70
87
|
const found = document.body.querySelector<HTMLElement>('.dialkit-root');
|
|
@@ -92,30 +109,65 @@ function retitle(root: HTMLElement) {
|
|
|
92
109
|
if (title && title.textContent !== DIALS_TITLE) title.textContent = DIALS_TITLE;
|
|
93
110
|
}
|
|
94
111
|
|
|
95
|
-
type PanelLink = {
|
|
112
|
+
type PanelLink = {
|
|
113
|
+
key: string;
|
|
114
|
+
label: string;
|
|
115
|
+
icon: IconName;
|
|
116
|
+
href?: string;
|
|
117
|
+
newTab?: boolean;
|
|
118
|
+
/** A row that does something here instead of going somewhere. */
|
|
119
|
+
act?: () => void;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Studio's way into Client view and back: the page as a client gets it, beside
|
|
123
|
+
// the dials it changes. The page loads again, so the comments, the dials and
|
|
124
|
+
// the prototype itself all start as a client's would.
|
|
125
|
+
function clientViewRow(): PanelLink {
|
|
126
|
+
const on = isClientView();
|
|
127
|
+
return {
|
|
128
|
+
key: 'client-view',
|
|
129
|
+
label: on ? 'Leave Client view' : 'Client view',
|
|
130
|
+
icon: 'briefcase-01',
|
|
131
|
+
act: () => {
|
|
132
|
+
setClientView(!on);
|
|
133
|
+
location.reload();
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
96
137
|
|
|
97
|
-
// The panel's last rows, under every group: the hub's
|
|
98
|
-
// then the feature's walkthrough when it has one,
|
|
138
|
+
// The panel's last rows, under every group: Client view for Studio, the hub's
|
|
139
|
+
// list of every prototype, then the feature's walkthrough when it has one,
|
|
140
|
+
// which stays the very last.
|
|
99
141
|
function panelLinks(): PanelLink[] {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
142
|
+
const rows: PanelLink[] = isStudioPerson() ? [clientViewRow()] : [];
|
|
143
|
+
rows.push({ key: 'home', href: import.meta.env.BASE_URL, label: 'All prototypes', icon: 'grid-01' });
|
|
144
|
+
if (guide)
|
|
145
|
+
rows.push({
|
|
146
|
+
key: 'guide',
|
|
147
|
+
href: guide,
|
|
148
|
+
label: 'Open the walkthrough',
|
|
149
|
+
icon: 'arrow-up-right',
|
|
150
|
+
newTab: true,
|
|
151
|
+
});
|
|
152
|
+
return rows;
|
|
106
153
|
}
|
|
107
154
|
|
|
108
|
-
function makeLink({ key, href, label, icon, newTab }: PanelLink) {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
155
|
+
function makeLink({ key, href, label, icon, newTab, act }: PanelLink) {
|
|
156
|
+
const row = document.createElement(act ? 'button' : 'a');
|
|
157
|
+
row.className = 'dial-link';
|
|
158
|
+
row.dataset.dialLink = key;
|
|
159
|
+
if (row instanceof HTMLButtonElement) {
|
|
160
|
+
row.type = 'button';
|
|
161
|
+
row.addEventListener('click', () => act?.());
|
|
162
|
+
} else {
|
|
163
|
+
row.href = href ?? import.meta.env.BASE_URL;
|
|
164
|
+
if (newTab) {
|
|
165
|
+
row.target = '_blank';
|
|
166
|
+
row.rel = 'noopener';
|
|
167
|
+
}
|
|
116
168
|
}
|
|
117
|
-
|
|
118
|
-
return
|
|
169
|
+
row.innerHTML = `<span>${label}</span>${iconMarkup(icon, 16)}`;
|
|
170
|
+
return row;
|
|
119
171
|
}
|
|
120
172
|
|
|
121
173
|
// DialKit remounts the content on open and adds groups as panels register, so
|
|
@@ -125,7 +177,7 @@ function placeLinks(root: HTMLElement) {
|
|
|
125
177
|
const content = root.querySelector('.dialkit-folder-root > .dialkit-folder-content');
|
|
126
178
|
if (!content) return;
|
|
127
179
|
const rows = panelLinks().map(
|
|
128
|
-
(l) => content.querySelector<
|
|
180
|
+
(l) => content.querySelector<HTMLElement>(`:scope > [data-dial-link="${l.key}"]`) ?? makeLink(l),
|
|
129
181
|
);
|
|
130
182
|
const tail = Array.from(content.children).slice(-rows.length);
|
|
131
183
|
if (rows.every((row, i) => tail[i] === row)) return;
|
|
@@ -183,7 +235,7 @@ const rowLabel = (row: HTMLElement) =>
|
|
|
183
235
|
row.getAttribute('aria-label') ??
|
|
184
236
|
(
|
|
185
237
|
row.querySelector('.dialkit-labeled-control-label')?.firstChild ??
|
|
186
|
-
row.querySelector('.dialkit-select-label') ??
|
|
238
|
+
row.querySelector('.dialkit-select-label, .dialkit-text-label, .dialkit-color-label') ??
|
|
187
239
|
row
|
|
188
240
|
).textContent?.trim() ??
|
|
189
241
|
'';
|
|
@@ -263,19 +315,204 @@ function installHints() {
|
|
|
263
315
|
document.addEventListener('scroll', hide, true);
|
|
264
316
|
}
|
|
265
317
|
|
|
266
|
-
|
|
318
|
+
// Who a dial is for (core/controls.ts). Every dial is internal until marked
|
|
319
|
+
// client-facing: with `client(...)` where it is declared, or by Studio's eye
|
|
320
|
+
// beside its row, which is stored per site and overrules the code. Studio's
|
|
321
|
+
// panel has every dial. A Client's has only the client-facing ones: the others
|
|
322
|
+
// are never handed to DialKit, and code reads their defaults.
|
|
323
|
+
|
|
324
|
+
type Panel = {
|
|
325
|
+
/** Each dial's id by the label path its row shows, as the hints key theirs. */
|
|
326
|
+
byLabel: Record<string, string>;
|
|
327
|
+
inCode: Record<string, ControlAudience>;
|
|
328
|
+
/** Nothing in it for the person looking, so its header leaves the panel. */
|
|
329
|
+
empty: boolean;
|
|
330
|
+
};
|
|
331
|
+
const panels = new Map<string, Panel>();
|
|
332
|
+
|
|
333
|
+
function labelIds(
|
|
334
|
+
panel: string,
|
|
335
|
+
cfg: DialConfig,
|
|
336
|
+
into: Record<string, string>,
|
|
337
|
+
labels = '',
|
|
338
|
+
path: string[] = [],
|
|
339
|
+
) {
|
|
340
|
+
for (const [k, v] of Object.entries(cfg)) {
|
|
341
|
+
if (k === '_collapsed') continue;
|
|
342
|
+
const label = labels + (actionLabel(v) ?? labelOf(k));
|
|
343
|
+
if (v && typeof v === 'object' && !Array.isArray(v) && !('type' in v))
|
|
344
|
+
labelIds(panel, v as DialConfig, into, label + PATH_SEP, [...path, k]);
|
|
345
|
+
else into[label] = dialId(panel, [...path, k]);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* A panel's config as DialKit takes it (`all`), the part of it the person
|
|
351
|
+
* looking gets (`shown`), and DialKit's own options. Registers the hints too.
|
|
352
|
+
*/
|
|
353
|
+
function usePanel<T extends DialConfig>(name: string, config: T, options?: DialOptions<T>) {
|
|
267
354
|
useLayoutEffect(ensureDialRoot, []);
|
|
355
|
+
const { studio, marks } = useControls();
|
|
268
356
|
const { hints: h, ...rest } = options ?? {};
|
|
269
|
-
|
|
270
|
-
|
|
357
|
+
const { config: all, dials } = readConfig(name, config);
|
|
358
|
+
const inCode = Object.fromEntries(dials.map((d) => [d.id, d.inCode]));
|
|
359
|
+
const shown = studio
|
|
360
|
+
? all
|
|
361
|
+
: keepDials(name, all, (id) => dialAudience(marks, id, inCode[id] ?? 'internal') === 'client');
|
|
362
|
+
const byLabel: Record<string, string> = {};
|
|
363
|
+
labelIds(name, all as DialConfig, byLabel);
|
|
364
|
+
panels.set(name, { byLabel, inCode, empty: Object.keys(shown).length === 0 });
|
|
365
|
+
registerHints(name, all as DialConfig, h as Record<string, unknown> | undefined);
|
|
366
|
+
/** What the prototype reads: DialKit's values, with the default of every dial it was not given. */
|
|
367
|
+
const read = (values: unknown) => (studio ? values : withDefaults(all, values as Record<string, unknown>));
|
|
368
|
+
return { shown: shown as T, rest, read };
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// DialKit draws a header for a panel with no dials in it.
|
|
372
|
+
function tagEmpty(root: HTMLElement) {
|
|
373
|
+
for (const section of root.querySelectorAll<HTMLElement>('.dialkit-folder-section')) {
|
|
374
|
+
const title = section
|
|
375
|
+
.querySelector(':scope > .dialkit-folder-header .dialkit-folder-title')
|
|
376
|
+
?.textContent?.trim();
|
|
377
|
+
const empty = !!title && !!panels.get(title)?.empty;
|
|
378
|
+
if (empty !== 'dialEmpty' in section.dataset) section.toggleAttribute('data-dial-empty', empty);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export function useDials<T extends DialConfig>(name: string, config: T, options?: DialOptions<T>) {
|
|
383
|
+
const { shown, rest, read } = usePanel(name, config, options);
|
|
384
|
+
return read(useDialKit(name, shown, rest)) as ReturnType<typeof useDialKit<T>>;
|
|
271
385
|
}
|
|
272
386
|
|
|
273
387
|
// The same panel with its controller, for dials that code also sets (every toggle at once).
|
|
274
388
|
export function useDialsController<T extends DialConfig>(name: string, config: T, options?: DialOptions<T>) {
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
389
|
+
const { shown, rest, read } = usePanel(name, config, options);
|
|
390
|
+
const controller = useDialKitController(name, shown, rest);
|
|
391
|
+
return { ...controller, values: read(controller.values) } as ReturnType<typeof useDialKitController<T>>;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Studio's eye beside each dial: one click marks it client-facing or internal.
|
|
395
|
+
// DialKit has no slot in a row, so the row gives up 32px at its right end
|
|
396
|
+
// (kit/dials.css) and the eye is drawn over that slot, from outside the row:
|
|
397
|
+
// a click on it never reaches a slider's drag.
|
|
398
|
+
|
|
399
|
+
const EYE_ROWS =
|
|
400
|
+
'.dialkit-slider, .dialkit-labeled-control, .dialkit-select-row, .dialkit-text-control, .dialkit-color-control';
|
|
401
|
+
/** The panel's own sticky header, which a row scrolls under. */
|
|
402
|
+
const PANEL_HEAD = 48;
|
|
403
|
+
|
|
404
|
+
type Spot = { id: string; label: string; top: number; left: number };
|
|
405
|
+
|
|
406
|
+
function spotOf(row: HTMLElement, clip: DOMRect): Spot | null {
|
|
407
|
+
if (row.parentElement?.closest(EYE_ROWS)) return null;
|
|
408
|
+
const { path, panel } = rowPlace(row);
|
|
409
|
+
const label = rowLabel(row);
|
|
410
|
+
const id = panel ? panels.get(panel)?.byLabel[[...path, label].join(PATH_SEP)] : undefined;
|
|
411
|
+
if (!id) return null;
|
|
412
|
+
if (!('dialEye' in row.dataset)) row.dataset.dialEye = '';
|
|
413
|
+
const r = row.getBoundingClientRect();
|
|
414
|
+
const mid = r.top + r.height / 2;
|
|
415
|
+
if (r.height === 0 || mid < clip.top + PANEL_HEAD || mid > clip.bottom - 8) return null;
|
|
416
|
+
return { id, label, top: Math.round(mid), left: Math.round(r.right) };
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function eyeSpots(): Spot[] {
|
|
420
|
+
const clip = document.querySelector('.dialkit-root .dialkit-panel-inner')?.getBoundingClientRect();
|
|
421
|
+
if (!clip) return [];
|
|
422
|
+
const rows = document.querySelectorAll<HTMLElement>(`.dialkit-root :is(${EYE_ROWS})`);
|
|
423
|
+
return [...rows].flatMap((row) => spotOf(row, clip) ?? []);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Where each eye sits, followed every frame while Studio can mark: the panel scrolls, folds and is dragged. */
|
|
427
|
+
function useEyeSpots(on: boolean) {
|
|
428
|
+
const [spots, setSpots] = useState<Spot[]>([]);
|
|
429
|
+
useEffect(() => {
|
|
430
|
+
if (!on) return setSpots([]);
|
|
431
|
+
document.documentElement.dataset.dialMarking = '';
|
|
432
|
+
let frame = 0;
|
|
433
|
+
let last = '';
|
|
434
|
+
const tick = () => {
|
|
435
|
+
const next = eyeSpots();
|
|
436
|
+
const sig = JSON.stringify(next);
|
|
437
|
+
if (sig !== last) setSpots(next);
|
|
438
|
+
last = sig;
|
|
439
|
+
frame = requestAnimationFrame(tick);
|
|
440
|
+
};
|
|
441
|
+
tick();
|
|
442
|
+
return () => {
|
|
443
|
+
cancelAnimationFrame(frame);
|
|
444
|
+
delete document.documentElement.dataset.dialMarking;
|
|
445
|
+
};
|
|
446
|
+
}, [on]);
|
|
447
|
+
return spots;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const EYE =
|
|
451
|
+
'M2.4 12.7a1.2 1.2 0 0 1 0-1.4C3.5 9.6 6.7 5 12 5s8.5 4.6 9.6 6.3a1.2 1.2 0 0 1 0 1.4C20.5 14.4 17.3 19 12 19s-8.5-4.6-9.6-6.3Z';
|
|
452
|
+
|
|
453
|
+
function EyeIcon({ off }: { off: boolean }) {
|
|
454
|
+
return (
|
|
455
|
+
<svg
|
|
456
|
+
width="16"
|
|
457
|
+
height="16"
|
|
458
|
+
viewBox="0 0 24 24"
|
|
459
|
+
fill="none"
|
|
460
|
+
stroke="currentColor"
|
|
461
|
+
strokeWidth="2"
|
|
462
|
+
strokeLinecap="round"
|
|
463
|
+
strokeLinejoin="round"
|
|
464
|
+
aria-hidden="true"
|
|
465
|
+
>
|
|
466
|
+
<path d={EYE} />
|
|
467
|
+
<circle cx="12" cy="12" r="3" />
|
|
468
|
+
{off ? <path d="M4 4l16 16" /> : null}
|
|
469
|
+
</svg>
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function inCodeOf(id: string): ControlAudience {
|
|
474
|
+
for (const p of panels.values()) if (id in p.inCode) return p.inCode[id];
|
|
475
|
+
return 'internal';
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function DialEyes() {
|
|
479
|
+
const { studio, canMark, marks, failed } = useControls();
|
|
480
|
+
const spots = useEyeSpots(canMark);
|
|
481
|
+
// DialKit's own tools (Copy parameters, Save version) are Studio's: the panel shows them only under this mark.
|
|
482
|
+
useEffect(() => {
|
|
483
|
+
document.documentElement.toggleAttribute('data-dial-studio', studio);
|
|
484
|
+
}, [studio]);
|
|
485
|
+
if (!canMark) return null;
|
|
486
|
+
return (
|
|
487
|
+
<div data-harness="dial-eyes">
|
|
488
|
+
{spots.map((s) => {
|
|
489
|
+
const on = dialAudience(marks, s.id, inCodeOf(s.id)) === 'client';
|
|
490
|
+
return (
|
|
491
|
+
<button
|
|
492
|
+
key={s.id}
|
|
493
|
+
type="button"
|
|
494
|
+
className="dial-eye"
|
|
495
|
+
style={{ top: s.top, left: s.left }}
|
|
496
|
+
aria-pressed={on}
|
|
497
|
+
aria-label={`Client-facing: ${s.label}`}
|
|
498
|
+
title={
|
|
499
|
+
on
|
|
500
|
+
? 'Clients get this dial. Click to keep it internal.'
|
|
501
|
+
: 'Internal. Click to give it to clients.'
|
|
502
|
+
}
|
|
503
|
+
onClick={() => void markControl('dial', s.id, on ? 'internal' : 'client')}
|
|
504
|
+
>
|
|
505
|
+
<EyeIcon off={!on} />
|
|
506
|
+
</button>
|
|
507
|
+
);
|
|
508
|
+
})}
|
|
509
|
+
{failed ? (
|
|
510
|
+
<p className="dial-eye-failed" role="alert">
|
|
511
|
+
{failed}
|
|
512
|
+
</p>
|
|
513
|
+
) : null}
|
|
514
|
+
</div>
|
|
515
|
+
);
|
|
279
516
|
}
|
|
280
517
|
|
|
281
518
|
// Dial values as CSS variables on an element: `--key`, a folder's as `--folder-key`,
|
package/kit/harness.css
CHANGED
|
@@ -97,3 +97,37 @@
|
|
|
97
97
|
bottom: auto;
|
|
98
98
|
top: 24px;
|
|
99
99
|
}
|
|
100
|
+
|
|
101
|
+
/* Who a variant is for (kit/Variants.tsx). In Studio's picker a dot says a
|
|
102
|
+
client gets this one; the eye turns clicks into marks, and the note says so. */
|
|
103
|
+
.proto-picker-item { gap: 6px; }
|
|
104
|
+
.proto-picker-dot {
|
|
105
|
+
width: 6px;
|
|
106
|
+
height: 6px;
|
|
107
|
+
border-radius: 50%;
|
|
108
|
+
box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.35);
|
|
109
|
+
transition: background-color 120ms cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 120ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
|
110
|
+
}
|
|
111
|
+
[data-theirs] > .proto-picker-dot { background: oklch(0.72 0.17 150); box-shadow: none; }
|
|
112
|
+
.proto-picker-item[aria-pressed="false"] { color: oklch(1 0 0 / 0.45); }
|
|
113
|
+
.proto-picker-item[aria-pressed="true"] { color: oklch(1 0 0); }
|
|
114
|
+
.proto-picker-choose { padding: 0 10px; border-radius: 999px; }
|
|
115
|
+
.proto-picker-choose[aria-pressed="true"] { background: oklch(1 0 0 / 0.12); }
|
|
116
|
+
.proto-picker-note {
|
|
117
|
+
position: fixed;
|
|
118
|
+
left: 50%;
|
|
119
|
+
bottom: 72px;
|
|
120
|
+
z-index: 2147483647;
|
|
121
|
+
transform: translateX(-50%);
|
|
122
|
+
margin: 0;
|
|
123
|
+
padding: 4px 12px;
|
|
124
|
+
border-radius: 999px;
|
|
125
|
+
background: oklch(0.145 0 0 / 0.82);
|
|
126
|
+
-webkit-backdrop-filter: blur(12px) saturate(1.4);
|
|
127
|
+
backdrop-filter: blur(12px) saturate(1.4);
|
|
128
|
+
color: oklch(1 0 0 / 0.85);
|
|
129
|
+
font: 500 13px/20px var(--sys-font);
|
|
130
|
+
white-space: nowrap;
|
|
131
|
+
-webkit-font-smoothing: antialiased;
|
|
132
|
+
}
|
|
133
|
+
.proto-picker-note[data-position="top"] { bottom: auto; top: 72px; }
|
package/kit/prefs.ts
CHANGED
|
@@ -22,6 +22,7 @@ const COMMENTS_KEY = 'proto:comments';
|
|
|
22
22
|
const CLIENT_VIEW_KEY = 'proto:client-view';
|
|
23
23
|
|
|
24
24
|
let appearance: Appearance = readAppearance();
|
|
25
|
+
let pinned: 'light' | 'dark' | null = null;
|
|
25
26
|
let commentsHidden = readStored(COMMENTS_KEY) === 'hidden';
|
|
26
27
|
let clientView = readStored(CLIENT_VIEW_KEY) === 'on';
|
|
27
28
|
let forceReduce = false;
|
|
@@ -61,7 +62,8 @@ function subscribe(fn: () => void) {
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
function applyTheme() {
|
|
64
|
-
const
|
|
65
|
+
const shown = pinned ?? appearance;
|
|
66
|
+
const dark = shown === 'dark' || (shown === 'system' && darkQuery.matches);
|
|
65
67
|
// The browser chrome and native controls follow the app's theme, not the OS: the class decides.
|
|
66
68
|
root.style.colorScheme = dark ? 'dark' : 'light';
|
|
67
69
|
document.querySelector('meta[name="theme-color"]')?.setAttribute('content', dark ? '#0c0e12' : '#ffffff');
|
|
@@ -76,6 +78,24 @@ function applyMotion() {
|
|
|
76
78
|
else delete root.dataset.motion;
|
|
77
79
|
}
|
|
78
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Holds the page to one look whatever the person's own theme is, without
|
|
83
|
+
* changing or storing that choice; null lets it go. A `Board` pins the look
|
|
84
|
+
* its files export in, so what is on screen is what `pnpm export` writes.
|
|
85
|
+
*/
|
|
86
|
+
export function pinAppearance(next: 'light' | 'dark' | null) {
|
|
87
|
+
if (next === pinned) return;
|
|
88
|
+
pinned = next;
|
|
89
|
+
applyTheme();
|
|
90
|
+
emit();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The look `?theme=` asks for, when it names one: what an export of this page is written in. */
|
|
94
|
+
export const urlAppearance = (): 'light' | 'dark' | null => {
|
|
95
|
+
const asked = params.get('theme');
|
|
96
|
+
return asked === 'light' || asked === 'dark' ? asked : null;
|
|
97
|
+
};
|
|
98
|
+
|
|
79
99
|
export function setAppearance(next: Appearance) {
|
|
80
100
|
if (next === appearance) return;
|
|
81
101
|
appearance = next;
|
|
@@ -117,6 +137,8 @@ export function setClientView(on: boolean) {
|
|
|
117
137
|
export const isDark = () => root.classList.contains('dark-mode');
|
|
118
138
|
export const prefersReducedMotion = () => root.dataset.motion === 'reduce';
|
|
119
139
|
|
|
140
|
+
/** Client view, for the controls that step aside in it (kit/audience.ts). */
|
|
141
|
+
export const useClientView = () => useSyncExternalStore(subscribe, isClientView);
|
|
120
142
|
export const useAppearance = () => useSyncExternalStore(subscribe, () => appearance);
|
|
121
143
|
export const useDark = () => useSyncExternalStore(subscribe, isDark);
|
|
122
144
|
export const useReducedMotion = () => useSyncExternalStore(subscribe, prefersReducedMotion);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milesroxas/design-hub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "The Design Hub product: the hub that lists and serves prototypes, the review panel and its API, the sign-in gate, the kit, and the design-hub CLI. A project installs it and keeps only its prototypes, kit materials and docs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -64,10 +64,11 @@
|
|
|
64
64
|
"@types/node": "^26.6.6",
|
|
65
65
|
"@types/react": "^19.3.0",
|
|
66
66
|
"@types/react-dom": "^19.3.0",
|
|
67
|
+
"@vercel/blob": "^2.9.0",
|
|
67
68
|
"@vercel/functions": "^3.10.4",
|
|
68
69
|
"@vitejs/plugin-react": "^6.1.2",
|
|
69
70
|
"axe-core": "^4.14.0",
|
|
70
|
-
"dialkit": "^2.1
|
|
71
|
+
"dialkit": "^2.2.1",
|
|
71
72
|
"marked": "^18.1.2",
|
|
72
73
|
"motion": "^14.6.0",
|
|
73
74
|
"postcss": "^8.5.32",
|
package/shell/ClientViewNote.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { useControls } from '@kit/audience';
|
|
1
2
|
import { Icon } from '@kit/Icon';
|
|
3
|
+
import { setClientView, useClientView } from '@kit/prefs';
|
|
2
4
|
import { Button } from '@kit/ui';
|
|
3
5
|
import './shell.css';
|
|
4
6
|
|
|
@@ -7,12 +9,38 @@ import './shell.css';
|
|
|
7
9
|
* its words and look, with the one way back. On the index and on a
|
|
8
10
|
* prototype's page that Client view shows as missing.
|
|
9
11
|
*/
|
|
10
|
-
export function ClientViewNote({
|
|
12
|
+
export function ClientViewNote({
|
|
13
|
+
onLeave,
|
|
14
|
+
text = 'Client view: prototypes as a client sees them',
|
|
15
|
+
at,
|
|
16
|
+
}: {
|
|
17
|
+
onLeave: () => void;
|
|
18
|
+
text?: string;
|
|
19
|
+
/** On a prototype's page the note sits at the top: the picker and the comment bar hold the bottom. */
|
|
20
|
+
at?: 'top';
|
|
21
|
+
}) {
|
|
11
22
|
return (
|
|
12
|
-
<p className="index-viewing sys" role="status">
|
|
23
|
+
<p className="index-viewing sys" role="status" data-at={at}>
|
|
13
24
|
<Icon name="briefcase-01" size={14} />
|
|
14
|
-
<span>
|
|
25
|
+
<span>{text}</span>
|
|
15
26
|
<Button kind="tertiary" size={null} className="index-viewing-act" label="Leave" onClick={onLeave} />
|
|
16
27
|
</p>
|
|
17
28
|
);
|
|
18
29
|
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* On a prototype's page, for a Studio person in Client view: what the page
|
|
33
|
+
* is showing, and the way back. Client view is entered from the Controls
|
|
34
|
+
* panel or the comment bar; it is left from here, from either of them, or
|
|
35
|
+
* from the index.
|
|
36
|
+
*/
|
|
37
|
+
export function PrototypeClientView() {
|
|
38
|
+
const { person } = useControls();
|
|
39
|
+
const on = useClientView();
|
|
40
|
+
if (!person || !on) return null;
|
|
41
|
+
const leave = () => {
|
|
42
|
+
setClientView(false);
|
|
43
|
+
location.reload();
|
|
44
|
+
};
|
|
45
|
+
return <ClientViewNote onLeave={leave} at="top" text="Client view: this prototype as a client gets it" />;
|
|
46
|
+
}
|
package/shell/Guide.tsx
CHANGED
|
@@ -71,14 +71,20 @@ function GuideList() {
|
|
|
71
71
|
<ul>
|
|
72
72
|
{[...guides.keys()].map((f) => (
|
|
73
73
|
<li key={f}>
|
|
74
|
-
<a
|
|
74
|
+
<a
|
|
75
|
+
href={
|
|
76
|
+
import.meta.env.BASE_URL === '/' ? guideHref(f) : `${import.meta.env.BASE_URL}guide/${f}/`
|
|
77
|
+
}
|
|
78
|
+
>
|
|
79
|
+
{featureTitle(f)}
|
|
80
|
+
</a>
|
|
75
81
|
</li>
|
|
76
82
|
))}
|
|
77
83
|
</ul>
|
|
78
84
|
) : (
|
|
79
85
|
<p>No walkthrough yet. Start one with pnpm new:guide <feature>.</p>
|
|
80
86
|
)}
|
|
81
|
-
<a href=
|
|
87
|
+
<a href={import.meta.env.BASE_URL}>All prototypes</a>
|
|
82
88
|
</main>
|
|
83
89
|
);
|
|
84
90
|
}
|
|
@@ -128,7 +134,7 @@ function GuidePage({ feature }: { feature: string }) {
|
|
|
128
134
|
<main className="doc">
|
|
129
135
|
<div className="doc-layout">
|
|
130
136
|
<header className="doc-head">
|
|
131
|
-
<a className="doc-back" href=
|
|
137
|
+
<a className="doc-back" href={import.meta.env.BASE_URL}>
|
|
132
138
|
<Icon name="arrow-left" size={16} />
|
|
133
139
|
Prototypes
|
|
134
140
|
</a>
|
|
@@ -142,7 +148,7 @@ function GuidePage({ feature }: { feature: string }) {
|
|
|
142
148
|
{prototype ? (
|
|
143
149
|
<a
|
|
144
150
|
className="btn btn-primary btn-md"
|
|
145
|
-
href={
|
|
151
|
+
href={`${import.meta.env.BASE_URL}${prototype.slug}/`}
|
|
146
152
|
target="_blank"
|
|
147
153
|
rel="noreferrer"
|
|
148
154
|
>
|
|
@@ -167,7 +173,7 @@ function GuidePage({ feature }: { feature: string }) {
|
|
|
167
173
|
{/* biome-ignore lint/security/noDangerouslySetInnerHtml: compiled at build time from a Markdown file in this repo */}
|
|
168
174
|
<article className="doc-body" dangerouslySetInnerHTML={{ __html: html }} />
|
|
169
175
|
<footer className="doc-foot">
|
|
170
|
-
<a href=
|
|
176
|
+
<a href={import.meta.env.BASE_URL}>All prototypes</a>
|
|
171
177
|
</footer>
|
|
172
178
|
</div>
|
|
173
179
|
</main>
|
package/shell/Index.tsx
CHANGED
|
@@ -22,6 +22,7 @@ import { AUDIENCE_LABEL, audienceIn, emptyState, lensOf, withAudience } from './
|
|
|
22
22
|
import { ClientViewNote } from './ClientViewNote';
|
|
23
23
|
import { type Hub, loadHub, saveAudience } from './hub';
|
|
24
24
|
import { type Entry, guides } from './registry';
|
|
25
|
+
import { signedOut } from './review/client';
|
|
25
26
|
import './shell.css';
|
|
26
27
|
|
|
27
28
|
// The index is built from the server's answer (shell/hub.ts): Studio's view
|
|
@@ -51,7 +52,11 @@ const groupsOf = (list: Entry[]): Group[] => {
|
|
|
51
52
|
return {
|
|
52
53
|
id: `feature-${f}`,
|
|
53
54
|
title: featureTitle(f),
|
|
54
|
-
guide: guides.has(f)
|
|
55
|
+
guide: guides.has(f)
|
|
56
|
+
? import.meta.env.BASE_URL === '/'
|
|
57
|
+
? guideHref(f)
|
|
58
|
+
: `${import.meta.env.BASE_URL}guide/${f}/`
|
|
59
|
+
: undefined,
|
|
55
60
|
items: primary ? [primary] : alternates,
|
|
56
61
|
alternates: primary ? alternates : [],
|
|
57
62
|
explorations: own.filter((e) => e.kind === 'exploration'),
|
|
@@ -96,7 +101,10 @@ function useIndexFilter(entries: Entry[]) {
|
|
|
96
101
|
const RISE_CAP = 8;
|
|
97
102
|
const rise = (i: number) => ({ '--i': Math.min(i, RISE_CAP) }) as CSSProperties;
|
|
98
103
|
|
|
99
|
-
type Loaded =
|
|
104
|
+
type Loaded =
|
|
105
|
+
| { status: 'loading' }
|
|
106
|
+
| { status: 'error'; message: string; signedOut: boolean }
|
|
107
|
+
| { status: 'ready'; hub: Hub };
|
|
100
108
|
|
|
101
109
|
/**
|
|
102
110
|
* The index as the server answers it for this view, and Studio's switch.
|
|
@@ -113,7 +121,8 @@ function useHub(clientView: boolean) {
|
|
|
113
121
|
setLoaded({ status: 'loading' });
|
|
114
122
|
loadHub(clientView).then(
|
|
115
123
|
(hub) => current && setLoaded({ status: 'ready', hub }),
|
|
116
|
-
(error: Error) =>
|
|
124
|
+
(error: Error) =>
|
|
125
|
+
current && setLoaded({ status: 'error', message: error.message, signedOut: signedOut(error) }),
|
|
117
126
|
);
|
|
118
127
|
return () => {
|
|
119
128
|
current = false;
|
|
@@ -213,15 +222,28 @@ function IndexPage({ loaded, controls, head }: { loaded: Loaded; controls: Contr
|
|
|
213
222
|
return (
|
|
214
223
|
<main className="index" aria-busy={loaded.status === 'loading'}>
|
|
215
224
|
<IndexHead>{head}</IndexHead>
|
|
216
|
-
{loaded.status === 'error' ?
|
|
217
|
-
<p className="index-none" role="alert">
|
|
218
|
-
The prototypes did not load: {loaded.message}
|
|
219
|
-
</p>
|
|
220
|
-
) : null}
|
|
225
|
+
{loaded.status === 'error' ? <LoadFailed loaded={loaded} /> : null}
|
|
221
226
|
</main>
|
|
222
227
|
);
|
|
223
228
|
}
|
|
224
229
|
|
|
230
|
+
/** The index did not load: signed out says how to sign in again, as the client's hub does; anything else says why. */
|
|
231
|
+
function LoadFailed({ loaded }: { loaded: Extract<Loaded, { status: 'error' }> }) {
|
|
232
|
+
if (!loaded.signedOut)
|
|
233
|
+
return (
|
|
234
|
+
<p className="index-none" role="alert">
|
|
235
|
+
The prototypes did not load: {loaded.message}
|
|
236
|
+
</p>
|
|
237
|
+
);
|
|
238
|
+
return (
|
|
239
|
+
<section className="index-empty index-signed-out" role="alert">
|
|
240
|
+
<h2>You are signed out</h2>
|
|
241
|
+
<p>Reload the page to see how to sign in again.</p>
|
|
242
|
+
<Button kind="secondary" size="sm" label="Reload" onClick={() => location.reload()} />
|
|
243
|
+
</section>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
225
247
|
function IndexHead({ children }: { children?: ReactNode }) {
|
|
226
248
|
return (
|
|
227
249
|
<header className="index-head">
|
|
@@ -305,7 +327,7 @@ function IndexList({
|
|
|
305
327
|
<li key={e.slug} className="index-rise" style={rise(from + i)}>
|
|
306
328
|
<a
|
|
307
329
|
className="index-row"
|
|
308
|
-
href={
|
|
330
|
+
href={`${import.meta.env.BASE_URL}${e.slug}/`}
|
|
309
331
|
data-kind={e.kind}
|
|
310
332
|
data-chosen={leaving === e.slug || undefined}
|
|
311
333
|
onClick={(ev) => onOpen(ev, e.slug)}
|
|
@@ -449,7 +471,7 @@ function Explorations({
|
|
|
449
471
|
<li key={e.slug} className="index-rise" style={rise(at + 1 + i)}>
|
|
450
472
|
<a
|
|
451
473
|
className="index-card"
|
|
452
|
-
href={
|
|
474
|
+
href={`${import.meta.env.BASE_URL}${e.slug}/`}
|
|
453
475
|
data-chosen={leaving === e.slug || undefined}
|
|
454
476
|
onClick={(ev) => onOpen(ev, e.slug)}
|
|
455
477
|
>
|