@milesroxas/design-hub 0.8.1 → 0.10.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 (78) hide show
  1. package/README.md +7 -2
  2. package/core/controls.test.ts +176 -0
  3. package/core/controls.ts +195 -0
  4. package/core/prototype.test.ts +83 -0
  5. package/core/prototype.ts +84 -0
  6. package/core/review/model.ts +32 -0
  7. package/core/review/policy.test.ts +4 -2
  8. package/core/review/policy.ts +4 -2
  9. package/core/review/service.test.ts +223 -4
  10. package/core/review/service.ts +111 -2
  11. package/core/review/store.ts +13 -0
  12. package/dist/core/controls.d.ts +55 -0
  13. package/dist/core/controls.js +174 -0
  14. package/dist/core/prototype.d.ts +35 -0
  15. package/dist/core/prototype.js +84 -0
  16. package/dist/core/review/model.d.ts +13 -0
  17. package/dist/core/review/model.js +27 -0
  18. package/dist/core/review/policy.d.ts +1 -1
  19. package/dist/core/review/policy.js +1 -0
  20. package/dist/core/review/service.d.ts +50 -1
  21. package/dist/core/review/service.js +97 -3
  22. package/dist/core/review/store.d.ts +13 -0
  23. package/dist/core/review/store.js +13 -0
  24. package/dist/scripts/guard.d.ts +11 -0
  25. package/dist/scripts/guard.js +44 -0
  26. package/dist/scripts/lib/cdp.js +6 -1
  27. package/dist/scripts/lib/export-smoke.d.ts +18 -0
  28. package/dist/scripts/lib/export-smoke.js +73 -0
  29. package/dist/scripts/lib/rules.d.ts +1 -0
  30. package/dist/scripts/lib/rules.js +1 -0
  31. package/dist/scripts/new.js +5 -2
  32. package/dist/scripts/release-check.d.ts +5 -3
  33. package/dist/scripts/release-check.js +17 -4
  34. package/dist/scripts/share.d.ts +2 -2
  35. package/dist/server/api.js +21 -0
  36. package/dist/server/session.d.ts +5 -1
  37. package/dist/server/session.js +39 -21
  38. package/dist/vercel/proxy.js +44 -8
  39. package/dist/vite/boundary.d.ts +93 -0
  40. package/dist/vite/boundary.js +218 -0
  41. package/dist/vite/css-boundary.d.ts +39 -0
  42. package/dist/vite/css-boundary.js +167 -0
  43. package/dist/vite/kit.js +15 -6
  44. package/dist/vite/leaks.d.ts +37 -0
  45. package/dist/vite/leaks.js +331 -0
  46. package/dist/vite/plugin.js +2 -1
  47. package/dist/vite/registry.d.ts +15 -4
  48. package/dist/vite/registry.js +531 -27
  49. package/dist/vite/settle.d.ts +27 -0
  50. package/dist/vite/settle.js +185 -0
  51. package/kit/Artboard.tsx +21 -8
  52. package/kit/Space.tsx +4 -3
  53. package/kit/Variants.tsx +193 -65
  54. package/kit/ViewTools.tsx +77 -11
  55. package/kit/audience.ts +85 -0
  56. package/kit/dials.css +59 -0
  57. package/kit/dials.tsx +272 -35
  58. package/kit/harness.css +34 -0
  59. package/kit/prefs.ts +23 -1
  60. package/package.json +5 -4
  61. package/shell/ClientViewNote.tsx +46 -0
  62. package/shell/Guide.tsx +17 -2
  63. package/shell/Index.tsx +257 -25
  64. package/shell/audience.test.ts +63 -0
  65. package/shell/audience.ts +47 -0
  66. package/shell/controls.ts +26 -0
  67. package/shell/hub.ts +36 -0
  68. package/shell/main.tsx +51 -5
  69. package/shell/registry.ts +28 -7
  70. package/shell/registry.virtual.d.ts +12 -4
  71. package/shell/review/client.ts +16 -4
  72. package/shell/review/review.css +2 -2
  73. package/shell/shell.css +54 -3
  74. package/shell/system.css +5 -0
  75. package/skills/miles-brand/SKILL.md +11 -1
  76. package/skills/miles-deploy/SKILL.md +19 -0
  77. package/skills/miles-new-feature/SKILL.md +1 -1
  78. package/skills/miles-prototype/SKILL.md +48 -2
@@ -0,0 +1,26 @@
1
+ // A prototype page's one read of its controls, handed to the kit before the
2
+ // prototype renders (kit/audience.ts): the view the server gives this person
3
+ // and what Studio marked on the dials and variants. The page is the person's
4
+ // own view; Client view narrows it in the kit, with no second read.
5
+ import { setControls } from '@kit/audience';
6
+ import { type ControlAudience, type ControlKind, type Marks, NO_MARKS } from '../core/controls';
7
+ import type { PersonKind } from '../core/review/model';
8
+ import { call, noApi } from './review/client';
9
+
10
+ /** `design-hub export` captures the prototype as Studio tuned it: every dial, nothing to mark. */
11
+ export const exportControls = () => setControls({ studio: true, marks: NO_MARKS, save: null });
12
+
13
+ export async function loadControls(prototype: string) {
14
+ const save = (kind: ControlKind, id: string, audience: ControlAudience) =>
15
+ call('control.audience', { prototype, kind, id, audience });
16
+ try {
17
+ const { view, dials, variants } = await call<{ view: PersonKind } & Marks>('controls', undefined, {
18
+ prototype,
19
+ });
20
+ setControls({ studio: view === 'studio', marks: { dials, variants }, save });
21
+ } catch (error) {
22
+ // No review API at all (a local preview of the build) is Studio's view, as on the index, with nowhere to keep a mark.
23
+ // Any other failure leaves the narrowest view: a Client's, with nothing marked.
24
+ setControls({ studio: noApi(error), marks: NO_MARKS, save: null });
25
+ }
26
+ }
package/shell/hub.ts ADDED
@@ -0,0 +1,36 @@
1
+ // The index's one read and its one write, over the review API. The index is
2
+ // built from the server's answer (shell/audience.ts): Studio's view loads
3
+ // every slug, then each entry; a Client's view loads only the client-facing
4
+ // entries. An entry that is not there is skipped; one that fails otherwise is counted. Nothing here filters as
5
+ // the boundary: the server and the gate decide what reaches whom.
6
+ import type { Audience, PersonKind } from '../core/review/model';
7
+ import { type HubAnswer, slugsFor } from './audience';
8
+ import { type Entry, everySlug, getEntries } from './registry';
9
+ import { call, type Me, noApi } from './review/client';
10
+
11
+ /** `failed` counts entries that did not load for a reason other than not being there. */
12
+ export type Hub = HubAnswer & { me: Me | null; entries: Entry[]; failed: number };
13
+
14
+ /** Who is signed in and the index read. With no review API at all (a local preview of the build), Studio's view. */
15
+ export async function readHub(viewAs?: PersonKind): Promise<HubAnswer & { me: Me | null }> {
16
+ try {
17
+ const { person } = await call<{ person: Me | null }>('me');
18
+ const answer = await call<HubAnswer>('prototypes', undefined, viewAs ? { viewAs } : {});
19
+ return { me: person, ...answer };
20
+ } catch (error) {
21
+ if (noApi(error)) return { me: null, view: 'studio', clientFacing: [] };
22
+ throw error;
23
+ }
24
+ }
25
+
26
+ /** The index, as the server says this person sees it: Client view when `clientView` is on. */
27
+ export async function loadHub(clientView: boolean): Promise<Hub> {
28
+ const answer = await readHub(clientView ? 'client' : undefined);
29
+ // Studio's list failing to load is an error, never an empty index.
30
+ const all = answer.view === 'studio' ? await everySlug() : [];
31
+ return { ...answer, ...(await getEntries(slugsFor(answer, all))) };
32
+ }
33
+
34
+ /** Studio's switch: marks one prototype client-facing or internal. */
35
+ export const saveAudience = (prototype: string, audience: Audience) =>
36
+ call<{ prototype: string; audience: Audience }>('prototype.audience', { prototype, audience });
package/shell/main.tsx CHANGED
@@ -2,13 +2,18 @@ import { setGuide } from '@kit/dials';
2
2
  import '@kit/tokens.css';
3
3
  import '@kit/base.css';
4
4
  import './system.css';
5
- import { attachLapse } from '@kit/prefs';
5
+ import { attachLapse, isClientView, setClientView } from '@kit/prefs';
6
6
  import { lazy, type ReactNode, StrictMode, Suspense } from 'react';
7
7
  import { createRoot } from 'react-dom/client';
8
8
  import { guideHref } from '../core/feature';
9
+ import { hiddenFor } from './audience';
10
+ import { ClientViewNote, PrototypeClientView } from './ClientViewNote';
11
+ import { exportControls, loadControls } from './controls';
12
+ import { readHub } from './hub';
9
13
  import { Index } from './Index';
14
+ import { Notice } from './Notice';
10
15
  import { Prototype } from './Prototype';
11
- import { findEntry, guides } from './registry';
16
+ import { getEntry, guides } from './registry';
12
17
 
13
18
  const params = new URLSearchParams(location.search);
14
19
  // `design-hub export` opens a prototype with ?export: its artboards alone, no
@@ -29,10 +34,40 @@ if (import.meta.env.DEV && !exporting && params.get('a11y') !== '0') {
29
34
  }
30
35
 
31
36
  // /<slug>/ is a prototype; /guide/<feature>/ is that feature's walkthrough.
32
- // The slug `guide` belongs to the shell (new.ts refuses it).
37
+ // `guide`, `api` and `assets` belong to the hub (core/prototype.ts; new.ts refuses them).
33
38
  const [slug, sub] = location.pathname.split('/').filter(Boolean);
34
39
  const Guide = lazy(() => import('./Guide'));
35
40
 
41
+ /**
42
+ * The prototype a page opens, or none, and whether Studio's Client view is
43
+ * what hides it: one a client cannot open reads as missing there, as it does
44
+ * for them (the gate refuses it to a Client).
45
+ */
46
+ async function pageEntry(name: string) {
47
+ const entry = await getEntry(name);
48
+ if (!entry || !isClientView()) return { entry, hidden: false };
49
+ const answer = await readHub('client').catch(() => null);
50
+ const hidden = hiddenFor(answer, name) && answer?.me?.kind === 'studio';
51
+ return { entry: hidden ? undefined : entry, hidden };
52
+ }
53
+
54
+ /** Studio in Client view on a prototype a client cannot open: the missing page, with the way back. */
55
+ function HiddenInClientView({ name }: { name: string }) {
56
+ const leave = () => {
57
+ setClientView(false);
58
+ location.reload();
59
+ };
60
+ return (
61
+ <>
62
+ <Notice
63
+ title={`No prototype called “${name}”`}
64
+ body="Check the link, or open one from all prototypes."
65
+ />
66
+ <ClientViewNote onLeave={leave} />
67
+ </>
68
+ );
69
+ }
70
+
36
71
  let page: ReactNode;
37
72
  // Hub pages wear the neutral system look; a prototype keeps the project's tokens.
38
73
  if (!slug || slug === 'guide') document.documentElement.classList.add('sys');
@@ -43,9 +78,20 @@ if (slug === 'guide') {
43
78
  </Suspense>
44
79
  );
45
80
  } else if (slug) {
46
- const entry = findEntry(slug);
81
+ // The controls' audience is read beside the entry, so the first render already has it.
82
+ const [{ entry, hidden }] = await Promise.all([
83
+ pageEntry(slug),
84
+ exporting ? exportControls() : loadControls(slug),
85
+ ]);
47
86
  if (entry?.feature && guides.has(entry.feature)) setGuide(guideHref(entry.feature));
48
- page = <Prototype slug={slug} entry={entry} />;
87
+ page = hidden ? (
88
+ <HiddenInClientView name={slug} />
89
+ ) : (
90
+ <>
91
+ <Prototype slug={slug} entry={entry} />
92
+ {exporting ? null : <PrototypeClientView />}
93
+ </>
94
+ );
49
95
  if (entry && !exporting) {
50
96
  const { mountReview } = await import('./review/mount');
51
97
  mountReview({ prototype: slug, feature: entry.feature, states: (entry.states ?? []).map((s) => s.name) });
package/shell/registry.ts CHANGED
@@ -1,21 +1,42 @@
1
- import { guideDocs, modules, readmes } from 'virtual:design-hub/registry';
1
+ import { allSlugs, entryOf, guideDocs } from 'virtual:design-hub/registry';
2
2
  import type { ComponentType } from 'react';
3
3
  import { byIndexOrder, type Meta, readMeta } from '../core/catalog';
4
+ import { isPrototypeSlug } from '../core/prototype';
4
5
  import type { Doc } from './doc';
5
6
 
6
7
  export type Entry = Meta & { load?: () => Promise<{ default: ComponentType }> };
7
8
 
8
9
  // The registry module is written by the Vite plugin (vite/registry.ts) from
9
- // the project's prototypes/ and docs/sprints/ folders.
10
- export const entries: Entry[] = Object.entries(readmes)
11
- .map(([slug, md]): Entry => ({ ...readMeta(slug, md), load: modules[slug] }))
12
- .sort(byIndexOrder);
10
+ // the project's prototypes/ and docs/sprints/ folders. In a build every
11
+ // prototype is a file of its own, fetched by path, so what reaches this page
12
+ // is what the gate let through.
13
13
 
14
- export const findEntry = (slug: string) => entries.find((e) => e.slug === slug);
14
+ /** One prototype's entry; undefined when the name is no slug or there is none (the gate refused it). Any other failure throws. */
15
+ async function readEntry(slug: string): Promise<Entry | undefined> {
16
+ if (!isPrototypeSlug(slug)) return undefined;
17
+ const found = await entryOf(slug);
18
+ return found ? { ...readMeta(slug, found.readme), load: found.load } : undefined;
19
+ }
20
+
21
+ /** One prototype's entry for its page; undefined when it is not there or did not load. */
22
+ export const getEntry = (slug: string): Promise<Entry | undefined> => readEntry(slug).catch(() => undefined);
23
+
24
+ /** The entries for these slugs, in index order: one that is not there is skipped, one that fails otherwise is counted. */
25
+ export async function getEntries(slugs: readonly string[]): Promise<{ entries: Entry[]; failed: number }> {
26
+ const loaded = await Promise.allSettled(slugs.map(readEntry));
27
+ const entries = loaded
28
+ .map((r) => (r.status === 'fulfilled' ? r.value : undefined))
29
+ .filter((e): e is Entry => e !== undefined)
30
+ .sort(byIndexOrder);
31
+ return { entries, failed: loaded.filter((r) => r.status === 'rejected').length };
32
+ }
33
+
34
+ /** Every slug, for Studio's view. Built, `_p/all.js` is Studio's alone; a failure to load it throws. */
35
+ export const everySlug = (): Promise<string[]> => allSlugs();
15
36
 
16
37
  export const guides = new Map<string, () => Promise<Doc>>(Object.entries(guideDocs));
17
38
 
18
39
  // The prototype a feature's walkthrough opens: the sprint itself, else the first one listed.
19
- export const featureEntry = (feature: string) =>
40
+ export const featureEntry = (entries: readonly Entry[], feature: string) =>
20
41
  entries.find((e) => e.feature === feature && e.kind === 'sprint') ??
21
42
  entries.find((e) => e.feature === feature);
@@ -1,10 +1,18 @@
1
1
  declare module 'virtual:design-hub/registry' {
2
2
  import type { ComponentType } from 'react';
3
3
  import type { Doc } from './doc';
4
- /** Each prototype's README text, by slug. */
5
- export const readmes: Record<string, string>;
6
- /** Each prototype's module loader, by slug; absent when the folder has no index.tsx. */
7
- export const modules: Record<string, () => Promise<{ default: ComponentType }>>;
4
+ /** One prototype's entry: its README text, and its module loader, absent when the folder has no index.tsx. */
5
+ export type RegistryEntry = { readme: string; load?: () => Promise<{ default: ComponentType }> };
6
+ /**
7
+ * Every prototype's slug. Built, this loads `_p/all.js`, which the gate
8
+ * gives Studio only; for a Client it fails.
9
+ */
10
+ export function allSlugs(): Promise<string[]>;
11
+ /**
12
+ * One prototype's entry. Served, null for a slug with no prototype. Built,
13
+ * it loads `_p/<slug>/entry.js` and fails where the gate refuses it or there is none.
14
+ */
15
+ export function entryOf(slug: string): Promise<RegistryEntry | null>;
8
16
  /** Each feature's compiled walkthrough loader, by feature. */
9
17
  export const guideDocs: Record<string, () => Promise<Doc>>;
10
18
  }
@@ -1,4 +1,5 @@
1
- // The review UI's one store: who is signed in, this prototype's comments and,
1
+ // The review UI's one store, and the one way to the API (`call`), which the
2
+ // index uses too: who is signed in, this prototype's comments and,
2
3
  // for Studio, the people. Components read it with useSyncExternalStore and
3
4
  // call its actions; every call goes to /api/review (server/api.ts), and each
4
5
  // answer is merged in place, so a write never refetches the list. The list is
@@ -25,6 +26,8 @@ class ApiError extends Error {
25
26
  problems: string[];
26
27
  /** A 503 with Retry-After: the store did not answer, and review is on. */
27
28
  retry: boolean;
29
+ /** The answer was not JSON: no review API answered (`vite preview` serves its page instead). */
30
+ notJson = false;
28
31
  constructor(status: number, message: string, problems: string[] = [], retry = false) {
29
32
  super(message);
30
33
  this.status = status;
@@ -38,7 +41,7 @@ const API = '/api/review';
38
41
  /** For a click handler: the store shows every failure in the panel, so the handler has nothing left to do with one. */
39
42
  export const act = (pending: Promise<unknown>) => void pending.catch(() => {});
40
43
 
41
- async function call<T>(
44
+ export async function call<T>(
42
45
  op: string,
43
46
  body?: Record<string, unknown>,
44
47
  params: Record<string, string> = {},
@@ -56,8 +59,14 @@ async function call<T>(
56
59
  | null;
57
60
  if (response.status === 503 && response.headers.has('retry-after'))
58
61
  throw new ApiError(503, 'The review store did not answer. Reload in a minute.', [], true);
59
- if (!json)
60
- throw new ApiError(response.status, `The review API did not answer with JSON (${response.status}).`);
62
+ if (!json) {
63
+ const error = new ApiError(
64
+ response.status,
65
+ `The review API did not answer with JSON (${response.status}).`,
66
+ );
67
+ error.notJson = true;
68
+ throw error;
69
+ }
61
70
  if (!response.ok)
62
71
  throw new ApiError(response.status, json.error ?? `Request failed (${response.status}).`, json.problems);
63
72
  return json;
@@ -70,6 +79,9 @@ async function call<T>(
70
79
  const isOff = (error: unknown) =>
71
80
  error instanceof ApiError && !error.retry && (error.status === 503 || error.status === 404);
72
81
 
82
+ /** No review API at all: none set up (`isOff`), or an answer that is not the API's (a static preview's page). */
83
+ export const noApi = (error: unknown) => isOff(error) || (error instanceof ApiError && error.notJson);
84
+
73
85
  export function createReviewStore(prototype: string) {
74
86
  let state: State = { status: 'loading', me: null, comments: [], people: null, access: null, error: null };
75
87
  const listeners = new Set<() => void>();
@@ -21,8 +21,8 @@
21
21
  --rv-mark: oklch(0.55 0 0); /* on the page: mid grey holds on light and dark */
22
22
  --rv-pin: oklch(0.205 0 0);
23
23
  --rv-done: oklch(0.8 0.13 155); /* resolved: green, on its check alone */
24
- --rv-internal: oklch(0.83 0.15 85); /* internal: the amber of a support tool's internal note */
25
- --rv-on-internal: oklch(0.3 0.06 85); /* the label on amber, 8:1 */
24
+ --rv-internal: var(--sys-internal); /* internal: the amber of a support tool's internal note (system.css) */
25
+ --rv-on-internal: var(--sys-on-internal); /* the label on amber, 8:1 */
26
26
  --rv-internal-chip: oklch(0.35 0.06 85); /* the Internal tag on the card: a solid low tint, not amber at low opacity */
27
27
  --rv-internal-chip-fg: oklch(0.88 0.12 85); /* 8:1 on the chip */
28
28
  --rv-danger: oklch(0.779 0.131 23.4);
package/shell/shell.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /* The index: one group per feature (its primary prototype, its alternates on
2
- a rail, its internal explorations folded into cards), then prototypes with
2
+ a rail, its explorations folded into cards), then prototypes with
3
3
  no feature, then the archive. Rows draw no dividers; their hover surface
4
4
  bleeds 12px into the gutter. The list ends in a foot (the Ledger Foot Rule).
5
5
  The rules are in README.md, The index. */
@@ -13,6 +13,7 @@
13
13
  .index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-empty, .index-none, .index-foot { padding-inline: 12px; }
14
14
 
15
15
  .index-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 40px; }
16
+ .index-head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 32px; }
16
17
  .index-head h1 { font-size: 18px; line-height: 28px; font-weight: 600; text-wrap: balance; }
17
18
  .index-voice { font: 400 18px/28px var(--font-voice); letter-spacing: -0.01em; color: var(--text-secondary); max-width: 44ch; text-wrap: pretty; }
18
19
  .index code { font: 13px/20px var(--sys-font-mono); color: var(--text-secondary); }
@@ -114,6 +115,52 @@
114
115
 
115
116
  .index-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border-secondary); color: var(--text-primary); }
116
117
 
118
+ /* Studio, outside Client view: each prototype's audience in a fifth column,
119
+ beside its row and never inside the link. Internal wears the internal
120
+ comments' amber; Client-facing stays quiet. The switch is the plain kind:
121
+ a 28px track, its hit area grown to 40px. */
122
+ .index.has-audience { grid-template-columns: minmax(0, 1fr) auto auto auto auto; }
123
+ .index.has-audience .index-row { grid-column: 1 / 5; }
124
+ .index-list > li > .index-audience { grid-column: 5; align-self: center; padding-right: 12px; }
125
+ .index-cards > li { flex-direction: column; gap: 6px; }
126
+ .index-cards > li > .index-audience { padding: 0 12px 4px; }
127
+ .index-audience { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 12px; line-height: 18px; color: var(--text-quaternary); white-space: nowrap; }
128
+ .index-cards .index-audience { justify-content: space-between; }
129
+ .index-audience-word[data-audience="internal"] { padding: 0 6px; border-radius: var(--radius-xs); background: var(--sys-internal); color: var(--sys-on-internal); font-weight: 500; }
130
+ .index-switch { position: relative; flex: none; width: 28px; height: 16px; padding: 0; border: 0; border-radius: var(--radius-full); background: var(--border-primary); cursor: pointer; transition: background-color var(--dur-hover) var(--ease-hover); }
131
+ .index-switch::before { content: ""; position: absolute; inset: -12px -6px; }
132
+ .index-switch[aria-disabled="true"] { cursor: progress; opacity: 0.6; }
133
+ .index-switch:focus-visible { outline: 2px solid transparent; box-shadow: var(--focus-ring); }
134
+ .index-switch-thumb { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: oklch(1 0 0); box-shadow: 0 1px 2px oklch(0 0 0 / 0.2); transition: translate 160ms var(--ease-out), background-color var(--dur-hover) var(--ease-hover); }
135
+ .index-switch[aria-checked="true"] { background: var(--fg-primary); }
136
+ .index-switch[aria-checked="true"] .index-switch-thumb { translate: 12px 0; background: var(--bg-primary); }
137
+
138
+ /* Studio's Client view, entered from the head and left from this note: the
139
+ comment layer's note (shell/review, .rv-viewing), in its words and look. */
140
+ .index-client-view { flex: none; }
141
+ .index-viewing {
142
+ --button-tertiary-fg: var(--harness-fg-muted);
143
+ --button-tertiary-fg_hover: oklch(1 0 0);
144
+ --button-tertiary-bg_hover: oklch(1 0 0 / 0.1);
145
+ --focus-ring: 0 0 0 2px var(--harness-bg), 0 0 0 4px oklch(1 0 0 / 0.7);
146
+ position: fixed; z-index: 10; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
147
+ translate: -50% 0;
148
+ display: flex; align-items: center; gap: 8px;
149
+ width: max-content; max-width: min(480px, calc(100vw - 32px)); margin: 0;
150
+ padding: 4px 4px 4px 14px; border-radius: 12px;
151
+ background: var(--harness-bg); color: oklch(1 0 0);
152
+ box-shadow: 0 0 0 1px oklch(1 0 0 / 0.09), 0 12px 32px -8px oklch(0 0 0 / 0.5), 0 2px 6px oklch(0 0 0 / 0.25);
153
+ font: 13px/18px var(--sys-font);
154
+ transition: opacity 200ms var(--ease-out), translate 200ms var(--ease-out);
155
+ }
156
+ @starting-style { .index-viewing { opacity: 0; translate: -50% 4px; } }
157
+ /* On a prototype's page: at the top, over the page, clear of the picker and the comment bar. */
158
+ .index-viewing[data-at="top"] { z-index: 2147483646; top: max(16px, env(safe-area-inset-top)); bottom: auto; }
159
+ /* The comment bar says the same while it is open: one note at a time. */
160
+ body:has(.rv-viewing) .index-viewing[data-at="top"] { display: none; }
161
+ .index-viewing .icon { flex: none; color: var(--harness-fg-muted); }
162
+ .index-viewing .btn.index-viewing-act { height: 28px; padding: 0 8px; }
163
+
117
164
  @media (hover: hover) and (pointer: fine) {
118
165
  .index-row:hover { background: var(--bg-primary_hover); }
119
166
  .index-row:hover .index-summary { color: var(--text-secondary); }
@@ -140,9 +187,9 @@
140
187
  prototype, and the chosen row holds, so the eye keeps what it picked.
141
188
  The browser paints this page until the next one is ready, so the fade
142
189
  fills a wait that was blank. */
143
- .index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot { transition: opacity var(--dur-dialog-out) var(--ease-in); }
190
+ .index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot, .index-audience { transition: opacity var(--dur-dialog-out) var(--ease-in); }
144
191
  .index.is-leaving .index-alternates::before { opacity: 0; transition: opacity var(--dur-dialog-out) var(--ease-in); }
145
- .index.is-leaving :is(.index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot, .index-row:not([data-chosen]), .index-card:not([data-chosen])) { opacity: 0; }
192
+ .index.is-leaving :is(.index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot, .index-row:not([data-chosen]), .index-card:not([data-chosen]), .index-audience) { opacity: 0; }
146
193
  .index.is-leaving :is(.index-row, .index-card) { pointer-events: none; }
147
194
 
148
195
  :root[data-motion="reduce"] .index-rise { animation-name: index-fade; animation-duration: 120ms; animation-timing-function: linear; }
@@ -150,11 +197,15 @@
150
197
  :root[data-motion="reduce"] .index-fold { transition-property: opacity; }
151
198
  :root[data-motion="reduce"] .index-fold-toggle svg { transition: none; }
152
199
  :root[data-motion="reduce"] .index-card:hover .index-card-head svg { transform: none; }
200
+ :root[data-motion="reduce"] .index-switch-thumb { transition: none; }
201
+ :root[data-motion="reduce"] .index-viewing { transition-property: opacity; }
202
+ @starting-style { :root[data-motion="reduce"] .index-viewing { translate: -50% 0; } }
153
203
 
154
204
  @media (max-width: 560px) {
155
205
  .index, .index-group, .index-alternates, .index-list, .index-list > li, .index-row { display: flex; flex-direction: column; }
156
206
  .index-row { gap: 2px; }
157
207
  .index-meta { display: flex; gap: 12px; margin-top: 4px; }
208
+ .index-list > li > .index-audience { justify-content: flex-start; padding: 0 12px 8px; }
158
209
  }
159
210
 
160
211
  .shell-notice { width: min(720px, 100% - 32px); margin: 0 auto; padding: 96px 0; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
package/shell/system.css CHANGED
@@ -24,6 +24,11 @@
24
24
  --harness-fg-muted: oklch(1 0 0 / 0.55);
25
25
  --harness-border: oklch(1 0 0 / 0.1);
26
26
  --harness-shadow: 0 8px 24px oklch(0 0 0 / 0.4);
27
+
28
+ /* Internal: the amber an internal comment wears (shell/review), and the
29
+ label on it, 8:1. The index marks an Internal prototype with the same pair. */
30
+ --sys-internal: oklch(0.83 0.15 85);
31
+ --sys-on-internal: oklch(0.3 0.06 85);
27
32
  }
28
33
 
29
34
  .sys {
@@ -21,6 +21,16 @@ A piece of collateral here is a template, not a picture: one component that hold
21
21
  - **Safe areas.** A story keeps type, buttons and the logo out of its top and bottom 250px; the Board shades them (Controls → Board → Guides). Other formats keep a margin of at least 64px at 1080 wide.
22
22
  - **One template, many formats.** Draw the content once as a component and place it in one `<Artboard>` per format, adjusting per format with `[data-format="story"] .x { … }` in CSS. Never a second copy of the markup per format.
23
23
 
24
+ ## Still, and one look
25
+
26
+ Collateral is a file: a PNG or a PDF. Nothing in it moves and it has no dark mode, so a board has no View panel. Its viewing tools are the Board's own **Zoom** and **Guides**.
27
+
28
+ - **No motion.** No `transition`, `animation`, `@keyframes` or `motion/react` in a brand prototype, and no reduce-motion or speed control. Export turns motion off, so anything that moves on the board is not what ships. The guard warns on it.
29
+ - **No theme.** A board is held to the look it exports in: light, whatever theme the person looking has. Never style collateral with `.dark-mode`, `prefers-color-scheme`, `useDark` or `useAppearance`, and never mount `ViewTools`. A dark or inverse version is a `tone` dial on the piece, so it is a state a reviewer can see and an export can name.
30
+ - **A piece that moves is not collateral here.** An animated story, a logo sting or a transition between slides is a `Space` prototype (`pnpm new <slug> --feature <feature>`), where View has the motion tools and nothing is exported. Say so to the user instead of animating an artboard.
31
+ - **A slide deck is stills.** One artboard per slide, no builds or slide transitions.
32
+ - **Collateral beside a product or a site.** A mock of a screen inside a post is drawn still, as a picture of that screen. It does not make the board a product prototype.
33
+
24
34
  ## Dials are the template's slots
25
35
 
26
36
  Every slot an editor will change is a dial or a fixture, never a hard-coded string:
@@ -30,7 +40,7 @@ Every slot an editor will change is a dial or a fixture, never a hard-coded stri
30
40
  | Copy (kicker, headline, subhead, call to action) | `fixtures.json`, one item per post; `text` names headline and subhead so `longest` stresses them |
31
41
  | Which post | A `post` select over the set |
32
42
  | Layout (photo, type only, quote) | A `layout` select; each option a state in the README |
33
- | Tone (brand, light, inverse) | A `tone` select |
43
+ | Tone (brand, light, inverse, dark) | A `tone` select. This is the only way a piece has a dark version: the board ignores the theme. |
34
44
 
35
45
  The README's States table lists every combination a reviewer must see: each fixture set, each layout, each tone. `empty` and `missing` are real states here too: a post with no image is the one that runs on a busy day.
36
46
 
@@ -85,6 +85,25 @@ A signed-in device stays signed in until the person's access ends: 3 months, 6 m
85
85
  - One person: `pnpm people access <id> --access 3m|6m|open`, counted from today, or `--access` on `pnpm people add`.
86
86
  - When someone's access ends their links stop working at once, and every device signs out within five minutes. A changed access length reaches their signed-in devices within five minutes too. Change their access to let them back in, then send a new link.
87
87
 
88
+ ## Internal and client-facing prototypes
89
+
90
+ Every prototype is **Internal** until a Studio person marks it **Client-facing** with the switch beside it on the deployed site's **Prototypes** page; only then can a Client open it or see it listed. No command reads or sets it: to check one, open the site's index signed in as Studio and look at its switch, or turn on **Client view** there to see the index as a client gets it. A switch flipped under `pnpm dev` writes the local store only; the deployed site has its own. A new prototype is internal, and so is every prototype on a site upgraded to the release that brought this: after that upgrade, tell the user once that clients see nothing until they switch on the prototypes the client should see. Before sending a handover, ask the user to check that the prototype it names is switched on. Walkthroughs and feature names reach every signed-in person whatever the switches say, so a walkthrough that describes internal work must wait.
91
+
92
+ Dials and variants follow the same rule from the release after that one. Every dial is internal until marked: a client's **Controls** panel has only the View tools (theme, reduce motion, speed), and each internal dial stays at its default. A client gets the first variant and no picker. Studio marks a dial with the eye beside its row in Controls, and variants with the eye at the end of the picker; both are kept per site, so marks made under `pnpm dev` do not reach the deployed one. After that upgrade, tell the user once that clients lose every dial and the picker until Studio marks what they should have, and that the brand board's Zoom and Guides stay theirs. Copy parameters and Save version are Studio's only. To check what a client gets, a Studio person presses **Client view** at the bottom of a prototype's Controls panel, or on the Prototypes page.
93
+
94
+ The same upgrade changes what a build accepts and writes. Tell the user once, and when a build fails fix the file it names; never work around the check:
95
+
96
+ - A stylesheet that does not parse (an unclosed block) fails `pnpm build` and stops `pnpm dev` (the page answers 500), naming file and line, where both worked before: every stylesheet is now read for reaches into a prototype's folder.
97
+ - A prototype that reaches into another prototype's folder fails in `pnpm dev` and `pnpm build`, naming both files: an import (any query), a CSS `@import` or `url()`, or a `new URL('…', import.meta.url)`. Copy the file into the prototype that uses it, or move it into `kit/`.
98
+ - Importing a file that sits directly in `prototypes/`, or in a folder there with no `README.md`, fails in `pnpm dev` and `pnpm build`: nothing in `prototypes/` is shared. Move shared code into `kit/`.
99
+ - A `kit/` file that imports or references anything in a prototype's folder fails in `pnpm dev` and `pnpm build`: the kit never reads a prototype. Move what it needs into `kit/`.
100
+ - A web worker in a prototype fails `pnpm build`. Run the work on the main thread, or build the worker from `kit/` files only.
101
+ - Sass, Less and Stylus are refused: importing a `.scss`, `.sass`, `.less`, `.styl` or `.stylus` file from a prototype or from `kit/` fails in `pnpm dev` and `pnpm build`, naming the file. Rewrite it as plain CSS or `.pcss`.
102
+ - Stylesheet ties resolve in source import order, as in `pnpm dev`: when a prototype imports a kit sheet and then its own, a rule of equal weight in its own sheet wins, where a build could put the kit's last before.
103
+ - A prototype's small images and SVGs are separate requests from its own folder, no longer inlined as `data:` URIs.
104
+ - A build fails when a file outside a prototype's folder is one of that prototype's files whole (the same bytes, a `data:` URI of it, or its whole text as a string), naming both files.
105
+ - `postcss` is a direct dependency of the hub, and Vite is pinned to 8.3 (it was any 8.x from 8.3.5): the project's next install may move its Vite to any 8.3 patch, never 8.4. Nothing to do.
106
+
88
107
  ## A project that shared before one-time links
89
108
 
90
109
  A project that shared with a password (before one-time links) needs this once, before its next `pnpm share`. The pre-flight `gate` step stops the share until the store is there, so production is never replaced by a gate nobody can pass.
@@ -34,7 +34,7 @@ One feature is one slug used in two places: `docs/sprints/<slug>/` and the `feat
34
34
 
35
35
  ## The walkthrough
36
36
 
37
- `docs/sprints/<feature>/guide.md` is for the reviewer who has a sign-in link and not the repo. It is written from the States table: one section per workflow, then "Every state, and how to reach it" copied from the README, then what the prototype does not do, then what the review must settle. Screenshots go in `assets/guide/` beside it, named in order (`01-list.jpg`); a missing file fails the build. Write it before the share link goes out (`miles-deploy` checks it exists for a sprint).
37
+ `docs/sprints/<feature>/guide.md` is for the reviewer who has a sign-in link and not the repo. It is written from the States table: one section per workflow, then "Every state, and how to reach it" copied from the README, then what the prototype does not do, then what the review must settle. Screenshots go in `assets/guide/` beside it, named in order (`01-list.jpg`); a missing file fails the build. Write it before the share link goes out (`miles-deploy` checks it exists for a sprint). It goes to every signed-in person, clients included, even while the feature's prototypes are internal, and so does the feature's name: never name or describe internal work in it until the client may see it.
38
38
 
39
39
  ## When done means decided
40
40
 
@@ -24,7 +24,7 @@ A finding with a log id (`log 3f9a…`) was Jev's. When the user says it was wro
24
24
 
25
25
  ### Low gravity
26
26
 
27
- A prototype imports only `@kit/*` and files in its own folder. Never another prototype, never the hub's own code in `node_modules/@milesroxas/design-hub`. Why: the moment two prototypes share a file, deleting one breaks the other, and a prototype that cannot be deleted is production.
27
+ A prototype imports only `@kit/*` and files in its own folder. Never another prototype, never the hub's own code in `node_modules/@milesroxas/design-hub`. Why: the moment two prototypes share a file, deleting one breaks the other, and a prototype that cannot be deleted is production. The build refuses an import from another prototype's folder, naming both files: copy the file in, or promote it to `kit/`.
28
28
 
29
29
  ### Fork, don't flex
30
30
 
@@ -54,6 +54,19 @@ A user-visible state the README's `## States` table does not list does not exist
54
54
 
55
55
  Anything a control would do that the prototype does not build says so: `notInPrototype('Model history')` or `toast(message, { kind: 'scope' })`. Never a product toast with a green check for something that did not happen. Why: a reviewer who sees a success they did not get stops trusting the ones they did.
56
56
 
57
+ ## Who sees it
58
+
59
+ A new prototype is **Internal**: only Studio can open it, until a Studio person marks it **Client-facing** with the switch beside it on the hub's index (no command reads or sets it). Never tell the user a new prototype is ready for the client before that. Everything in `prototypes/<slug>/` (code, README, styles, fixtures, images) ships only to people who may see that prototype: the deployed site refuses its page and files to a Client while it is internal. Why: an internal prototype stays inside the studio only because nothing of it leaves its folder.
60
+
61
+ - Never reach into another prototype's folder: an import, a CSS `@import` or `url()`, a `new URL(…, import.meta.url)`. The build refuses each, naming both files: copy the file in, or promote it to `kit/`. A link to another prototype's page is fine; reading its files is not. And nothing in `kit/` may point into a prototype's folder: the build refuses that too.
62
+ - No web worker in a prototype (`new Worker`, `?worker`, `?worker&inline`): Vite builds it outside the prototype's folder, so the build refuses it. Run the work on the main thread, or build the worker from `kit/` files that use no prototype's.
63
+ - Write styles in plain CSS (or `.pcss`). Sass, Less and Stylus are refused in prototypes and in `kit/`, in `pnpm dev` and `pnpm build`, naming the file. Why: their own `@import` and `@use` resolve inside the preprocessor, where no check can see a reach into another prototype.
64
+ - The build also reads what it wrote, as a backstop for a whole file copied out of the folder: a file outside a prototype's folder that is one of its files whole (the same bytes, a `data:` URI of it, or its whole text as a string in a script) fails it, naming both files. It does not look for a part of a file, so shared lines, rules or snippets build.
65
+ - Limits: a `new URL` whose path is built at run time is not seen, until its content lands outside the folder. `pnpm dev` checks less than `pnpm build` (no read or output check). Nothing directly in `prototypes/`, or in a folder there without a README: shared code belongs in `kit/`, and the build refuses the rest. Run `pnpm build` before sharing.
66
+ - A prototype's small images and SVGs are built as files of their own, never inlined as `data:` URIs, so the site can refuse them to a Client while the prototype is internal.
67
+ - `kit/` is shared with every signed-in person, the client included, so nothing client-secret goes there: no unreleased product name, internal note or real data that only one prototype may show.
68
+ - Walkthrough text (`docs/sprints/<feature>/guide.md`) and feature names go to every signed-in person, clients included, whether or not the feature's prototypes are client-facing. A walkthrough must not name or describe internal work until the client may see it.
69
+
57
70
  ## DialKit patterns
58
71
 
59
72
  Walk this for every number and every switch:
@@ -70,10 +83,43 @@ Is it a value CSS consumes (duration, distance, scale, colour)?
70
83
  ```
71
84
 
72
85
  - Every dial carries a hint: one sentence, the unit named. A reviewer never guesses what a slider does.
73
- - Panels register in the order a reviewer reaches for them: Review (fixtures, role, scenarios) first, then the feature's own numbers, then Motion. View is mounted by the shell.
86
+ - Panels register in the order a reviewer reaches for them: Review (fixtures, role, scenarios) first, then the feature's own numbers, then Motion. View is mounted by what the prototype stands on (see View tools).
74
87
  - Slider defaults are the comp's values. The decision is the number the user settles on; copy it into the README's Decision with the rejected range.
88
+ - Every dial is internal: a client's panel has the View tools and nothing else until a dial is marked client-facing. `client(...)` from `@kit/dials` marks one where it is declared (`density: client({ type: 'select', ... })`, or around a folder for every dial in it); use it only when the user asks for clients to have that dial. Studio can also mark any dial with the eye beside its row, per deployed site, and that overrules the code. Fixtures, roles and scenarios stay internal.
89
+ - A client reads an internal dial at its default, so the default is the value to present, not a test value.
90
+ - The picker is Studio's until marked: a client gets the first variant and no picker, unless Studio marks variants with the picker's eye. Put the direction to present first.
75
91
  - Never a control inside the product chrome. A sidebar item or a sheet that switches fixtures is a testing aid wearing the product's clothes.
76
92
 
93
+ ## View tools
94
+
95
+ ### View tools fit what the prototype is
96
+
97
+ The **View** panel holds only what changes something on the prototype in front of the reviewer. What a prototype stands on decides it; you never mount `ViewTools` yourself (the guard blocks it).
98
+
99
+ | It stands on | View holds | Why |
100
+ | --- | --- | --- |
101
+ | `AppShell`, `SiteShell` | Theme, Reduce motion, Speed | A product or a site has themes and things that move. |
102
+ | `Space` | Theme, Reduce motion, Speed, unless narrowed | One thing alone may have neither. |
103
+ | `Board` (brand collateral) | Nothing: no View panel | A still file has no motion to slow, and one look. Zoom and Guides are its viewing tools. |
104
+
105
+ Narrow a `Space` when a tool would do nothing there:
106
+
107
+ ```
108
+ Does anything in it move (a transition, an animation, a hover or press response)?
109
+ ├── No → drop motion: <Space tools={['theme']}>
110
+ └── Yes → keep it
111
+ Does it have a light and a dark look (the project's tokens do, unless DESIGN.md says one theme)?
112
+ ├── No → drop theme: <Space tools={['motion']}>
113
+ └── Yes → keep it
114
+ Neither → <Space tools={false}>
115
+ ```
116
+
117
+ - Decide from what is on the page now, and change `tools` when that changes: adding the first transition to a Space that had `['theme']` puts motion back.
118
+ - A kit component that animates counts as motion: a toast, a menu, a dialog, a press response on a `Button`.
119
+ - A project with one theme narrows it once, in its own `kit/AppShell.tsx` and `kit/SiteShell.tsx` (`<ViewTools tools={['motion']} />`), not in each prototype.
120
+ - A person's own reduced-motion setting is still honoured everywhere, whatever View holds. Removing the dial removes a test control, not the behaviour: `:root[data-motion="reduce"]` rules stay in every prototype that moves.
121
+ - Never add a reduce-motion or speed control of your own to a prototype that has none in View. If you think it needs one, it stands on the wrong thing.
122
+
77
123
  ## Motion, accessibility, performance
78
124
 
79
125
  The references beside this skill (`references/motion.md`, `references/accessibility.md`, `references/performance.md`) are binding; the short rules: transform and opacity only, ease-out in and ease-in out, nothing over 300ms, nothing animates on a keyboard action, reduced motion keeps the fades, every control has a name, 40px targets, no state per frame.