Skip to content

Commit b5ad57c

Browse files
Copilothuangyiirene
andcommitted
Update documentation for Canvas mode
Co-authored-by: huangyiirene <[email protected]>
1 parent 39b03a1 commit b5ad57c

File tree

1 file changed

+77
-11
lines changed

1 file changed

+77
-11
lines changed

packages/designer/SPECIALIZED_DESIGNERS.md

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Specialized Designers
22

3-
Object UI Designer now supports three specialized designer modes, each optimized for specific use cases:
3+
Object UI Designer now supports **four** specialized designer modes, each optimized for specific use cases:
44

55
## 🎯 Designer Modes
66

@@ -132,6 +132,65 @@ function App() {
132132
All components from the component registry, including:
133133
- Layout, Form, Data Display, Feedback, Overlay, Navigation categories
134134

135+
### 4. Canvas Designer (`mode="canvas"`) 🆕
136+
137+
A free-form canvas designer with absolute positioning, similar to design tools like Figma.
138+
139+
**Features:**
140+
- Free-form positioning - drag components anywhere
141+
- Absolute coordinate system (x, y positioning)
142+
- Resize components freely
143+
- Grid snapping for alignment (configurable)
144+
- Visual grid background
145+
- Works like a traditional design canvas
146+
147+
**Usage:**
148+
```tsx
149+
import { Designer } from '@object-ui/designer';
150+
151+
function App() {
152+
return (
153+
<Designer
154+
mode="canvas"
155+
initialSchema={{
156+
type: 'div',
157+
className: 'relative',
158+
style: { width: '100%', height: '100%', minHeight: '600px' },
159+
body: []
160+
}}
161+
/>
162+
);
163+
}
164+
```
165+
166+
Or use the dedicated component:
167+
```tsx
168+
import { CanvasDesigner } from '@object-ui/designer';
169+
170+
function App() {
171+
return (
172+
<CanvasDesigner
173+
config={{
174+
showGrid: true,
175+
gridSize: 20,
176+
canvasBackground: '#ffffff'
177+
}}
178+
/>
179+
);
180+
}
181+
```
182+
183+
**Available Components:**
184+
- **Basic**: div, card, text, button, image
185+
- **Form**: input, textarea, select, checkbox, switch
186+
- **Layout**: stack, grid
187+
- **Display**: badge, avatar, separator
188+
189+
**Configuration Options:**
190+
- `showGrid`: Show/hide alignment grid (default: true)
191+
- `gridSize`: Grid snap size in pixels (default: 20)
192+
- `canvasBackground`: Canvas background color (default: '#ffffff')
193+
135194
## 🔄 Migration Guide
136195

137196
### From Previous Version
@@ -149,6 +208,7 @@ import { Designer } from '@object-ui/designer';
149208
// New - specialized modes
150209
<Designer mode="form" initialSchema={schema} />
151210
<Designer mode="layout" initialSchema={schema} />
211+
<Designer mode="canvas" initialSchema={schema} /> // 🆕 NEW!
152212
```
153213

154214
All existing code will continue to work without changes. The default mode is `'general'`, which provides the same functionality as before.
@@ -189,31 +249,37 @@ function CustomDesigner() {
189249

190250
## 📋 Component Comparison
191251

192-
| Feature | Form Designer | Layout Designer | General Designer |
193-
|---------|--------------|----------------|------------------|
194-
| Form Components | ✅ Primary | ⚠️ Limited | ✅ Full |
195-
| Layout Components | ⚠️ Limited | ✅ Primary | ✅ Full |
196-
| Navigation | ❌ None | ✅ Full | ✅ Full |
197-
| Data Display | ⚠️ Basic | ⚠️ Basic | ✅ Full |
198-
| Feedback/Overlay | ❌ None | ❌ None | ✅ Full |
199-
| Component Count | ~15 | ~15 | ~30+ |
200-
| Complexity | Low | Medium | High |
201-
| Use Case | Forms Only | Page Layouts | Everything |
252+
| Feature | Form Designer | Layout Designer | Canvas Designer 🆕 | General Designer |
253+
|---------|--------------|-----------------|-------------------|------------------|
254+
| Form Components | ✅ Primary | ⚠️ Limited | ✅ Full | ✅ Full |
255+
| Layout Components | ⚠️ Limited | ✅ Primary | ⚠️ Limited | ✅ Full |
256+
| Navigation | ❌ None | ✅ Full | ❌ None | ✅ Full |
257+
| Data Display | ⚠️ Basic | ⚠️ Basic | ⚠️ Basic | ✅ Full |
258+
| Feedback/Overlay | ❌ None | ❌ None | ❌ None | ✅ Full |
259+
| **Positioning** | **Tree** | **Tree** | **Absolute (x,y)** | **Tree** |
260+
| **Grid Snap** | **** | **** | **✅ Yes** | **** |
261+
| Component Count | ~15 | ~15 | ~15 | ~30+ |
262+
| Complexity | Low | Medium | Medium | High |
263+
| Use Case | Forms Only | Page Layouts | Free-form Design | Everything |
202264

203265
## 🚀 Best Practices
204266

205267
1. **Choose the Right Mode**: Use specialized designers when you know your use case:
206268
- Building a form? Use `mode="form"`
207269
- Designing a page structure? Use `mode="layout"`
270+
- Creating mockups or free-form designs? Use `mode="canvas"` 🆕
208271
- Need everything? Use `mode="general"` or omit the prop
209272

210273
2. **Start Specialized, Upgrade Later**: Begin with a specialized designer for focused work, then export the schema and open it in the general designer if you need additional components.
211274

212275
3. **Component Filtering**: The specialized designers limit available components to reduce cognitive load and improve the design experience for specific tasks.
213276

277+
4. **Canvas Mode for Prototyping**: Use canvas mode when you need pixel-perfect positioning or are creating mockups that don't follow typical web layout patterns. 🆕
278+
214279
## 📝 Examples
215280

216281
See the `examples/` directory for complete working examples:
282+
- `examples/designer-modes/` - Interactive demo with all 4 modes 🆕
217283
- `examples/form-designer/` - Form builder example
218284
- `examples/layout-designer/` - Page layout example
219285
- `examples/general-designer/` - General purpose example

0 commit comments

Comments
 (0)