Figma Code Connect (OceanBase Design)
When to use this skill
- User asks to update / fix / add Code Connect for a component (e.g. "同步 Alert 的 Figma 映射").
- Figma component properties changed (new variant, renamed layer).
- New in-scope component needs its first
index.figma.tsx.
Do not bulk-rewrite all 38 mappings unless explicitly asked. One component per task (incremental).
Source of truth
| Path | Role |
|---|---|
packages/design/src/<dir>/index.figma.tsx |
design 组件映射(直接编辑、Git 入库) |
packages/ui/src/<Name>/index.figma.tsx |
ui 组件映射 |
figma.config.json |
include、paths、documentUrlSubstitutions |
references/CONVENTIONS.md |
映射写法与硬规则 |
There is no sources/ or generate step. Edit the colocated file in packages/.
Agent workflow (incremental update)
1. Scope one component
Identify target directory, e.g. alert → packages/design/src/alert/index.figma.tsx.
If the file exists, read it first and apply minimal diff. If missing, copy structure from a similar component (e.g. skeleton for simple, breadcrumb for multi-connect).
2. Gather context
| Need | Tool |
|---|---|
| OB component props | ob-design info <Component> or MCP ob_info |
| Figma property names / types | Figma MCP get_context_for_code_connect (see CONVENTIONS.md) |
| Existing patterns | Read sibling index.figma.tsx in repo |
| Draft scaffold | npx @figma/code-connect connect create "<figma-url>" --outFile ... (then refine) |
3. Edit mapping
- Import from
@oceanbase/design/@oceanbase/ui/@oceanbase/iconsonly. - Use
figma.connect(RealComponent, '<FIGMA_OCEANBASE_*>' | url, { props, example }). - New
<FIGMA_*>placeholder → add tofigma.config.jsondocumentUrlSubstitutions. - Follow CONVENTIONS.md (no style/className in mapping, Figma typo values, etc.).
4. Validate (single file first)
pnpm run figma:parse:file -- packages/design/src/alert/index.figma.tsx
Fix until exit code 0. Then optional full check:
pnpm run figma:parse
5. Config housekeeping (only if needed)
pnpm run figma:sync-include # after adding a new index.figma.tsx path
6. Publish (human / maintainer with token)
pnpm run figma:publish:dry-run
pnpm run figma:publish
Requires .cursor/skills/figma-code-connect/.env (FIGMA_ACCESS_TOKEN, FIGMA_FILE_KEY).
Commands (repo root)
pnpm run figma:sync-include
pnpm run figma:parse
pnpm run figma:publish:dry-run
pnpm run figma:publish
In-scope components (38)
design: alert, badge, breadcrumb, button, card, checkbox, date-picker, descriptions, divider, drawer, dropdown, empty, filter, form, input, input-number, menu, message, modal, notification, pagination, popconfirm, progress, radio, result, segmented, select, skeleton, spin, steps, switch, table, tabs, tag, tooltip, upload.
ui: FooterToolbar, PageContainer.
Out of scope: packages/icons icon matrix (separate effort).
Minimal example (single connect)
See packages/design/src/alert/index.figma.tsx:
figma.connect(Alert, '<FIGMA_OCEANBASE_ALERT>', {
props: {
type: figma.enum('type', {
info: 'info',
warning: 'warning',
success: 'success',
error: 'error',
}),
message: figma.textContent('Text'),
},
example: ({ type, message }) => <Alert type={type} message={message} />,
});
PR merge gate
- Only touched component(s)'
index.figma.tsx(+figma.config.jsonif placeholders changed). pnpm run figma:parsepasses.pnpm buildno regression.
Anti-patterns
- Editing all mappings in one PR without request.
- Copying from
antdCode Connect examples. - Putting layout/preview styles in
propsinstead of component API props. - Forgetting
documentUrlSubstitutionsfor new<FIGMA_*>keys. - Running
figma:publishwithout localfigma:parsesuccess.