@rien7/design-surface 0.0.0-stage → 0.1.1
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/bin/design-surface.mjs +286 -0
- package/dist/cli/init.mjs +411 -0
- package/dist/cli/propose.mjs +172 -0
- package/dist/cli/reviewOps.mjs +127 -0
- package/dist/editor/AgentProposalCard.d.ts +10 -0
- package/dist/editor/AgentProposalCard.d.ts.map +1 -0
- package/dist/editor/AgentProposalCard.js +28 -0
- package/dist/editor/AgentProposalCard.js.map +1 -0
- package/dist/editor/App.d.ts +2 -0
- package/dist/editor/App.d.ts.map +1 -0
- package/dist/editor/App.js +1813 -0
- package/dist/editor/App.js.map +1 -0
- package/dist/editor/CanvasHud.d.ts +12 -0
- package/dist/editor/CanvasHud.d.ts.map +1 -0
- package/dist/editor/CanvasHud.js +13 -0
- package/dist/editor/CanvasHud.js.map +1 -0
- package/dist/editor/CanvasSurface.d.ts +20 -0
- package/dist/editor/CanvasSurface.d.ts.map +1 -0
- package/dist/editor/CanvasSurface.js +252 -0
- package/dist/editor/CanvasSurface.js.map +1 -0
- package/dist/editor/Changes.d.ts +17 -0
- package/dist/editor/Changes.d.ts.map +1 -0
- package/dist/editor/Changes.js +59 -0
- package/dist/editor/Changes.js.map +1 -0
- package/dist/editor/CommentPopover.d.ts +17 -0
- package/dist/editor/CommentPopover.d.ts.map +1 -0
- package/dist/editor/CommentPopover.js +62 -0
- package/dist/editor/CommentPopover.js.map +1 -0
- package/dist/editor/Comments.d.ts +13 -0
- package/dist/editor/Comments.d.ts.map +1 -0
- package/dist/editor/Comments.js +39 -0
- package/dist/editor/Comments.js.map +1 -0
- package/dist/editor/History.d.ts +7 -0
- package/dist/editor/History.d.ts.map +1 -0
- package/dist/editor/History.js +43 -0
- package/dist/editor/History.js.map +1 -0
- package/dist/editor/Inspector.d.ts +22 -0
- package/dist/editor/Inspector.d.ts.map +1 -0
- package/dist/editor/Inspector.js +241 -0
- package/dist/editor/Inspector.js.map +1 -0
- package/dist/editor/LazyMount.d.ts +10 -0
- package/dist/editor/LazyMount.d.ts.map +1 -0
- package/dist/editor/LazyMount.js +29 -0
- package/dist/editor/LazyMount.js.map +1 -0
- package/dist/editor/LocaleSwitch.d.ts +2 -0
- package/dist/editor/LocaleSwitch.d.ts.map +1 -0
- package/dist/editor/LocaleSwitch.js +13 -0
- package/dist/editor/LocaleSwitch.js.map +1 -0
- package/dist/editor/NodeInspector.d.ts +9 -0
- package/dist/editor/NodeInspector.d.ts.map +1 -0
- package/dist/editor/NodeInspector.js +9 -0
- package/dist/editor/NodeInspector.js.map +1 -0
- package/dist/editor/PreviewFrame.d.ts +10 -0
- package/dist/editor/PreviewFrame.d.ts.map +1 -0
- package/dist/editor/PreviewFrame.js +22 -0
- package/dist/editor/PreviewFrame.js.map +1 -0
- package/dist/editor/ProjectIndex.d.ts +12 -0
- package/dist/editor/ProjectIndex.d.ts.map +1 -0
- package/dist/editor/ProjectIndex.js +43 -0
- package/dist/editor/ProjectIndex.js.map +1 -0
- package/dist/editor/StyleEditor.d.ts +37 -0
- package/dist/editor/StyleEditor.d.ts.map +1 -0
- package/dist/editor/StyleEditor.js +275 -0
- package/dist/editor/StyleEditor.js.map +1 -0
- package/dist/editor/TokenWorkbench.d.ts +37 -0
- package/dist/editor/TokenWorkbench.d.ts.map +1 -0
- package/dist/editor/TokenWorkbench.js +146 -0
- package/dist/editor/TokenWorkbench.js.map +1 -0
- package/dist/editor/Tokens.d.ts +21 -0
- package/dist/editor/Tokens.d.ts.map +1 -0
- package/dist/editor/Tokens.js +56 -0
- package/dist/editor/Tokens.js.map +1 -0
- package/dist/editor/VariablesPage.d.ts +28 -0
- package/dist/editor/VariablesPage.d.ts.map +1 -0
- package/dist/editor/VariablesPage.js +14 -0
- package/dist/editor/VariablesPage.js.map +1 -0
- package/dist/editor/api.d.ts +13 -0
- package/dist/editor/api.d.ts.map +1 -0
- package/dist/editor/api.js +70 -0
- package/dist/editor/api.js.map +1 -0
- package/dist/editor/camera.d.ts +18 -0
- package/dist/editor/camera.d.ts.map +1 -0
- package/dist/editor/camera.js +40 -0
- package/dist/editor/camera.js.map +1 -0
- package/dist/editor/canvas.d.ts +26 -0
- package/dist/editor/canvas.d.ts.map +1 -0
- package/dist/editor/canvas.js +51 -0
- package/dist/editor/canvas.js.map +1 -0
- package/dist/editor/chrome/EditorChrome.d.ts +42 -0
- package/dist/editor/chrome/EditorChrome.d.ts.map +1 -0
- package/dist/editor/chrome/EditorChrome.js +21 -0
- package/dist/editor/chrome/EditorChrome.js.map +1 -0
- package/dist/editor/i18n.d.ts +18 -0
- package/dist/editor/i18n.d.ts.map +1 -0
- package/dist/editor/i18n.js +762 -0
- package/dist/editor/i18n.js.map +1 -0
- package/dist/editor/main.d.ts +3 -0
- package/dist/editor/main.d.ts.map +1 -0
- package/dist/editor/main.js +12 -0
- package/dist/editor/main.js.map +1 -0
- package/dist/editor/model.d.ts +17 -0
- package/dist/editor/model.d.ts.map +1 -0
- package/dist/editor/model.js +12 -0
- package/dist/editor/model.js.map +1 -0
- package/dist/editor/reviewLifecycle.d.ts +9 -0
- package/dist/editor/reviewLifecycle.d.ts.map +1 -0
- package/dist/editor/reviewLifecycle.js +30 -0
- package/dist/editor/reviewLifecycle.js.map +1 -0
- package/dist/editor/styles.css +6626 -0
- package/dist/editor/ui/Button.d.ts +3 -0
- package/dist/editor/ui/Button.d.ts.map +1 -0
- package/dist/editor/ui/Button.js +6 -0
- package/dist/editor/ui/Button.js.map +1 -0
- package/dist/editor/ui/CommentBox.d.ts +23 -0
- package/dist/editor/ui/CommentBox.d.ts.map +1 -0
- package/dist/editor/ui/CommentBox.js +41 -0
- package/dist/editor/ui/CommentBox.js.map +1 -0
- package/dist/editor/ui/Icon.d.ts +9 -0
- package/dist/editor/ui/Icon.d.ts.map +1 -0
- package/dist/editor/ui/Icon.js +6 -0
- package/dist/editor/ui/Icon.js.map +1 -0
- package/dist/editor/ui/IconButton.d.ts +11 -0
- package/dist/editor/ui/IconButton.d.ts.map +1 -0
- package/dist/editor/ui/IconButton.js +6 -0
- package/dist/editor/ui/IconButton.js.map +1 -0
- package/dist/editor/ui/NumberInput.d.ts +14 -0
- package/dist/editor/ui/NumberInput.d.ts.map +1 -0
- package/dist/editor/ui/NumberInput.js +6 -0
- package/dist/editor/ui/NumberInput.js.map +1 -0
- package/dist/editor/ui/PageLine.d.ts +14 -0
- package/dist/editor/ui/PageLine.d.ts.map +1 -0
- package/dist/editor/ui/PageLine.js +7 -0
- package/dist/editor/ui/PageLine.js.map +1 -0
- package/dist/editor/ui/Select.d.ts +15 -0
- package/dist/editor/ui/Select.d.ts.map +1 -0
- package/dist/editor/ui/Select.js +11 -0
- package/dist/editor/ui/Select.js.map +1 -0
- package/dist/editor/ui/TokenField.d.ts +14 -0
- package/dist/editor/ui/TokenField.d.ts.map +1 -0
- package/dist/editor/ui/TokenField.js +41 -0
- package/dist/editor/ui/TokenField.js.map +1 -0
- package/dist/editor-ui.d.ts +14 -0
- package/dist/editor-ui.d.ts.map +1 -0
- package/dist/editor-ui.js +13 -0
- package/dist/editor-ui.js.map +1 -0
- package/dist/inspector/runtime.d.ts +18 -0
- package/dist/inspector/runtime.d.ts.map +1 -0
- package/dist/inspector/runtime.js +987 -0
- package/dist/inspector/runtime.js.map +1 -0
- package/dist/preview/main.d.ts +3 -0
- package/dist/preview/main.d.ts.map +1 -0
- package/dist/preview/main.js +72 -0
- package/dist/preview/main.js.map +1 -0
- package/dist/preview/preview.css +39 -0
- package/dist/runtime/flow.d.ts +15 -0
- package/dist/runtime/flow.d.ts.map +1 -0
- package/dist/runtime/flow.js +48 -0
- package/dist/runtime/flow.js.map +1 -0
- package/dist/runtime/free.d.ts +18 -0
- package/dist/runtime/free.d.ts.map +1 -0
- package/dist/runtime/free.js +8 -0
- package/dist/runtime/free.js.map +1 -0
- package/dist/runtime/index.d.ts +11 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +46 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/types.d.ts +57 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +14 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/shared/prompt.d.mts +13 -0
- package/dist/shared/prompt.mjs +97 -0
- package/dist/shared/protocol.d.ts +79 -0
- package/dist/shared/protocol.d.ts.map +1 -0
- package/dist/shared/protocol.js +7 -0
- package/dist/shared/protocol.js.map +1 -0
- package/dist/shared/tokens.d.ts +66 -0
- package/dist/shared/tokens.d.ts.map +1 -0
- package/dist/shared/tokens.js +2 -0
- package/dist/shared/tokens.js.map +1 -0
- package/dist/shared/types.d.ts +301 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +13 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/tokens/adapters/css.mjs +44 -0
- package/dist/tokens/adapters/cssInCode.mjs +277 -0
- package/dist/tokens/adapters/oxcShared.mjs +59 -0
- package/dist/tokens/adapters/preprocessor.mjs +63 -0
- package/dist/tokens/adapters/registry.mjs +53 -0
- package/dist/tokens/adapters/tailwindcss.mjs +360 -0
- package/dist/tokens/adapters/types.mjs +117 -0
- package/dist/tokens/extract.mjs +328 -0
- package/dist/tokens/pipeline.mjs +688 -0
- package/dist/vite/events.d.ts +25 -0
- package/dist/vite/events.d.ts.map +1 -0
- package/dist/vite/events.js +137 -0
- package/dist/vite/events.js.map +1 -0
- package/dist/vite/layout.d.ts +4 -0
- package/dist/vite/layout.d.ts.map +1 -0
- package/dist/vite/layout.js +78 -0
- package/dist/vite/layout.js.map +1 -0
- package/dist/vite/plugin.d.ts +33 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +403 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/review.d.ts +7 -0
- package/dist/vite/review.d.ts.map +1 -0
- package/dist/vite/review.js +334 -0
- package/dist/vite/review.js.map +1 -0
- package/package.json +86 -4
- package/skills/design-surface/SKILL.md +190 -0
- package/skills/design-surface-authoring/SKILL.md +257 -0
- package/skills/design-surface-tokens/SKILL.md +235 -0
- package/README.md +0 -3
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: design-surface-authoring
|
|
3
|
+
description: Use when authoring or revising Design Surface artboards, editor-level pages, page boards, state frames, free-layout items, flows, providers, component pages, or review interactions. Defines the Page/Frame boundary, PageBoard API, FreeCanvas/FreeItem, defineFlow, componentPages, and thin-shell src/ vs design/ architecture.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Authoring a Design Surface
|
|
7
|
+
|
|
8
|
+
Design Surface has three levels: an artboard, pages, and frames.
|
|
9
|
+
|
|
10
|
+
- **Artboard** = one design project (`design/<id>/design.tsx`).
|
|
11
|
+
- **Page** = one editor-level canvas board. A page is not an iframe and has no page shell.
|
|
12
|
+
- **Frame** = one independently runnable iframe. A page can contain several frames.
|
|
13
|
+
|
|
14
|
+
## Start a new artboard
|
|
15
|
+
|
|
16
|
+
Scaffold the minimal `design/` structure once:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx design-surface init
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or create one directory per design:
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
design/<id>/design.tsx
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Export a `defineDesign` default. The Vite plugin discovers `design/<id>/design.tsx`; no registry edit is
|
|
29
|
+
needed. Open `/__design?design=<id>&page=<page>&frame=<frame>` in the Vite dev server.
|
|
30
|
+
|
|
31
|
+
### Thin-shell rule (`src/` vs `design/`)
|
|
32
|
+
|
|
33
|
+
**Real UI components must live in `src/` (or your shared UI package); `design/` is only a thin shell holding state frames, mock data, and canvas annotations.**
|
|
34
|
+
|
|
35
|
+
- Author reusable components, business UI, and styles in `src/`, then import them into `design/<id>/design.tsx` frames.
|
|
36
|
+
- Never build a duplicate copy of a component inside `design/` with the plan to copy-paste it into `src/` after review — the design is the code, and review items (`NodeRef.source`, `component`) resolve directly to the live component in `src/`.
|
|
37
|
+
- Keep `design/<id>/design.tsx` focused on `defineDesign`, `PageBoard`, `FrameConfig` states, mock props/providers, and page-level notes/annotations.
|
|
38
|
+
|
|
39
|
+
## Minimal example
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { defineDesign, type PageBoardProps } from '@rien7/design-surface/runtime'
|
|
43
|
+
import { CheckoutCard } from '@/components/CheckoutCard'
|
|
44
|
+
|
|
45
|
+
export default defineDesign({
|
|
46
|
+
title: 'Checkout',
|
|
47
|
+
pages: [
|
|
48
|
+
{
|
|
49
|
+
id: 'main',
|
|
50
|
+
title: 'Main',
|
|
51
|
+
size: [1200, 800],
|
|
52
|
+
board: MainBoard,
|
|
53
|
+
frames: [
|
|
54
|
+
{ id: 'desktop', title: 'Desktop', size: [960, 640], component: CheckoutDesktop },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
function MainBoard({ frames, renderFrame }: PageBoardProps) {
|
|
61
|
+
return <div className="flex flex-wrap gap-6">{frames.map(renderFrame)}</div>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function CheckoutDesktop() {
|
|
65
|
+
return (
|
|
66
|
+
<div data-ds="checkout-shell" className="p-6">
|
|
67
|
+
<CheckoutCard total="$48.00" />
|
|
68
|
+
</div>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> [!IMPORTANT]
|
|
74
|
+
> **Reserved `page.id` values**: Never use `'variables'` or `'overview'` as a `page.id` in `defineDesign`. Both IDs are reserved by the editor for the Variables sheet and Component overview routes.
|
|
75
|
+
|
|
76
|
+
## Page
|
|
77
|
+
|
|
78
|
+
A page is rendered by the editor directly:
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
{
|
|
82
|
+
id: 'comment-box',
|
|
83
|
+
title: 'CommentBox',
|
|
84
|
+
description: 'States for empty, drafting, and posted comments.',
|
|
85
|
+
size: [1200, 900],
|
|
86
|
+
board: CommentBoxBoard,
|
|
87
|
+
frames: [composeFrame, detailFrame],
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The page board (`board`) is editor-level React content. It can render:
|
|
92
|
+
|
|
93
|
+
- page title, description, captions and notes
|
|
94
|
+
- arrows and other annotations
|
|
95
|
+
- one or more frames through `renderFrame`
|
|
96
|
+
- any layout around the frames
|
|
97
|
+
|
|
98
|
+
Page annotations are **not inspectable**. The inspector runtime only runs inside frame iframes. Do not add page-level `data-ds-ignore`; it is not needed and is not the architecture.
|
|
99
|
+
|
|
100
|
+
The page has no outer card border, background card, or page-level frame bar. Its canvas styling belongs to the page surface.
|
|
101
|
+
|
|
102
|
+
## Frame
|
|
103
|
+
|
|
104
|
+
A frame is a standalone iframe with its own route:
|
|
105
|
+
|
|
106
|
+
```text
|
|
107
|
+
/__design/preview?design=<design>&page=<page>&frame=<frame>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- One frame = one state.
|
|
111
|
+
- `FrameConfig.size` is an explicit authored size. The design content assigns it;
|
|
112
|
+
the editor does not auto-measure and resize frames.
|
|
113
|
+
- The frame chrome and the state viewport are the same width. Opening a popup must
|
|
114
|
+
not change the chrome or the frame size, and must not squeeze labels or fields.
|
|
115
|
+
Leave enough width for the state content and enough height for its popup.
|
|
116
|
+
- Each frame has system chrome: title, state id, size, Play.
|
|
117
|
+
- Use declared color, radius, spacing and type tokens instead of literal palette values.
|
|
118
|
+
Reuse existing semantic tokens first; if a truly missing semantic role is needed, propose it with
|
|
119
|
+
`npx design-surface propose token` and a clear `--rationale`, reference it in code with a fallback
|
|
120
|
+
(`var(--proposed-token, var(--existing-fallback))`), wait for human Approve in the UI, and only
|
|
121
|
+
write `design/tokens/*.tokens.json` after approval. Run `npx design-surface tokens build` and
|
|
122
|
+
`npx design-surface tokens check` after editing DTCG source.
|
|
123
|
+
- Play toggles the iframe inline between inspect and play. It must not open a new tab.
|
|
124
|
+
- The frame is the context for inspector selection, comments and free-layout items. The review ledger is design-level; tokens are design-scoped.
|
|
125
|
+
- Do not put a card border, radius, shadow, inner page header or a second chrome inside the frame.
|
|
126
|
+
|
|
127
|
+
## PageBoard API
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
type PageBoardProps = {
|
|
131
|
+
page: PageConfig
|
|
132
|
+
frames: FrameConfig[]
|
|
133
|
+
activeFrameId: string
|
|
134
|
+
playing: ReadonlySet<string>
|
|
135
|
+
onActivateFrame: (frameId: string) => void
|
|
136
|
+
renderFrame: (frame: FrameConfig) => ReactNode
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The board renders `renderFrame(frame)` for each state. The system renders the frame chrome, iframe, loading/error states, selection and comments.
|
|
141
|
+
|
|
142
|
+
## Free layout (`FreeCanvas` & `FreeItem`)
|
|
143
|
+
|
|
144
|
+
Use `FreeCanvas` and `FreeItem` from `@rien7/design-surface/runtime` when a frame has free-positioned elements that can be Alt-dragged or adjusted numerically in the Inspector:
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { FreeCanvas, FreeItem } from '@rien7/design-surface/runtime'
|
|
148
|
+
import { HeroBanner } from '@/components/HeroBanner'
|
|
149
|
+
|
|
150
|
+
function HeroFrame() {
|
|
151
|
+
return (
|
|
152
|
+
<FreeCanvas width={1120} height={600}>
|
|
153
|
+
<FreeItem id="hero" x={32} y={32} width={420} height={260}>
|
|
154
|
+
<HeroBanner />
|
|
155
|
+
</FreeItem>
|
|
156
|
+
</FreeCanvas>
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
- `FreeItem` sets `data-ds={id}` and `data-free-item={id}` so `free` review items restore reliably across reloads.
|
|
162
|
+
- Apply `free` review item `to` rects back to `FreeItem` props (`x`, `y`, `width`, `height`).
|
|
163
|
+
|
|
164
|
+
## Flows (`defineFlow`, `useDesignFlow`, `FrameConfig.state`)
|
|
165
|
+
|
|
166
|
+
Attach an optional finite-state flow to a design so interactive Play frames and static state frames share transitions:
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { defineDesign, defineFlow, useDesignFlow } from '@rien7/design-surface/runtime'
|
|
170
|
+
import { PayButton } from '@/components/PayButton'
|
|
171
|
+
|
|
172
|
+
export const flow = defineFlow({
|
|
173
|
+
initial: 'idle',
|
|
174
|
+
states: {
|
|
175
|
+
idle: { on: { PAY: 'pending' } },
|
|
176
|
+
pending: { on: { OK: 'done', FAIL: 'error' } },
|
|
177
|
+
error: { on: { RETRY: 'pending' } },
|
|
178
|
+
done: {},
|
|
179
|
+
},
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
export default defineDesign({
|
|
183
|
+
title: 'Payment',
|
|
184
|
+
flow,
|
|
185
|
+
pages: [
|
|
186
|
+
{
|
|
187
|
+
id: 'states',
|
|
188
|
+
title: 'States',
|
|
189
|
+
size: [1200, 720],
|
|
190
|
+
frames: [
|
|
191
|
+
{ id: 'idle', title: 'Idle', size: [480, 320], state: 'idle', component: PayPreview },
|
|
192
|
+
{ id: 'error', title: 'Error', size: [480, 320], state: 'error', component: PayPreview },
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
function PayPreview() {
|
|
199
|
+
const { state, send } = useDesignFlow()
|
|
200
|
+
return (
|
|
201
|
+
<PayButton data-ds="pay-btn" pending={state === 'pending'} error={state === 'error'} onClick={() => send('PAY')} />
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- `FrameConfig.state` sets the initial flow state for that frame.
|
|
207
|
+
- Without `flow`, frames can use plain React state.
|
|
208
|
+
|
|
209
|
+
## Providers (`design/providers.tsx`)
|
|
210
|
+
|
|
211
|
+
Wrap every preview frame with your app's providers (theme context, router memory wrapper, tooltips, i18n) in `design/providers.tsx`:
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
import type { ReactNode } from 'react'
|
|
215
|
+
import { Tooltip } from '@base-ui/react/tooltip'
|
|
216
|
+
|
|
217
|
+
export function Providers({ children }: { children: ReactNode }) {
|
|
218
|
+
return <Tooltip.Provider>{children}</Tooltip.Provider>
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Component pages (`design/components.ts`)
|
|
223
|
+
|
|
224
|
+
- One page per component.
|
|
225
|
+
- One frame per state.
|
|
226
|
+
- Import and render the real component from `src/`.
|
|
227
|
+
- Register each component's page in `design/components.ts` (and optional manual `componentSources`):
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
// design/components.ts
|
|
231
|
+
export const componentPages = {
|
|
232
|
+
Button: { design: 'app', page: 'button' },
|
|
233
|
+
Card: { design: 'app', page: 'card' },
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export const componentSources = {
|
|
237
|
+
// Optional fallback when a component is outside componentGroups globs
|
|
238
|
+
ExternalWidget: 'src/widgets/ExternalWidget.tsx',
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
- Do not create a page per state and do not nest a whole board inside another iframe.
|
|
243
|
+
- The Inspector identifies the nearest React component and source location (`file:line`) from the live React tree. The Inspector does not edit component props, variants, or Tailwind classes — those belong in `src/` TSX.
|
|
244
|
+
|
|
245
|
+
## Pages vs components
|
|
246
|
+
|
|
247
|
+
- **Page** is the navigation unit: one page board, one canvas node, one entry under Pages.
|
|
248
|
+
- **Component page** is a page whose subject is one component. It is listed under Components, not duplicated under Pages.
|
|
249
|
+
- **Frame** is a state inside a page. Frames are never top-level page/component navigation entries.
|
|
250
|
+
|
|
251
|
+
## Comments
|
|
252
|
+
|
|
253
|
+
Review comments are editor chrome. They are anchored to a frame's content and rendered outside the iframe. Never put review pins, threads or a review composer inside a page board or a state frame.
|
|
254
|
+
|
|
255
|
+
## Handoff
|
|
256
|
+
|
|
257
|
+
The browser records review items in `design/<design>/review.json`; it never writes TSX or CSS. When asked to apply pending items, use `design-surface` and `npx design-surface status` / `npx design-surface reply`. Do not edit generated token files and do not archive items manually.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: design-surface-tokens
|
|
3
|
+
description: Use when editing Design Surface tokens, proposing new tokens, migrating existing CSS variables, resolving token review items, adding or aliasing DTCG tokens, or fixing token health. Covers source layout, tiers, aliases, build/check/extract, token actions and verification. For the general review loop use design-surface; for pages use design-surface-authoring.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Design Surface tokens
|
|
7
|
+
|
|
8
|
+
Token source is DTCG JSON under `design/tokens/`. Generated files are outputs. The browser
|
|
9
|
+
previews tokens as CSS variables; the agent proposes or edits DTCG source; the surface verifies
|
|
10
|
+
generated output.
|
|
11
|
+
|
|
12
|
+
## Source layout
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
design/tokens/primitive.tokens.json
|
|
16
|
+
design/tokens/semantic.tokens.json
|
|
17
|
+
design/tokens/component.tokens.json
|
|
18
|
+
design/tokens.config.json
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Tiers:
|
|
22
|
+
|
|
23
|
+
| Tier | Use |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `primitive` | Palette, raw scale, spacing, radius, font size, layout primitives. |
|
|
26
|
+
| `semantic` | Roles such as `surface.bg`, `surface.text`, `surface.accent`. |
|
|
27
|
+
| `component` | Component decisions that cannot be expressed semantically. |
|
|
28
|
+
|
|
29
|
+
Generated outputs (paths configurable in `design/tokens.config.json`):
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
design/tokens.generated.ts tokenGroups, tokenValues, tokenSources, tokenAliases, tokenSourceHash, tokenHealth
|
|
33
|
+
design/tokens.manifest.json resolved values, source hash, usage, contrast, hardcoded report, clusters, unsupported
|
|
34
|
+
src/tokens.generated.css @theme or :root CSS variables (based on cssFormat)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Never edit generated files. Edit DTCG source, then run:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx design-surface tokens build
|
|
41
|
+
npx design-surface tokens check
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
To migrate existing CSS custom properties from `:root` or `@theme` into DTCG source:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx design-surface tokens extract [files...] [--dry-run]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## DTCG shape
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"color": {
|
|
55
|
+
"$extensions": {
|
|
56
|
+
"design-surface": {
|
|
57
|
+
"tier": "primitive",
|
|
58
|
+
"group": "color",
|
|
59
|
+
"label": "Color",
|
|
60
|
+
"labelZh": "颜色"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"$type": "color",
|
|
64
|
+
"primary": {
|
|
65
|
+
"$value": "#2563eb",
|
|
66
|
+
"$extensions": {
|
|
67
|
+
"design-surface": {
|
|
68
|
+
"label": "Primary",
|
|
69
|
+
"labelZh": "主色",
|
|
70
|
+
"uiType": "color"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Common fields:
|
|
79
|
+
|
|
80
|
+
| Field | Meaning |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `$type` | `color`, `dimension`, `string`; controls validation. |
|
|
83
|
+
| `$value` | Literal or `{path.to.token}` alias. |
|
|
84
|
+
| `$description` | Optional human description. |
|
|
85
|
+
| `$extensions.design-surface.tier` | `primitive`, `semantic`, `component`. |
|
|
86
|
+
| `$extensions.design-surface.group` | Group id used by the Variables page. |
|
|
87
|
+
| `$extensions.design-surface.label` / `labelZh` | Display labels. |
|
|
88
|
+
| `$extensions.design-surface.uiType` | Form control: `color`, `length`, `text`, `select`. |
|
|
89
|
+
| `min` / `max` / `step` | Numeric bounds for length controls. |
|
|
90
|
+
|
|
91
|
+
Aliases:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"surface": {
|
|
96
|
+
"accent": {
|
|
97
|
+
"$type": "color",
|
|
98
|
+
"$value": "{color.primary}"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Alias paths use dots. No cycles. A token may alias another tier; the Variables page keeps alias rows
|
|
105
|
+
read-only and sends edits to the aliased source.
|
|
106
|
+
|
|
107
|
+
## CSS variable mapping
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
surface.accent -> --surface-accent
|
|
111
|
+
color.primary -> --color-primary
|
|
112
|
+
space.card -> --space-card
|
|
113
|
+
font-size.md -> --font-size-md
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`target.token` in a review item is the CSS variable name; `tokenAlias` is the DTCG path.
|
|
117
|
+
|
|
118
|
+
## Token review items
|
|
119
|
+
|
|
120
|
+
A token item is design-scoped:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"kind": "token",
|
|
125
|
+
"scope": "design",
|
|
126
|
+
"target": { "type": "token", "token": "--surface-accent" },
|
|
127
|
+
"source": "design/tokens/semantic.tokens.json",
|
|
128
|
+
"sourceHash": "<generated tokenSourceHash>",
|
|
129
|
+
"tokenType": "color",
|
|
130
|
+
"tokenAction": "update",
|
|
131
|
+
"from": "#2563eb",
|
|
132
|
+
"to": "#0f766e",
|
|
133
|
+
"status": "open"
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
| `tokenAction` | Source change | `to` |
|
|
138
|
+
| --- | --- | --- |
|
|
139
|
+
| `create` | Add the token to the requested tier. | Resolved value. |
|
|
140
|
+
| `update` | Change `$value` (literal or alias). | Resolved value. |
|
|
141
|
+
| `alias` | Set `$value` to `{target.path}`. | Target DTCG path. |
|
|
142
|
+
| `merge` | Alias the source to the target; preserve the source name as an alias unless asked to remove. | Target DTCG path. |
|
|
143
|
+
| `deprecate` | Remove the token and its usages. | Empty. |
|
|
144
|
+
|
|
145
|
+
For `alias` / `merge`, set `tokenAlias` to the target DTCG path. For `create`, set `tokenTier`.
|
|
146
|
+
|
|
147
|
+
### Agent → Human token proposals
|
|
148
|
+
|
|
149
|
+
When authoring new components or pages, reuse existing semantic tokens first. Only when a semantic
|
|
150
|
+
role is genuinely missing, propose it via the CLI instead of silently inventing tokens in DTCG
|
|
151
|
+
source:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
npx design-surface propose token <design> \
|
|
155
|
+
--name --surface-elevated \
|
|
156
|
+
--value "#ffffff" \
|
|
157
|
+
--tier semantic \
|
|
158
|
+
--alias color.surface \
|
|
159
|
+
--type color \
|
|
160
|
+
--rationale "Shared by secondary cards"
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- During the proposal stage (before approval and DTCG build), reference the proposed token in code
|
|
164
|
+
with an existing fallback: `var(--surface-elevated, var(--color-surface))`.
|
|
165
|
+
- `npx design-surface tokens check` allows unrejected agent proposal `var(--*)` references as a
|
|
166
|
+
report-only warning rather than failing with unknown CSS variable errors.
|
|
167
|
+
- Unreviewed proposals (`author: "agent"`, no `proposalDecision`) preview live in the UI and do
|
|
168
|
+
**not** appear in `Copy to agent` / `design-surface prompt` until the human decides.
|
|
169
|
+
- **`[approved proposal]`**: write the approved token (using the possibly adjusted `to` value) into
|
|
170
|
+
the named `design/tokens/<tier>.tokens.json` file, run `tokens build` and `tokens check`, and mark
|
|
171
|
+
`resolved` with `npx design-surface status <design> <itemId> resolved`.
|
|
172
|
+
- **`[rejected proposal]`**: do **not** create the token in DTCG source; switch usages back to
|
|
173
|
+
existing tokens following `decisionNote` and mark `resolved` with
|
|
174
|
+
`npx design-surface status <design> <itemId> resolved --reply "..."`. Rejected proposals archive
|
|
175
|
+
10 minutes after resolution without needing `verifiedAt`.
|
|
176
|
+
|
|
177
|
+
### Verification
|
|
178
|
+
|
|
179
|
+
The surface verifies generated output:
|
|
180
|
+
|
|
181
|
+
| Action | Verified when |
|
|
182
|
+
| --- | --- |
|
|
183
|
+
| `create` / `update` | generated value equals `to` |
|
|
184
|
+
| `alias` / `merge` | generated alias equals `to` |
|
|
185
|
+
| `deprecate` | generated value is absent |
|
|
186
|
+
|
|
187
|
+
Do not write `verifiedAt`. Do not archive token items. A resolved token item archives only after the
|
|
188
|
+
surface writes `verifiedAt` and ten minutes pass.
|
|
189
|
+
|
|
190
|
+
`sourceHash` is the generated token hash at proposal time. Do not edit it. If generated output is
|
|
191
|
+
stale, run `npx design-surface tokens build` and re-check.
|
|
192
|
+
|
|
193
|
+
## Token health
|
|
194
|
+
|
|
195
|
+
The Variables page and manifest report:
|
|
196
|
+
|
|
197
|
+
- duplicated values within a group
|
|
198
|
+
- orphan tokens with no usage and no alias
|
|
199
|
+
- semantic literals
|
|
200
|
+
- component tokens that alias primitives
|
|
201
|
+
- hardcoded color files and cross-file value `clusters`
|
|
202
|
+
- `unsupported` dynamic style expressions or uninstalled preprocessor parsers (report-only)
|
|
203
|
+
|
|
204
|
+
## Preview semantics
|
|
205
|
+
|
|
206
|
+
The Inspector previews token candidates as:
|
|
207
|
+
|
|
208
|
+
```css
|
|
209
|
+
padding: var(--space-card);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The actual component consumes the token. The preview is not the source. The agent applies the token
|
|
213
|
+
to TSX/CSS and updates the review item status with `npx design-surface status`.
|
|
214
|
+
|
|
215
|
+
## Checks
|
|
216
|
+
|
|
217
|
+
`npx design-surface tokens check` validates:
|
|
218
|
+
|
|
219
|
+
- DTCG types and alias cycles
|
|
220
|
+
- unknown `var()` references (unrejected agent proposals are allowed with a report-only warning)
|
|
221
|
+
- generated file freshness
|
|
222
|
+
- configured `contrastPairs`
|
|
223
|
+
- hardcoded color literals and unsupported style expressions (report-only)
|
|
224
|
+
|
|
225
|
+
If it reports generated files stale, run `npx design-surface tokens build` and check again.
|
|
226
|
+
|
|
227
|
+
## Common mistakes
|
|
228
|
+
|
|
229
|
+
- Editing `design/tokens.generated.ts` or `src/tokens.generated.css`.
|
|
230
|
+
- Editing `design/tokens.ts`; it re-exports generated metadata, not source.
|
|
231
|
+
- Using a CSS variable name in `tokenAlias`; use the DTCG path (e.g. `color.surface`).
|
|
232
|
+
- Adding a semantic token as a literal when an alias is expected.
|
|
233
|
+
- Marking a token resolved without rebuilding (`tokens build` + `tokens check`).
|
|
234
|
+
- Deleting a token without finding usages.
|
|
235
|
+
- Writing `verifiedAt` or `archivedAt`.
|
package/README.md
DELETED