Skip to content

feat: add template flows for common mobile app patterns#20

Merged
trmquang93 merged 2 commits intomainfrom
feat/template-flows
Apr 2, 2026
Merged

feat: add template flows for common mobile app patterns#20
trmquang93 merged 2 commits intomainfrom
feat/template-flows

Conversation

@trmquang93
Copy link
Copy Markdown
Collaborator

Summary

  • Add 6 pre-built flow templates (Authentication, Onboarding, Settings, Tab Bar App, E-Commerce, Social Feed) that users can insert onto the canvas to eliminate cold-start
  • Each template includes SVG wireframe screens, hotspots with configured actions/API endpoints, and connections between screens
  • Template browser modal accessible via toolbar button, file menu ("New from Template"), empty state button, or T keyboard shortcut
  • Templates are code-split via dynamic import() and IDs are regenerated on insert to prevent conflicts

New files

  • src/templates/ -- 6 template data files + wireframe SVG generator + registry index
  • src/utils/mergeFlowAtPosition.js -- Centers template at viewport position, delegates to mergeFlow() for ID remapping
  • src/hooks/useTemplateInserter.js -- Computes viewport center and inserts template data
  • src/components/TemplateBrowserModal.jsx -- Modal with 2-column grid of template cards

Modified files

  • Drawd.jsx, ModalsLayer.jsx, CanvasArea.jsx, TopBar.jsx, ToolBar.jsx -- Wire up template state and callbacks
  • EmptyState.jsx -- Add interactive "Start from Template" button
  • useKeyboardShortcuts.js, ShortcutsPanel.jsx -- Add T shortcut
  • userGuide.md -- Document template flows feature

Test plan

  • 316 tests pass (24 new: 8 for mergeFlowAtPosition, 16 for template data validation)
  • Lint clean, production build succeeds
  • Open empty canvas -- "Start from Template" button appears
  • Click template button -- modal shows 6 templates in 2-column grid
  • Select a template -- screens, connections, hotspots appear centered on canvas
  • Insert template on non-empty canvas -- no overlap with existing screens
  • Press T -- template browser opens
  • Undo after insert -- all template screens removed
  • File menu > "New from Template" works

Pre-built flow templates (Auth, Onboarding, Settings, Tab Bar, E-Commerce,
Social Feed) that users can insert onto the canvas to eliminate cold-start.
Each template includes wireframe screen images, hotspots with configured
actions/API endpoints, and connections between screens. Templates are
code-split via dynamic imports and IDs are regenerated on insert to
prevent conflicts.
- Extract makeHotspot() factory to eliminate boilerplate across templates
- Use MERGE_GAP from constants instead of local SCREEN_GAP
- Deduplicate TemplateIcon (shared component with size/stroke props)
- Remove unnecessary useState for hover (use direct style mutation)
- Fix setLoading not reset on success path in TemplateBrowserModal
- Remove unnecessary async from insertTemplate
- Replace magic 390 with derived SCREEN_HEIGHT_ESTIMATE constant
- Import theme colors in wireframe.js instead of hardcoding
@trmquang93 trmquang93 merged commit d052773 into main Apr 2, 2026
1 check passed
@github-actions github-actions bot deleted the feat/template-flows branch April 2, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant