Extract a target component from a Figma page, analyze variant dimensions, and generate a
production-ready ComponentSet. Prioritize reusing existing page content over redrawing.
/make-variants 按钮
/make-variants 输入框 fileKey=abc123 nodeId=12:34
/make-variants 标签 页面有三种尺寸:small/medium/large,两种类型:填充/描边
/make-variants 全局提示 根据 oneid-design-system.md 设计系统规范延展变体状态
Extract from $ARGUMENTS:
| Parameter | Required | Description |
|---|---|---|
| ----------- | ---------- | ------------- |
| Component name | Yes | e.g., "按钮", "输入框" |
fileKey | No | From Figma URL |
nodeId | No | Target reference node |
| Variant description | No | Known variant dimensions |
| Design system | No | Specific design system to follow |
| Component library | No | Figma component library to reference |
> This is the most critical step. Execute all sub-steps in parallel.
get_screenshot)Capture the target node or current page. While reviewing, identify:
use_figma)Run scripts/scan_page.js (replace __TARGET_NODE_ID__ and __COMPONENT_NAME__ with actual values).
This returns:
target — matched node info with children detailsicons — up to 30 reusable icon candidates on the pagetextIcons — suspected text characters masquerading as icons (⚠️ must be replaced)search_design_system)Search for the component name and any icon names referenced.
If the page contains an existing built version of the target component (COMPONENT or FRAME):
> Clone the entire node. Do not redraw any elements. Preserve the cloned node's color token
> references, and apply the same design system's color tokens when generating variants.
// ✅ Clone existing, modify only variant-specific properties
const source = figma.getNodeById('SOURCE_NODE_ID');
const cloned = source.clone();
// Modify only: background, text color, icon color, opacity for state differences
// Prefer design system token values for all colors
Applicable when:
If textIcons were detected in Step 1b, replace them before proceeding.
Consult references/icon-resolution-strategy.md for the full priority-based resolution process:
scripts/find_real_icon.jsimportComponentByKeyAsynccreateNodeFromSvg (must match observed visual style)Absolute prohibitions: No Unicode characters, emoji, color blocks, or invented icon styles as substitutes.
Determine variant dimensions from screenshot observations and argument descriptions.
Consult references/design-tokens.md for:
Naming rule: DimensionA=Value, DimensionB=Value — comma-separated, PascalCase, all dimensions present in every variant name.
Minimum variant set: Prioritize commonly used state combinations; typically 8–16 variants.
Use scripts/generate_component_set.js as the template. Customize variantDefs array and source node ID before execution.
Critical constraints:
createComponent() + combineAsVariants() — never createFrame()async function main() with try/catch, end with return main()For common errors, consult references/troubleshooting.md.
After generating the ComponentSet:
combineAsVariants may add unexpected prefixes; correct by indexr:0.898, g:0.910, b:0.937), cornerRadius: 8figma.viewport.scrollAndZoomIntoView([compSet]), then take a screenshot to compare with the originalBefore presenting the output, verify:
scripts/)| Script | Purpose |
|---|---|
| -------- | --------- |
scan_page.js | Scan page for target component, icon candidates, and text-icon traps |
find_real_icon.js | Locate real icon replacements using priority-based strategy |
generate_component_set.js | Template for creating ComponentSet via clone + combineAsVariants |
references/)| File | Content |
|---|---|
| ------ | --------- |
design-tokens.md | Design system tokens, variant dimensions, naming conventions |
icon-resolution-strategy.md | Full icon detection and replacement priority chain |
troubleshooting.md | Common Figma plugin crashes, causes, and fixes |
共 1 个版本