create-substrate 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/dist/index.js +1 -1
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +68 -4
- package/dist/scaffold.js.map +1 -1
- package/dist/surfaces/3d-scene.d.ts.map +1 -1
- package/dist/surfaces/3d-scene.js +414 -67
- package/dist/surfaces/3d-scene.js.map +1 -1
- package/dist/surfaces/animation.d.ts.map +1 -1
- package/dist/surfaces/animation.js +95 -103
- package/dist/surfaces/animation.js.map +1 -1
- package/dist/surfaces/blank.d.ts.map +1 -1
- package/dist/surfaces/blank.js +28 -16
- package/dist/surfaces/blank.js.map +1 -1
- package/dist/surfaces/canvas-2d.d.ts.map +1 -1
- package/dist/surfaces/canvas-2d.js +369 -92
- package/dist/surfaces/canvas-2d.js.map +1 -1
- package/dist/surfaces/data-vis.d.ts.map +1 -1
- package/dist/surfaces/data-vis.js +262 -98
- package/dist/surfaces/data-vis.js.map +1 -1
- package/dist/surfaces/image-gen.d.ts.map +1 -1
- package/dist/surfaces/image-gen.js +354 -92
- package/dist/surfaces/image-gen.js.map +1 -1
- package/dist/surfaces/node-editor.d.ts.map +1 -1
- package/dist/surfaces/node-editor.js +559 -114
- package/dist/surfaces/node-editor.js.map +1 -1
- package/package.json +4 -2
- package/skills/3d-scene/SKILL.md +6 -0
- package/skills/animation/SKILL.md +6 -0
- package/skills/canvas-2d/SKILL.md +7 -1
- package/skills/composing-panels/SKILL.md +14 -8
- package/skills/create-custom-tool/SKILL.md +6 -0
- package/skills/data-visualisation/SKILL.md +6 -0
- package/skills/image-generation/SKILL.md +6 -0
- package/skills/install-components/SKILL.md +199 -0
- package/skills/scaffold-playground/SKILL.md +12 -6
- package/skills/substrate-controls/SKILL.md +1 -3
- package/skills/theming/SKILL.md +6 -0
- package/skills/wire-interactions/SKILL.md +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-editor.js","sourceRoot":"","sources":["../../src/surfaces/node-editor.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAkB;IACvC,UAAU,EAAE;QACV,SAAS;QACT,OAAO;QACP,MAAM;QACN,MAAM;QACN,cAAc;QACd,eAAe;QACf,YAAY;QACZ,eAAe;
|
|
1
|
+
{"version":3,"file":"node-editor.js","sourceRoot":"","sources":["../../src/surfaces/node-editor.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAkB;IACvC,UAAU,EAAE;QACV,SAAS;QACT,OAAO;QACP,MAAM;QACN,MAAM;QACN,cAAc;QACd,eAAe;QACf,YAAY;QACZ,eAAe;KAChB;IACD,OAAO,EAAE;;;;;;;mCAOwB;IACjC,GAAG,EAAE,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8nBZ;CACA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-substrate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Scaffold a Substrate creative tool playground",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|
|
11
|
-
"dev": "tsx src/index.ts"
|
|
11
|
+
"dev": "tsx src/index.ts",
|
|
12
|
+
"prepack": "node ../../scripts/sync-skills.mjs && npm run build",
|
|
13
|
+
"prepublishOnly": "npm --prefix ../.. run release:check"
|
|
12
14
|
},
|
|
13
15
|
"dependencies": {
|
|
14
16
|
"chalk": "^5.4.0",
|
package/skills/3d-scene/SKILL.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 3d-scene
|
|
3
|
+
description: "Build interactive 3D viewports with Substrate — scene graphs, orbit cameras, object placement, materials, and lighting. Use when the app involves spatial objects in three dimensions. Triggers on: 3D, scene, viewport, three.js, react-three-fiber, r3f, orbit camera, material editor, lighting, shader playground, product viewer, scene graph."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# 3D scene
|
|
2
8
|
|
|
3
9
|
Guide to building interactive 3D viewports with Substrate — object placement, orbit cameras, material editors, and lighting controls.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: animation
|
|
3
|
+
description: "Build timeline-based motion tools with Substrate — keyframes, easing curves, playback controls, and animated previews. Use when the app involves motion over time. Triggers on: animation, timeline, keyframe, easing, tween, playback, motion, GSAP, sprite animation, motion graphics, ease curve."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Animation
|
|
2
8
|
|
|
3
9
|
Guide to building timeline-based motion tools with Substrate — keyframe editing, easing controls, playback, and animated previews.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: canvas-2d
|
|
3
|
+
description: "Build spatial 2D tools with Substrate — shape editors, diagram builders, whiteboards, and Figma-like design surfaces using the DesignCanvas component. Use when the app involves objects on an infinite pannable/zoomable plane. Triggers on: canvas, 2D, design canvas, shape editor, diagram, whiteboard, map builder, pan, zoom, infinite canvas, Figma-like, flat shapes."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# 2D canvas
|
|
2
8
|
|
|
3
9
|
Guide to building spatial 2D tools with Substrate — shape editors, diagram builders, whiteboard apps, and Figma-like design surfaces.
|
|
@@ -21,7 +27,7 @@ This pulls in the canvas renderer, hit-test system, interaction hooks, transform
|
|
|
21
27
|
### Mount
|
|
22
28
|
|
|
23
29
|
```tsx
|
|
24
|
-
import { DesignCanvas } from "@/
|
|
30
|
+
import { DesignCanvas } from "@/components/substrate/design-canvas"
|
|
25
31
|
|
|
26
32
|
export default function PlaygroundPage() {
|
|
27
33
|
return (
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: composing-panels
|
|
3
|
+
description: "Compose Substrate panel UIs — how Panel, Pane, PaneHeader, Action, and ActionControls nest together to build property inspectors, layer panels, and parameter forms. Use when laying out the side panels of a playground. Triggers on: panel, pane, sidebar, inspector, property panel, layer panel, form row, action row, compose panels, nest components."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Composing panels
|
|
2
8
|
|
|
3
9
|
Guide to building property panels, layer lists, and inspector UIs using Substrate's panel component system.
|
|
@@ -30,7 +36,7 @@ npx shadcn@latest add https://substrate.georgedrury.co.uk/r/slider
|
|
|
30
36
|
## Panel positioning
|
|
31
37
|
|
|
32
38
|
```tsx
|
|
33
|
-
import { Panel } from "@/
|
|
39
|
+
import { Panel } from "@/components/substrate/panel"
|
|
34
40
|
|
|
35
41
|
{
|
|
36
42
|
/* Left panel — layers, tool options */
|
|
@@ -52,19 +58,19 @@ A typical properties panel reads from `useDocumentStore` and writes back via `up
|
|
|
52
58
|
```tsx
|
|
53
59
|
"use client"
|
|
54
60
|
|
|
55
|
-
import { useDocumentStore } from "@/
|
|
61
|
+
import { useDocumentStore } from "@/stores/substrate/document-store"
|
|
56
62
|
import {
|
|
57
63
|
Pane,
|
|
58
64
|
PaneHeader,
|
|
59
65
|
PaneLabel,
|
|
60
66
|
PaneAction,
|
|
61
|
-
} from "@/
|
|
67
|
+
} from "@/components/substrate/pane"
|
|
62
68
|
import {
|
|
63
69
|
Action,
|
|
64
70
|
ActionLabel,
|
|
65
71
|
ActionControls,
|
|
66
|
-
} from "@/
|
|
67
|
-
import { Slider } from "@/
|
|
72
|
+
} from "@/components/substrate/action"
|
|
73
|
+
import { Slider } from "@/components/substrate/slider"
|
|
68
74
|
|
|
69
75
|
export function PropertiesPanel() {
|
|
70
76
|
const selectedIds = useDocumentStore((s) => s.selectedIds)
|
|
@@ -164,12 +170,12 @@ A layers panel lists elements in render order (bottom to top) and lets users sel
|
|
|
164
170
|
```tsx
|
|
165
171
|
"use client"
|
|
166
172
|
|
|
167
|
-
import { useDocumentStore } from "@/
|
|
173
|
+
import { useDocumentStore } from "@/stores/substrate/document-store"
|
|
168
174
|
import {
|
|
169
175
|
Pane,
|
|
170
176
|
PaneHeader,
|
|
171
177
|
PaneLabel,
|
|
172
|
-
} from "@/
|
|
178
|
+
} from "@/components/substrate/pane"
|
|
173
179
|
|
|
174
180
|
export function LayersPanel() {
|
|
175
181
|
const elements = useDocumentStore((s) => s.elements)
|
|
@@ -218,7 +224,7 @@ export function LayersPanel() {
|
|
|
218
224
|
Use `usePanelStore` to control panel visibility:
|
|
219
225
|
|
|
220
226
|
```tsx
|
|
221
|
-
import { usePanelStore } from "@/
|
|
227
|
+
import { usePanelStore } from "@/stores/substrate/panel-store"
|
|
222
228
|
|
|
223
229
|
const leftPanel = usePanelStore((s) => s.leftPanel)
|
|
224
230
|
const rightPanel = usePanelStore((s) => s.rightPanel)
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: create-custom-tool
|
|
3
|
+
description: "End-to-end guide for adding a new canvas tool to Substrate — ToolType union, element factory, renderer, hit-test, interaction handler, keyboard shortcut, and toolbar entry. Use when extending the 2D canvas with a custom drawing or editing tool. Triggers on: custom tool, new tool, tool type, element factory, toolbar toggle, canvas tool, drawing tool, add tool."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Create a custom tool
|
|
2
8
|
|
|
3
9
|
End-to-end guide for adding a new canvas tool to Substrate — from type definition through to toolbar entry and keyboard shortcut.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: data-visualisation
|
|
3
|
+
description: "Build interactive data exploration tools with Substrate — charts, graphs, dashboards, and visual analytics surfaces. Use when the app explores, filters, and presents data visually. Triggers on: data visualisation, dataviz, chart, graph, dashboard, analytics, D3, Observable Plot, filters, axis, aggregation, data explorer."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Data visualisation
|
|
2
8
|
|
|
3
9
|
Guide to building interactive data exploration tools with Substrate — charts, graphs, dashboards, and visual analytics playgrounds.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: image-generation
|
|
3
|
+
description: "Build prompt-driven image creation tools with Substrate — generation controls, preview surfaces, galleries, and parameter tuning. Use when the app produces AI-generated visuals via an API. Triggers on: image generation, text-to-image, Stable Diffusion, fal.ai, Replicate, inpainting, outpainting, style transfer, texture generator, prompt, gallery, generation controls."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Image generation
|
|
2
8
|
|
|
3
9
|
Guide to building prompt-driven image creation tools with Substrate — generation controls, preview surfaces, galleries, and parameter tuning.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: install-components
|
|
3
|
+
description: "Catalogue of every Substrate component, hook, utility, and store — with the exact `substrate-kit add` command to install each. Use this BEFORE writing any custom slider, input, toggle, picker, toolbar, panel, or other UI primitive — Substrate almost certainly already has one. Triggers on: slider, input, toggle, select, picker, swatch, toolbar, panel, pane, modal, popover, context menu, command palette, progress bar, badge, tabs, tree, layer list, resizer, status bar, zoom, gallery, timeline, easing, node, port, custom component, build my own, write a slider, from scratch, install, substrate-kit add."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Install Substrate components
|
|
8
|
+
|
|
9
|
+
**Before you write any UI primitive from scratch, check this catalogue.** Substrate ships a slider, number input, colour picker, toggle, select, context menu, command palette, toolbar, panel, timeline, easing editor, node graph, and many more — installable with a single command.
|
|
10
|
+
|
|
11
|
+
## How to install
|
|
12
|
+
|
|
13
|
+
All Substrate components install through the Substrate CLI, **not** by hand-rolling them or copying from other registries:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx substrate-kit add <component-name>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Install several at once:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx substrate-kit add slider number-input toggle colour-picker
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Install every component in a category:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx substrate-kit add --category substrate/ui/form
|
|
29
|
+
npx substrate-kit add --category substrate/ui/control
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Open an interactive picker (no arguments):
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx substrate-kit add
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
List all categories and their components:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx substrate-kit add --list-categories
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Requirements
|
|
45
|
+
|
|
46
|
+
- Run from a project created with `npx create-substrate` or initialised with `npx @substrate-kit/cli init`. Both add `@substrate-kit/cli` as a dev dependency, which is what makes `npx substrate-kit` resolve. The CLI looks for `components.json` — it will error if it's missing.
|
|
47
|
+
- Components land in `registry/substrate/...` and related aliases defined in `components.json`.
|
|
48
|
+
- Under the hood the CLI delegates to `npx shadcn@latest add` against `https://substrate.georgedrury.co.uk/r/<name>`. Do **not** use the shadcn CLI directly — always go through `substrate-kit add` so the CLI can print theme-override hints and keep the workflow uniform.
|
|
49
|
+
|
|
50
|
+
### Related CLI commands
|
|
51
|
+
|
|
52
|
+
| Command | What it does |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `substrate-kit add <name>` | Install one or more components |
|
|
55
|
+
| `substrate-kit docs <name>` | Read component docs in the terminal |
|
|
56
|
+
| `substrate-kit browse <name>` | Open component docs in the browser |
|
|
57
|
+
| `substrate-kit variables <name>` | Print the theme-override CSS variables for a component |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Don't build these — install them
|
|
62
|
+
|
|
63
|
+
When you catch yourself about to write a custom version of any of these, stop and run `substrate-kit add <name>` instead.
|
|
64
|
+
|
|
65
|
+
### Form controls — `substrate/ui/form`
|
|
66
|
+
|
|
67
|
+
| Component | Command | Use for |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| Slider | `substrate-kit add slider` | Any range input — opacity, volume, zoom, numeric sliders |
|
|
70
|
+
| Number Input | `substrate-kit add number-input` | Numeric property fields with drag-to-scrub on the label |
|
|
71
|
+
| Number Slider | `substrate-kit add number-slider` | Combined slider + numeric input on one row |
|
|
72
|
+
| Select | `substrate-kit add select` | Dropdown pickers (blend mode, font family, alignment) |
|
|
73
|
+
| Toggle | `substrate-kit add toggle` | Binary on/off switches (snap, visibility, lock) |
|
|
74
|
+
| Text Area | `substrate-kit add text-area` | Auto-resizing multi-line text input |
|
|
75
|
+
|
|
76
|
+
### Higher-level controls — `substrate/ui/control`
|
|
77
|
+
|
|
78
|
+
| Component | Command | Use for |
|
|
79
|
+
| --- | --- | --- |
|
|
80
|
+
| Colour Picker | `substrate-kit add colour-picker` | HSV picker with hex/RGB + opacity |
|
|
81
|
+
| Swatch Palette | `substrate-kit add swatch-palette` | Grid of preset colours |
|
|
82
|
+
| Alignment Controls | `substrate-kit add alignment-controls` | Horizontal/vertical align + distribute |
|
|
83
|
+
| Collapsible Pane | `substrate-kit add collapsible-pane` | Expandable section inside a panel |
|
|
84
|
+
| Layer List | `substrate-kit add layer-list` | Sortable list with visibility/lock toggles |
|
|
85
|
+
| Tree List | `substrate-kit add tree-list` | Hierarchical tree with expand/collapse and drag reorder |
|
|
86
|
+
| Node | `substrate-kit add node` | Card-based node with typed input/output ports |
|
|
87
|
+
|
|
88
|
+
### Chrome (app shell) — `substrate/ui/chrome`
|
|
89
|
+
|
|
90
|
+
| Component | Command | Use for |
|
|
91
|
+
| --- | --- | --- |
|
|
92
|
+
| Surface | `substrate-kit add surface` | Consistent mount point for a creative surface |
|
|
93
|
+
| History Controls | `substrate-kit add history-controls` | Undo/redo buttons wired to the document store |
|
|
94
|
+
| Breadcrumbs | `substrate-kit add breadcrumbs` | Document/frame hierarchy navigation |
|
|
95
|
+
| Command Palette | `substrate-kit add command-palette` | Cmd-K searchable command launcher |
|
|
96
|
+
| Document Tabs | `substrate-kit add document-tabs` | Tab bar for open documents |
|
|
97
|
+
| Resizer | `substrate-kit add resizer` | Draggable split-pane handle |
|
|
98
|
+
| Shortcut Overlay | `substrate-kit add shortcut-overlay` | `?`-triggered keyboard shortcuts overlay |
|
|
99
|
+
| Status Bar | `substrate-kit add status-bar` | Bottom bar for tool/selection/zoom info |
|
|
100
|
+
| Zoom Controls | `substrate-kit add zoom-controls` | Zoom in/out/reset with percentage display |
|
|
101
|
+
|
|
102
|
+
### Core UI — `substrate/ui`
|
|
103
|
+
|
|
104
|
+
| Component | Command | Use for |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| Toolbar | `substrate-kit add toolbar` | Floating toolbar with toggle groups and tooltips |
|
|
107
|
+
| Panel | `substrate-kit add panel` | Left/right side panel container |
|
|
108
|
+
| Pane | `substrate-kit add pane` | Content section (header + label + actions) inside a panel |
|
|
109
|
+
| Action | `substrate-kit add action` | Labelled form-row container |
|
|
110
|
+
| Badge | `substrate-kit add badge` | Small status indicator |
|
|
111
|
+
| Context Menu | `substrate-kit add context-menu` | Right-click menu with items, separators, submenus |
|
|
112
|
+
| Empty State | `substrate-kit add empty-state` | Placeholder for empty panels/lists |
|
|
113
|
+
| Popover | `substrate-kit add popover` | Floating content anchored to a trigger |
|
|
114
|
+
| Progress Bar | `substrate-kit add progress-bar` | Horizontal progress indicator |
|
|
115
|
+
| Toast | `substrate-kit add toast` | Notifications with undo, powered by Sonner |
|
|
116
|
+
|
|
117
|
+
### Animation — `substrate/ui/animation`
|
|
118
|
+
|
|
119
|
+
| Component | Command | Use for |
|
|
120
|
+
| --- | --- | --- |
|
|
121
|
+
| Timeline | `substrate-kit add timeline` | Ruler + playhead + tracks + keyframe diamonds |
|
|
122
|
+
| Easing Curve Editor | `substrate-kit add easing-curve-editor` | Draggable cubic-bezier editor |
|
|
123
|
+
|
|
124
|
+
### Visualisation — `substrate/ui/visualization`
|
|
125
|
+
|
|
126
|
+
| Component | Command | Use for |
|
|
127
|
+
| --- | --- | --- |
|
|
128
|
+
| Gallery | `substrate-kit add gallery` | Responsive thumbnail grid with selection and actions |
|
|
129
|
+
|
|
130
|
+
### 2D canvas — `substrate/canvas`
|
|
131
|
+
|
|
132
|
+
| Component | Command | Use for |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| Design Canvas | `substrate-kit add design-canvas` | The main HTML5 canvas component (pulls in renderer/hit-test/interaction) |
|
|
135
|
+
| Renderer | `substrate-kit add renderer` | Pure Canvas 2D draw functions |
|
|
136
|
+
| Hit Test | `substrate-kit add hit-test` | Point-in-element geometry |
|
|
137
|
+
| Element Factory | `substrate-kit add element-factory` | Factories for rectangle/ellipse/text/etc |
|
|
138
|
+
|
|
139
|
+
### Canvas hooks — `substrate/canvas` & `substrate/hook`
|
|
140
|
+
|
|
141
|
+
| Hook | Command | Use for |
|
|
142
|
+
| --- | --- | --- |
|
|
143
|
+
| useCanvasRenderer | `substrate-kit add use-canvas-renderer` | rAF render loop with dirty-flag optimisation |
|
|
144
|
+
| useCanvasInteraction | `substrate-kit add use-canvas-interaction` | Pointer-event state machine (idle/pan/create/drag) |
|
|
145
|
+
| useCanvasDrag | `substrate-kit add use-canvas-drag` | Drag tracking (create/move/resize) |
|
|
146
|
+
| useCanvasTransform | `substrate-kit add use-canvas-transform` | Screen↔world coordinate conversion, pan, zoom |
|
|
147
|
+
| useHitTest | `substrate-kit add use-hit-test` | Hit-testing wrapper around canvas state |
|
|
148
|
+
| useKeyboardShortcuts | `substrate-kit add use-keyboard-shortcuts` | Global keyboard shortcut binding |
|
|
149
|
+
| useSelection | `substrate-kit add use-selection` | Multi-select with cmd/shift modifiers |
|
|
150
|
+
| useDragReorder | `substrate-kit add use-drag-reorder` | Pointer-based list reordering |
|
|
151
|
+
| useClipboard | `substrate-kit add use-clipboard` | Copy/cut/paste with system clipboard |
|
|
152
|
+
| useViewport | `substrate-kit add use-viewport` | Pan/zoom state for canvas surfaces |
|
|
153
|
+
| useUndoable | `substrate-kit add use-undoable` | Lightweight undo/redo stack |
|
|
154
|
+
|
|
155
|
+
### Stores — `substrate/store`
|
|
156
|
+
|
|
157
|
+
| Store | Command | Use for |
|
|
158
|
+
| --- | --- | --- |
|
|
159
|
+
| document-store | `substrate-kit add document-store` | Elements, camera, selection, history |
|
|
160
|
+
| tool-store | `substrate-kit add tool-store` | Active tool + temporary tool support |
|
|
161
|
+
| panel-store | `substrate-kit add panel-store` | Left/right panel visibility, open panes |
|
|
162
|
+
| animation-store | `substrate-kit add animation-store` | Playback: duration, time, play/pause |
|
|
163
|
+
|
|
164
|
+
### Libraries — `substrate/lib`
|
|
165
|
+
|
|
166
|
+
| Lib | Command | Use for |
|
|
167
|
+
| --- | --- | --- |
|
|
168
|
+
| types | `substrate-kit add types` | Core canvas type definitions |
|
|
169
|
+
| math | `substrate-kit add math` | Geometry helpers (rotate, clamp, hit, distance) |
|
|
170
|
+
| id | `substrate-kit add id` | `crypto.randomUUID` wrapper |
|
|
171
|
+
| color | `substrate-kit add color` | OKLCh parsing and manipulation |
|
|
172
|
+
| keyboard-shortcuts | `substrate-kit add keyboard-shortcuts` | Declarative shortcut registration + formatting |
|
|
173
|
+
| snap | `substrate-kit add snap` | Grid + smart edge snapping |
|
|
174
|
+
| bounding-box | `substrate-kit add bounding-box` | AABB union/intersect/contain/expand |
|
|
175
|
+
| easing | `substrate-kit add easing` | Cubic bezier easing presets and evaluation |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Rules of thumb
|
|
180
|
+
|
|
181
|
+
1. **If you're about to write a form control, stop.** `slider`, `number-input`, `number-slider`, `select`, `toggle`, `text-area` already exist. Writing a custom one means throwing away the `data-slot` composition that makes `ActionControls` style children automatically.
|
|
182
|
+
2. **If you're about to write a colour picker, stop.** `colour-picker` and `swatch-palette` exist.
|
|
183
|
+
3. **If you're about to write a context menu, command palette, toast, or popover, stop.** All four are in the registry.
|
|
184
|
+
4. **If you're about to write a panel/pane/toolbar/status bar, stop.** The entire app shell is packaged — see `substrate-scaffold` for composition patterns.
|
|
185
|
+
5. **If you're about to write a canvas renderer or hit-test from scratch, stop.** `design-canvas` bundles the renderer, hit-test, interaction state machine, and keyboard shortcuts.
|
|
186
|
+
6. **Never use `npx shadcn@latest add` directly** for Substrate components — go through `substrate-kit add` so theme hints and workflow stay consistent.
|
|
187
|
+
|
|
188
|
+
## Cross-references
|
|
189
|
+
|
|
190
|
+
| Want a domain overview? | Skill |
|
|
191
|
+
| --- | --- |
|
|
192
|
+
| Form controls and property editors | **substrate-controls** |
|
|
193
|
+
| App shell (toolbar, panels, tabs, status bar) | **substrate-scaffold** |
|
|
194
|
+
| Spatial hooks (viewport, selection, snapping) | **substrate-canvas** |
|
|
195
|
+
| Node graph (nodes, ports, wires) | **substrate-nodes** |
|
|
196
|
+
| Status/notification/discovery UI | **substrate-feedback** |
|
|
197
|
+
| Selection/undo/clipboard/shortcuts wiring | **substrate-interaction** |
|
|
198
|
+
| Building a new playground | **scaffold-playground** |
|
|
199
|
+
| Composing a property panel | **composing-panels** |
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scaffold-playground
|
|
3
|
+
description: "Bootstrap a new Substrate playground from scratch — choose a surface type, install chrome primitives, and compose the surface + panels + toolbar layout. Use when starting a new interactive app or initialising Substrate in an existing project. Triggers on: new playground, scaffold, bootstrap, start project, substrate create, substrate init, set up Substrate, new app, starter."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Scaffold a Substrate playground
|
|
2
8
|
|
|
3
9
|
Step-by-step guide to bootstrapping a new interactive playground from Substrate primitives.
|
|
@@ -11,7 +17,7 @@ A Substrate playground is a creative app built from composable primitives: a **s
|
|
|
11
17
|
A Next.js 14+ project with Tailwind CSS and the shadcn CLI configured. If you don't have one, run:
|
|
12
18
|
|
|
13
19
|
```bash
|
|
14
|
-
npx substrate
|
|
20
|
+
npx create-substrate my-playground
|
|
15
21
|
```
|
|
16
22
|
|
|
17
23
|
This scaffolds a full project with dependencies, globals.css with Substrate tokens, and a starter playground page.
|
|
@@ -19,7 +25,7 @@ This scaffolds a full project with dependencies, globals.css with Substrate toke
|
|
|
19
25
|
To add Substrate to an existing project instead:
|
|
20
26
|
|
|
21
27
|
```bash
|
|
22
|
-
npx substrate-kit init
|
|
28
|
+
npx @substrate-kit/cli init
|
|
23
29
|
```
|
|
24
30
|
|
|
25
31
|
This installs skills, CLAUDE.md, components.json, and registers the MCP server.
|
|
@@ -64,15 +70,15 @@ Every playground follows the same layout pattern — surface in the centre, opti
|
|
|
64
70
|
```tsx
|
|
65
71
|
"use client"
|
|
66
72
|
|
|
67
|
-
import { Panel } from "@/
|
|
73
|
+
import { Panel } from "@/components/substrate/panel"
|
|
68
74
|
import {
|
|
69
75
|
Toolbar,
|
|
70
76
|
ToolbarToggleGroup,
|
|
71
77
|
ToolbarToggle,
|
|
72
78
|
ToolbarSeparator,
|
|
73
|
-
} from "@/
|
|
74
|
-
import { usePanelStore } from "@/
|
|
75
|
-
import { useToolStore } from "@/
|
|
79
|
+
} from "@/components/substrate/toolbar"
|
|
80
|
+
import { usePanelStore } from "@/stores/substrate/panel-store"
|
|
81
|
+
import { useToolStore } from "@/stores/substrate/tool-store"
|
|
76
82
|
|
|
77
83
|
export default function PlaygroundPage() {
|
|
78
84
|
const leftPanel = usePanelStore((s) => s.leftPanel)
|
|
@@ -40,7 +40,7 @@ A horizontal row that auto-styles its children:
|
|
|
40
40
|
| `colour-swatch` | `size-4`, removes border |
|
|
41
41
|
| `slider` | Removes border |
|
|
42
42
|
|
|
43
|
-
**Exports**: `
|
|
43
|
+
**Exports**: `Action`, `ActionLabel`, `ActionControls`
|
|
44
44
|
|
|
45
45
|
**Typical use**: Group a label + one or more controls on a single row inside a pane.
|
|
46
46
|
|
|
@@ -173,14 +173,12 @@ Cubic bezier editor with draggable control points and real-time preview.
|
|
|
173
173
|
<ActionControls>
|
|
174
174
|
<ActionLabel>X</ActionLabel>
|
|
175
175
|
<NumberInput value={x} onChange={setX} onStart={pushSnapshot} />
|
|
176
|
-
<ActionSeparator />
|
|
177
176
|
<ActionLabel>Y</ActionLabel>
|
|
178
177
|
<NumberInput value={y} onChange={setY} onStart={pushSnapshot} />
|
|
179
178
|
</ActionControls>
|
|
180
179
|
<ActionControls>
|
|
181
180
|
<ActionLabel>W</ActionLabel>
|
|
182
181
|
<NumberInput value={w} onChange={setW} min={0} onStart={pushSnapshot} />
|
|
183
|
-
<ActionSeparator />
|
|
184
182
|
<ActionLabel>H</ActionLabel>
|
|
185
183
|
<NumberInput value={h} onChange={setH} min={0} onStart={pushSnapshot} />
|
|
186
184
|
</ActionControls>
|
package/skills/theming/SKILL.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: theming
|
|
3
|
+
description: "Customise the visual appearance of Substrate — CSS variable fallback chains (Tailwind v4), canvas background, chrome tokens, element colours, and per-component overrides exposed by the registry. Use when restyling, rebranding, or matching a design system. Triggers on: theme, theming, colors, palette, CSS variables, design tokens, rebrand, dark mode, Tailwind v4, canvas colour, chrome styling, override tokens."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Theming Substrate
|
|
2
8
|
|
|
3
9
|
Guide to customising the visual appearance of Substrate's canvas, UI chrome, and elements.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wire-interactions
|
|
3
|
+
description: "Wire up Substrate's interaction pipeline — pointer events, drag state machine, hit testing, coordinate transforms, mutations, and keyboard shortcuts. Use when connecting a canvas surface to the document store or debugging interaction flows. Triggers on: pointer events, drag, interaction state machine, hit test, useCanvasInteraction, useCanvasDrag, useCanvasTransform, keyboard shortcut, wire up, connect canvas."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Wire interactions
|
|
2
8
|
|
|
3
9
|
Guide to connecting canvas pointer events, drag state, keyboard shortcuts, and the interaction state machine in Substrate.
|