@milesroxas/design-hub 0.2.0 → 0.3.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 (59) hide show
  1. package/core/catalog.test.ts +10 -1
  2. package/core/catalog.ts +11 -0
  3. package/core/cms.test.ts +103 -0
  4. package/core/cms.ts +178 -0
  5. package/core/export.test.ts +127 -0
  6. package/core/export.ts +120 -0
  7. package/core/formats.ts +60 -0
  8. package/core/project.test.ts +71 -0
  9. package/core/project.ts +147 -0
  10. package/dist/core/catalog.d.ts +5 -0
  11. package/dist/core/catalog.js +10 -0
  12. package/dist/core/cms.d.ts +40 -0
  13. package/dist/core/cms.js +141 -0
  14. package/dist/core/export.d.ts +52 -0
  15. package/dist/core/export.js +84 -0
  16. package/dist/core/formats.d.ts +90 -0
  17. package/dist/core/formats.js +39 -0
  18. package/dist/core/project.d.ts +56 -0
  19. package/dist/core/project.js +121 -0
  20. package/dist/scripts/cli.js +4 -0
  21. package/dist/scripts/commands.js +4 -0
  22. package/dist/scripts/export.d.ts +42 -0
  23. package/dist/scripts/export.js +192 -0
  24. package/dist/scripts/fixtures-pull.d.ts +31 -19
  25. package/dist/scripts/fixtures-pull.js +102 -62
  26. package/dist/scripts/lib/cdp.d.ts +11 -0
  27. package/dist/scripts/lib/cdp.js +110 -0
  28. package/dist/scripts/new.d.ts +13 -1
  29. package/dist/scripts/new.js +43 -4
  30. package/dist/scripts/tracks.d.ts +40 -0
  31. package/dist/scripts/tracks.js +93 -0
  32. package/dist/server/paths.d.ts +2 -0
  33. package/dist/server/paths.js +2 -0
  34. package/dist/server/project.d.ts +7 -0
  35. package/dist/server/project.js +29 -0
  36. package/kit/Artboard.tsx +160 -0
  37. package/kit/artboard.css +47 -0
  38. package/kit/dials.tsx +2 -1
  39. package/package.json +1 -1
  40. package/shell/Index.tsx +49 -4
  41. package/shell/main.tsx +6 -2
  42. package/shell/shell.css +7 -3
  43. package/skills/miles-brand/SKILL.md +52 -0
  44. package/skills/miles-design-hub/SKILL.md +60 -25
  45. package/skills/miles-get-hostile/SKILL.md +7 -5
  46. package/skills/miles-new-feature/SKILL.md +8 -7
  47. package/skills/miles-port/SKILL.md +14 -2
  48. package/skills/miles-port/references/emdash.md +43 -0
  49. package/skills/miles-port/references/payload.md +31 -0
  50. package/skills/miles-port/references/wordpress.md +31 -0
  51. package/skills/miles-prototype/SKILL.md +2 -2
  52. package/templates/app/README.md +1 -0
  53. package/templates/brand/README.md +48 -0
  54. package/templates/brand/index.tsx +16 -0
  55. package/templates/brand/styles.css +5 -0
  56. package/templates/site/README.md +42 -0
  57. package/templates/site/index.tsx +22 -0
  58. package/templates/site/styles.css +6 -0
  59. package/templates/space/README.md +1 -0
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ /// <reference types="node" />
3
+ // `design-hub tracks`: what kind of engagement the project is. `set` writes
4
+ // .design-hub/project.json (the tracks, and for a website its platform and
5
+ // front end); with --remove-samples it also drops the sample prototype and
6
+ // walkthrough of every track the project does not have, which is what setup
7
+ // wants and nothing later should do unasked.
8
+ import { existsSync, rmSync } from 'node:fs';
9
+ import { join, relative } from 'node:path';
10
+ import { FRONTENDS, makeProject, needsPlatform, PLATFORMS, samplesOutside, TRACKS, } from '../core/project.js';
11
+ import { DOCS, PROJECT_JSON, PROTOTYPES, ROOT } from '../server/paths.js';
12
+ import { readProject, writeProject } from '../server/project.js';
13
+ import { CliError } from './lib/cli.js';
14
+ export const spec = {
15
+ name: 'tracks',
16
+ summary: "Show or set the project's tracks (product, website, brand) and its website platform.",
17
+ positionals: [{ name: 'action', description: 'show (default): what project.json says. set: write it.' }],
18
+ flags: {
19
+ track: {
20
+ type: 'list',
21
+ description: `For set: a track, repeated for several. One of: ${TRACKS.join(', ')}.`,
22
+ },
23
+ platform: {
24
+ type: 'string',
25
+ choices: PLATFORMS,
26
+ description: 'For set, with the website track: where the site is built.',
27
+ },
28
+ frontend: {
29
+ type: 'string',
30
+ choices: FRONTENDS,
31
+ description: 'For set: the front end, for Payload or WordPress. Webflow takes none; EmDash is always Astro.',
32
+ },
33
+ 'remove-samples': {
34
+ type: 'boolean',
35
+ description: 'For set: delete the sample prototype and walkthrough of every track not set. Setup only.',
36
+ },
37
+ },
38
+ output: '{ ok, tracks, website?, file, removed?, warnings }',
39
+ };
40
+ /** Deletes the samples of the tracks a project does not keep; returns what went, relative to the project. */
41
+ export function removeSamples(keep, prototypes = PROTOTYPES, docs = DOCS, root = ROOT) {
42
+ const removed = [];
43
+ for (const { slug, feature } of samplesOutside(keep)) {
44
+ for (const dir of [join(prototypes, slug), join(docs, 'sprints', feature)]) {
45
+ if (!existsSync(dir))
46
+ continue;
47
+ rmSync(dir, { recursive: true, force: true });
48
+ removed.push(`${relative(root, dir)}/`);
49
+ }
50
+ }
51
+ return removed;
52
+ }
53
+ const warningsFor = (project) => needsPlatform(project)
54
+ ? ['The website track has no platform yet. Set it with --platform before porting: miles-port needs it.']
55
+ : [];
56
+ function show() {
57
+ const { project, problems } = readProject();
58
+ if (problems.length)
59
+ throw new CliError('project.json is invalid.', {
60
+ problems,
61
+ fix: 'Rewrite it with design-hub tracks set.',
62
+ });
63
+ if (!project)
64
+ return {
65
+ tracks: [],
66
+ file: relative(ROOT, PROJECT_JSON),
67
+ warnings: [
68
+ 'No tracks recorded: every track is allowed. Record them with design-hub tracks set --track <track>.',
69
+ ],
70
+ };
71
+ return { ...project, file: relative(ROOT, PROJECT_JSON), warnings: warningsFor(project) };
72
+ }
73
+ function set({ flags }) {
74
+ const made = makeProject(flags.track, { platform: flags.platform, frontend: flags.frontend });
75
+ if ('problems' in made)
76
+ throw new CliError(made.problems.join(' '), { fix: 'design-hub tracks --help lists the choices.' });
77
+ writeProject(made.project);
78
+ const removed = flags['remove-samples'] ? removeSamples(made.project.tracks) : undefined;
79
+ return {
80
+ ...made.project,
81
+ file: relative(ROOT, PROJECT_JSON),
82
+ ...(removed ? { removed } : {}),
83
+ warnings: warningsFor(made.project),
84
+ };
85
+ }
86
+ export function main(args) {
87
+ const [action = 'show'] = args.positionals;
88
+ if (action === 'show')
89
+ return show();
90
+ if (action === 'set')
91
+ return set(args);
92
+ throw new CliError(`Unknown action ${action}.`, { fix: 'Use show or set.' });
93
+ }
@@ -12,6 +12,8 @@ export declare const SKILLS: string;
12
12
  /** Local state, gitignored but for checks.json: the Jev log and its labels, the dev review store. */
13
13
  export declare const STATE_DIR: string;
14
14
  export declare const CHECKS_FILE: string;
15
+ /** The project's tracks and website platform (core/project.ts); committed, like checks.json. */
16
+ export declare const PROJECT_JSON: string;
15
17
  /** The nearest ancestor of `from` whose package.json names this package, so source and dist agree. */
16
18
  export declare function packageRoot(from: string): string;
17
19
  /** This package on disk, wherever it is installed: the shell, the kit, the templates, the skills. */
@@ -53,6 +53,8 @@ export const SKILLS = join(ROOT, '.claude', 'skills');
53
53
  /** Local state, gitignored but for checks.json: the Jev log and its labels, the dev review store. */
54
54
  export const STATE_DIR = join(ROOT, '.design-hub');
55
55
  export const CHECKS_FILE = join(STATE_DIR, 'checks.json');
56
+ /** The project's tracks and website platform (core/project.ts); committed, like checks.json. */
57
+ export const PROJECT_JSON = join(STATE_DIR, 'project.json');
56
58
  /** The nearest ancestor of `from` whose package.json names this package, so source and dist agree. */
57
59
  export function packageRoot(from) {
58
60
  let dir = dirname(from);
@@ -0,0 +1,7 @@
1
+ import { type Project } from '../core/project.ts';
2
+ export type LoadedProject = {
3
+ project: Project | null;
4
+ problems: string[];
5
+ };
6
+ export declare function readProject(file?: string): LoadedProject;
7
+ export declare function writeProject(project: Project, file?: string): void;
@@ -0,0 +1,29 @@
1
+ /// <reference types="node" />
2
+ // .design-hub/project.json on disk: the project's tracks and website
3
+ // platform (core/project.ts has the rules). A project made before tracks
4
+ // existed has no file; every reader treats that as "any track", so nothing
5
+ // an older project does stops working.
6
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
7
+ import { dirname } from 'node:path';
8
+ import { parseProject } from '../core/project.js';
9
+ import { PROJECT_JSON } from './paths.js';
10
+ export function readProject(file = PROJECT_JSON) {
11
+ if (!existsSync(file))
12
+ return { project: null, problems: [] };
13
+ try {
14
+ const parsed = parseProject(JSON.parse(readFileSync(file, 'utf8')));
15
+ return 'project' in parsed
16
+ ? { project: parsed.project, problems: [] }
17
+ : { project: null, problems: parsed.problems };
18
+ }
19
+ catch (error) {
20
+ return {
21
+ project: null,
22
+ problems: [`${file}: ${error instanceof Error ? error.message : String(error)}`],
23
+ };
24
+ }
25
+ }
26
+ export function writeProject(project, file = PROJECT_JSON) {
27
+ mkdirSync(dirname(file), { recursive: true });
28
+ writeFileSync(file, `${JSON.stringify(project, null, 2)}\n`);
29
+ }
@@ -0,0 +1,160 @@
1
+ import {
2
+ createContext,
3
+ type ReactNode,
4
+ useContext,
5
+ useEffect,
6
+ useLayoutEffect,
7
+ useRef,
8
+ useState,
9
+ } from 'react';
10
+ import { FORMATS, type Format, type FormatName, sizeLabel, zoomFor } from '../core/formats.ts';
11
+ import { restoreDials, useDials } from './dials';
12
+ import { ViewTools } from './ViewTools';
13
+ import './artboard.css';
14
+
15
+ export { FORMAT_NAMES, FORMATS, type FormatName } from '../core/formats.ts';
16
+
17
+ const params = new URLSearchParams(location.search);
18
+ /** True when `design-hub export` opened the page: artboards only, at their real size, no tools. */
19
+ export const exporting = params.has('export');
20
+
21
+ type View = { zoom: string; guides: boolean; room: { width: number; height: number } };
22
+ const BoardView = createContext<View>({ zoom: '100%', guides: false, room: { width: 1e5, height: 1e5 } });
23
+
24
+ const ZOOMS = ['fit', '25%', '50%', '100%'];
25
+ const frames = (n: number) =>
26
+ new Promise<void>((resolve) => {
27
+ const step = (left: number) => (left ? requestAnimationFrame(() => step(left - 1)) : resolve());
28
+ step(n);
29
+ });
30
+
31
+ /** Applies the export's dial state, waits for fonts and images, then tells the exporter the page is ready. */
32
+ async function settleForExport() {
33
+ const dials = params.get('dials');
34
+ if (dials) restoreDials(JSON.parse(dials));
35
+ await document.fonts.ready;
36
+ await Promise.all([...document.images].map((img) => img.decode().catch(() => undefined)));
37
+ await frames(2);
38
+ document.documentElement.dataset.exportReady = '1';
39
+ }
40
+
41
+ /** The width the board has to draw in, and a height that keeps one artboard on screen. */
42
+ function useRoom() {
43
+ const ref = useRef<HTMLDivElement>(null);
44
+ const [room, setRoom] = useState({ width: 1e5, height: 1e5 });
45
+ useLayoutEffect(() => {
46
+ const el = ref.current;
47
+ if (!el || exporting) return;
48
+ const measure = () => setRoom({ width: el.clientWidth, height: Math.min(innerHeight * 0.6, 640) });
49
+ measure();
50
+ const observer = new ResizeObserver(measure);
51
+ observer.observe(el);
52
+ return () => observer.disconnect();
53
+ }, []);
54
+ return { ref, room };
55
+ }
56
+
57
+ type BoardProps = { title: string; lede?: ReactNode; children: ReactNode };
58
+
59
+ /**
60
+ * The canvas brand collateral sits on: every artboard side by side, scaled to
61
+ * fit, with its format and size under it. Under `design-hub export` it is
62
+ * the artboards alone, at their real size.
63
+ */
64
+ export function Board({ title, lede, children }: BoardProps) {
65
+ const view = useDials(
66
+ 'Board',
67
+ {
68
+ zoom: { type: 'select', options: ZOOMS, default: 'fit' },
69
+ guides: true,
70
+ },
71
+ {
72
+ hints: {
73
+ zoom: 'How large the artboards draw on screen. Export always writes them at their real size.',
74
+ guides: "Shade the bands a platform's own interface covers, where type and logos never go.",
75
+ },
76
+ },
77
+ );
78
+ const { ref, room } = useRoom();
79
+
80
+ useEffect(() => {
81
+ if (exporting) void settleForExport();
82
+ }, []);
83
+
84
+ if (exporting)
85
+ return (
86
+ <BoardView.Provider value={{ zoom: '100%', guides: false, room }}>
87
+ <div className="board-export">{children}</div>
88
+ </BoardView.Provider>
89
+ );
90
+
91
+ return (
92
+ <BoardView.Provider value={{ zoom: view.zoom as string, guides: view.guides as boolean, room }}>
93
+ <main className="board">
94
+ <header className="board-head">
95
+ <h1 className="board-title">{title}</h1>
96
+ {lede ? <p className="board-lede">{lede}</p> : null}
97
+ </header>
98
+ <div className="board-grid" ref={ref}>
99
+ {children}
100
+ </div>
101
+ <ViewTools />
102
+ </main>
103
+ </BoardView.Provider>
104
+ );
105
+ }
106
+
107
+ type ArtboardProps = {
108
+ format: FormatName;
109
+ /** Names the file on export (`<slug>-<name>.png`) and labels it on screen. */
110
+ name?: string;
111
+ children: ReactNode;
112
+ };
113
+
114
+ /**
115
+ * One piece of collateral at its real pixel size: type, spacing and images
116
+ * are drawn at the values that ship. On screen it scales with the Board's
117
+ * zoom; the content never knows.
118
+ */
119
+ /** The bands a platform's own interface covers, shaded on screen, never exported. */
120
+ function SafeBands({ format }: { format: FormatName }) {
121
+ const f: Format = FORMATS[format];
122
+ if (!f.safe) return null;
123
+ return (
124
+ <>
125
+ <div className="artboard-safe" style={{ top: 0, height: f.safe.top }} aria-hidden="true" />
126
+ <div className="artboard-safe" style={{ bottom: 0, height: f.safe.bottom }} aria-hidden="true" />
127
+ </>
128
+ );
129
+ }
130
+
131
+ export function Artboard({ format, name, children }: ArtboardProps) {
132
+ const { zoom, guides, room } = useContext(BoardView);
133
+ const f = FORMATS[format];
134
+ const scale = exporting ? 1 : zoomFor(zoom, format, room);
135
+ const frame = (
136
+ <div
137
+ className="artboard"
138
+ data-artboard=""
139
+ data-format={format}
140
+ data-name={name ?? ''}
141
+ data-output={f.output}
142
+ style={{ width: f.width, height: f.height, zoom: scale }}
143
+ >
144
+ {children}
145
+ {guides ? <SafeBands format={format} /> : null}
146
+ </div>
147
+ );
148
+ if (exporting) return frame;
149
+ return (
150
+ <figure className="artboard-slot">
151
+ {frame}
152
+ <figcaption className="artboard-label">
153
+ <span>{name ?? f.label}</span>
154
+ <span className="tabular">
155
+ {f.label} · {sizeLabel(format)}
156
+ </span>
157
+ </figcaption>
158
+ </figure>
159
+ );
160
+ }
@@ -0,0 +1,47 @@
1
+ /* The board: artboards side by side on a quiet canvas, each scaled with CSS
2
+ zoom so its content keeps its real pixel values. Under export, only the
3
+ artboards, stacked at 1:1, with motion off and one page per artboard. */
4
+ .board { min-height: 100vh; display: flex; flex-direction: column; gap: 32px; padding: 64px 32px 128px; background: var(--bg-secondary); }
5
+ .board-head { display: flex; flex-direction: column; gap: 4px; max-width: 65ch; }
6
+ .board-title { font-size: 18px; line-height: 28px; font-weight: 600; color: var(--text-primary); text-wrap: balance; }
7
+ .board-lede { color: var(--text-tertiary); text-wrap: pretty; }
8
+ .board-grid { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 40px; min-width: 0; }
9
+ .artboard-slot { display: flex; flex-direction: column; gap: 10px; margin: 0; min-width: 0; }
10
+ .artboard { position: relative; flex: none; overflow: hidden; background: var(--bg-primary); box-shadow: 0 0 0 1px rgb(16 24 40 / 0.08), 0 12px 32px -12px rgb(16 24 40 / 0.18); }
11
+ .artboard-label { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; line-height: 18px; color: var(--text-tertiary); }
12
+ .artboard-label > span:first-child { color: var(--text-secondary); font-weight: 500; }
13
+ .artboard-safe { position: absolute; inset-inline: 0; pointer-events: none; background: repeating-linear-gradient(-45deg, rgb(240 68 56 / 0.14) 0 12px, rgb(240 68 56 / 0.06) 12px 24px); outline: 1px dashed rgb(240 68 56 / 0.5); outline-offset: -1px; }
14
+
15
+ @media (max-width: 720px) {
16
+ .board { padding: 32px 16px 128px; }
17
+ }
18
+
19
+ /* Export: the page is the artboards and nothing else. */
20
+ html[data-export] body { margin: 0; background: transparent; }
21
+ .board-export { display: flex; flex-direction: column; align-items: flex-start; width: max-content; }
22
+ .board-export .artboard { box-shadow: none; }
23
+ html[data-export] *, html[data-export] *::before, html[data-export] *::after { animation: none !important; transition: none !important; }
24
+
25
+ /* PDF: one page per artboard at the format's own size. The exporter prints
26
+ one format at a time, hiding the rest, because Chrome lays out one PDF at
27
+ a single width. */
28
+ @media print {
29
+ .board-export .artboard { break-after: page; }
30
+ .artboard[data-format="post-square"] { page: post-square; }
31
+ .artboard[data-format="post-portrait"] { page: post-portrait; }
32
+ .artboard[data-format="story"] { page: story; }
33
+ .artboard[data-format="link-preview"] { page: link-preview; }
34
+ .artboard[data-format="banner"] { page: banner; }
35
+ .artboard[data-format="slide"] { page: slide; }
36
+ .artboard[data-format="a4"] { page: a4; }
37
+ .artboard[data-format="letter"] { page: letter; }
38
+ }
39
+ @page { margin: 0; }
40
+ @page post-square { size: 1080px 1080px; margin: 0; }
41
+ @page post-portrait { size: 1080px 1350px; margin: 0; }
42
+ @page story { size: 1080px 1920px; margin: 0; }
43
+ @page link-preview { size: 1200px 630px; margin: 0; }
44
+ @page banner { size: 1584px 396px; margin: 0; }
45
+ @page slide { size: 1920px 1080px; margin: 0; }
46
+ @page a4 { size: 210mm 297mm; margin: 0; }
47
+ @page letter { size: 8.5in 11in; margin: 0; }
package/kit/dials.tsx CHANGED
@@ -35,7 +35,8 @@ export const setGuide = (href: string) => {
35
35
 
36
36
  // One DialRoot per page, in its own React root, however many panels register.
37
37
  export function ensureDialRoot() {
38
- if (mounted) return;
38
+ // `design-hub export` captures the prototype alone; the panel never mounts.
39
+ if (mounted || document.documentElement.dataset.export !== undefined) return;
39
40
  mounted = true;
40
41
  const host = document.createElement('div');
41
42
  host.dataset.harness = 'dials';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milesroxas/design-hub",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The Design Hub product: the hub that lists and serves prototypes, the review panel and its API, the password 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": {
package/shell/Index.tsx CHANGED
@@ -10,7 +10,9 @@ import {
10
10
  useRef,
11
11
  useState,
12
12
  } from 'react';
13
+ import { placeLabel } from '../core/catalog';
13
14
  import { featureTitle, guideHref } from '../core/feature';
15
+ import { TRACK_LABEL, TRACKS, type Track } from '../core/project';
14
16
  import { type Entry, entries, guides } from './registry';
15
17
  import './shell.css';
16
18
 
@@ -60,17 +62,34 @@ const groupsOf = (list: Entry[]): Group[] => {
60
62
  ].filter((g) => g.items.length || g.alternates.length || g.explorations.length);
61
63
  };
62
64
 
65
+ /** The track the index shows, remembered per browser. Only the tracks the prototypes use are offered; a stale choice shows all. */
66
+ function useTrackFilter() {
67
+ const [track, setTrack] = useStoredState<Track | 'all'>('index-track', 'all');
68
+ const tracks = TRACKS.filter((t) => entries.some((e) => e.track === t));
69
+ const inTrack = (e: Entry) => track === 'all' || !tracks.includes(track) || e.track === track;
70
+ return { filter: { tracks, value: track, onChange: setTrack }, inTrack };
71
+ }
72
+
73
+ const byQuery = (q: string) => (e: Entry) =>
74
+ !q || `${e.title} ${e.summary} ${e.slug}`.toLowerCase().includes(q);
75
+
76
+ /** The filter text and the track, and the entries they leave: the chosen track's, matching the text. */
77
+ function useIndexFilter() {
78
+ const [query, setQuery] = useState('');
79
+ const q = useDeferredValue(query.trim().toLowerCase());
80
+ const { filter, inTrack } = useTrackFilter();
81
+ return { query, setQuery, q, shown: entries.filter(inTrack).filter(byQuery(q)), trackFilter: filter };
82
+ }
83
+
63
84
  const RISE_CAP = 8;
64
85
  const rise = (i: number) => ({ '--i': Math.min(i, RISE_CAP) }) as CSSProperties;
65
86
 
66
87
  export function Index() {
67
- const [query, setQuery] = useState('');
88
+ const { query, setQuery, q, shown, trackFilter } = useIndexFilter();
68
89
  const [leaving, setLeaving] = useState<string | null>(null);
69
90
  const [opened, setOpened] = useStoredState<Record<string, boolean>>('index-explorations-open', {});
70
91
  const [instant, setInstant] = useState(false);
71
- const q = useDeferredValue(query.trim().toLowerCase());
72
92
  const main = useRef<HTMLElement>(null);
73
- const shown = entries.filter((e) => !q || `${e.title} ${e.summary} ${e.slug}`.toLowerCase().includes(q));
74
93
  const groups = groupsOf(shown);
75
94
  const archivedTotal = entries.filter((e) => e.status === 'archived').length;
76
95
 
@@ -136,6 +155,7 @@ export function Index() {
136
155
  High-fidelity sketches in code, made as we sprint on features and improve the product.
137
156
  </p>
138
157
  </header>
158
+ <TrackFilter {...trackFilter} />
139
159
  {entries.length > 6 ? (
140
160
  <label className="index-filter">
141
161
  <span className="sr-only">Filter prototypes</span>
@@ -286,10 +306,35 @@ function Explorations({
286
306
  );
287
307
  }
288
308
 
309
+ /** One button per track the project's prototypes use, plus All; shown only when there are two or more. */
310
+ function TrackFilter({
311
+ tracks,
312
+ value,
313
+ onChange,
314
+ }: {
315
+ tracks: Track[];
316
+ value: Track | 'all';
317
+ onChange: (t: Track | 'all') => void;
318
+ }) {
319
+ if (tracks.length < 2) return null;
320
+ const options: (Track | 'all')[] = ['all', ...tracks];
321
+ return (
322
+ <fieldset className="index-tracks">
323
+ <legend className="sr-only">Track</legend>
324
+ {options.map((t) => (
325
+ <button key={t} type="button" aria-pressed={value === t} onClick={() => onChange(t)}>
326
+ {t === 'all' ? 'All' : TRACK_LABEL[t]}
327
+ </button>
328
+ ))}
329
+ </fieldset>
330
+ );
331
+ }
332
+
289
333
  function EntryMeta({ entry, className }: { entry: Entry; className: string }) {
290
334
  return (
291
335
  <span className={className}>
292
- <span>{entry.context === 'app' ? 'App shell' : 'Space'}</span>
336
+ {entry.track ? <span>{TRACK_LABEL[entry.track]}</span> : null}
337
+ <span>{placeLabel(entry)}</span>
293
338
  <span className="index-status" data-status={entry.status}>
294
339
  {entry.status}
295
340
  </span>
package/shell/main.tsx CHANGED
@@ -11,6 +11,10 @@ import { Prototype } from './Prototype';
11
11
  import { findEntry, guides } from './registry';
12
12
 
13
13
  const params = new URLSearchParams(location.search);
14
+ // `design-hub export` opens a prototype with ?export: its artboards alone, no
15
+ // review panel, no dials, no accessibility overlay (kit/Artboard.tsx).
16
+ const exporting = params.has('export');
17
+ if (exporting) document.documentElement.dataset.export = '';
14
18
 
15
19
  // Lapse patches the clocks, so it lands before any prototype (and Motion) loads.
16
20
  // The module is empty unless the project installed @aiforui/lapse (vite/lapse.ts).
@@ -20,7 +24,7 @@ if (import.meta.env.DEV && params.has('lapse')) {
20
24
  else console.warn('[design-hub] ?lapse needs Lapse in the project: pnpm add -D @aiforui/lapse');
21
25
  }
22
26
 
23
- if (import.meta.env.DEV && params.get('a11y') !== '0') {
27
+ if (import.meta.env.DEV && !exporting && params.get('a11y') !== '0') {
24
28
  import('./a11y').then((m) => m.watchA11y());
25
29
  }
26
30
 
@@ -42,7 +46,7 @@ if (slug === 'guide') {
42
46
  const entry = findEntry(slug);
43
47
  if (entry?.feature && guides.has(entry.feature)) setGuide(guideHref(entry.feature));
44
48
  page = <Prototype slug={slug} entry={entry} />;
45
- if (entry) {
49
+ if (entry && !exporting) {
46
50
  const { mountReview } = await import('./review/mount');
47
51
  mountReview({ prototype: slug, feature: entry.feature, states: (entry.states ?? []).map((s) => s.name) });
48
52
  }
package/shell/shell.css CHANGED
@@ -10,7 +10,7 @@
10
10
  is not a row carries that 12px itself. */
11
11
  .index { width: min(744px, 100% - 8px); margin: 0 auto; padding: 96px 0 128px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; column-gap: 20px; align-content: start; }
12
12
  .index > * { grid-column: 1 / -1; }
13
- .index-head, .index-filter, .index-section, .index-subsection, .index-empty, .index-none, .index-foot { padding-inline: 12px; }
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
16
  .index-head h1 { font-size: 18px; line-height: 28px; font-weight: 600; text-wrap: balance; }
@@ -18,6 +18,10 @@
18
18
  .index code { font: 13px/20px var(--sys-font-mono); color: var(--text-secondary); }
19
19
 
20
20
  .index-filter { margin-bottom: 24px; }
21
+ .index-tracks { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 16px; border: 0; min-width: 0; }
22
+ .index-tracks button { height: 32px; padding: 0 12px; border: 1px solid var(--border-secondary); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-secondary); font: inherit; font-weight: 500; cursor: pointer; transition: background-color var(--dur-hover) var(--ease-hover), color var(--dur-hover) var(--ease-hover); }
23
+ .index-tracks button[aria-pressed="true"] { background: var(--bg-active); border-color: var(--border-primary); color: var(--text-primary); }
24
+ @media (hover: hover) { .index-tracks button:hover { color: var(--text-primary); } }
21
25
  .index-filter input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-primary); border-radius: var(--radius-md); background: var(--bg-primary); box-shadow: var(--shadow-xs); font-size: 16px; transition: border-color var(--dur-hover) var(--ease-hover); }
22
26
  .index-filter input::placeholder { color: var(--text-placeholder); }
23
27
  .index-filter input:focus-visible { border-color: var(--border-brand); }
@@ -136,9 +140,9 @@
136
140
  prototype, and the chosen row holds, so the eye keeps what it picked.
137
141
  The browser paints this page until the next one is ready, so the fade
138
142
  fills a wait that was blank. */
139
- .index-head, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot { transition: opacity var(--dur-dialog-out) var(--ease-in); }
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); }
140
144
  .index.is-leaving .index-alternates::before { opacity: 0; transition: opacity var(--dur-dialog-out) var(--ease-in); }
141
- .index.is-leaving :is(.index-head, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot, .index-row:not([data-chosen]), .index-card:not([data-chosen])) { opacity: 0; }
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; }
142
146
  .index.is-leaving :is(.index-row, .index-card) { pointer-events: none; }
143
147
 
144
148
  :root[data-motion="reduce"] .index-rise { animation-name: index-fade; animation-duration: 120ms; animation-timing-function: linear; }
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: miles-brand
3
+ description: "Brand collateral as prototypes: social post templates, stories, link previews, banners, slides and print, drawn on artboards at real pixel size from the project's tokens and DESIGN.md, Brand, with copy and layout on dials, and written to PNG and PDF with pnpm export. Load when the work is the brand track, or when the user asks for a post, a story, a deck, a slide, a one-pager, a flyer, a banner, an export or a template. Triggers on: brand, collateral, social post, Instagram, LinkedIn, story, carousel, link preview, banner, slide, deck, presentation, one-pager, flyer, print, A4, letter, artboard, export, PNG, PDF, template."
4
+ ---
5
+
6
+ # Brand collateral
7
+
8
+ A piece of collateral here is a template, not a picture: one component that holds every post the team will write, drawn at the size it ships, with its copy and layout on dials. Files come out of it with `pnpm export`, so the next post is a dial change, not a redraw.
9
+
10
+ ## Before the first artboard
11
+
12
+ 1. **Read `DESIGN.md`, Brand.** Logo, imagery, collateral type, formats and voice. Where it is empty, ask for the one answer you need, write it there, then build. Why: collateral repeats; a guess on the first post becomes the brand on the tenth.
13
+ 2. **Read `prototypes/sample-social/`** when the project kept it. It is the worked example and wins over any description here.
14
+ 3. **Scaffold** with `pnpm new <slug> --track brand --feature <feature>` (`--sprint` for the feature's primary). The README's Formats table lists each artboard, its format and where it runs, before any code.
15
+
16
+ ## Drawing
17
+
18
+ - **Real pixels.** An artboard is its format's size (`post-square` is 1080 × 1080, `slide` 1920 × 1080, `a4` 794 × 1123). Write type, spacing and radii at that size: a feed headline is 64 to 104px, never the 32px a web page would use. The Board scales the view; the values never change. Why: export writes the values in the code, so a value tuned on a scaled preview ships at the wrong size.
19
+ - **Position inside the frame.** The artboard is `position: relative` with fixed size: lay out with an absolutely filled root (`position: absolute; inset: 0`) and flex or grid inside it. Nothing scrolls, nothing depends on the viewport.
20
+ - **Tokens only.** Colours, fonts and radii come from `kit/tokens.css`; a new brand colour is a token first, then used. The logo is `<Icon name={BRAND.glyph}>` or the file DESIGN.md names, never redrawn.
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
+ - **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
+
24
+ ## Dials are the template's slots
25
+
26
+ Every slot an editor will change is a dial or a fixture, never a hard-coded string:
27
+
28
+ | Slot | How |
29
+ | --- | --- |
30
+ | Copy (kicker, headline, subhead, call to action) | `fixtures.json`, one item per post; `text` names headline and subhead so `longest` stresses them |
31
+ | Which post | A `post` select over the set |
32
+ | Layout (photo, type only, quote) | A `layout` select; each option a state in the README |
33
+ | Tone (brand, light, inverse) | A `tone` select |
34
+
35
+ 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
+
37
+ ## Export
38
+
39
+ ```bash
40
+ pnpm export <slug> # every artboard at its format's default
41
+ pnpm export <slug> --dials '{"Review":{"layout":"type"}}' # a chosen state, by panel and dial name
42
+ pnpm export <slug> --as pdf # everything as PDF
43
+ pnpm export <slug> --scale 2 # PNGs at twice the pixels
44
+ ```
45
+
46
+ PNG for posts, stories, link previews and banners, at the exact size platforms ask for; one PDF per format for slides and print, each page at the format's size. Files land in `exports/<slug>/` (gitignored), named `<slug>-<artboard name>.png`. It needs Chrome, Chromium or Edge on the machine (`CHROME_PATH` for another location).
47
+
48
+ Export the state the README's Decision names. When the user asks for "the posts", export each post in the set: one `--dials` per post, `--out exports/<slug>/post-<n>`.
49
+
50
+ ## Done
51
+
52
+ The definition of done in `AGENTS.md`, plus: every artboard exports without an error, the exported files are opened and look like the board, and nothing sits in a story's safe bands.