办公效率
Figma与React组件映射代码
提供Figma组件标识和React组件路径,生成连接变体与代码属性的Code Connect文件。
# 为 React 组件生成 Figma Code Connect
## 何时使用此 Skill
用户提供 Figma 组件 URL(或组件名称),并希望为其生成 Code Connect 映射。
## 必需输入
1. **Figma 组件标识符**(以下任意一种):
- 完整 URL:`https://figma.com/design/{fileKey}/{fileName}?node-id={nodeId}`
- 文件 key + node ID:`fileKey: abc123, nodeId: 45:67`
- 证据文件路径:`.temp/figma-explore/{component}.json`
- 组件名称(将在项目文件中搜索 URL)
2. **代码组件文件夹路径**(例如 `src/components/Button/Button.tsx`)
## 执行步骤
### 1. 收集 Figma 组件数据
**选项 A:已提供证据文件(首选)**
如果提供了来自 `figma-explore` 的证据文件(例如 `.temp/figma-explore/{component}.json`):
- 直接读取 JSON 文件
- 提取:`id`(node ID)、`name`、`variants`、`variantProperties`、`componentPropertyDefinitions`
- 该文件包含 Code Connect 所需的全部变体名称和值
证据文件结构示例:
```json
{
"id": "16:1234",
"name": "Button",
"type": "COMPONENT_SET",
"variants": [
{ "name": "Type=Primary, Size=Small", "id": "16:1235" },
{ "name": "Type=Primary, Size=Large", "id": "16:1236" }
],
"variantProperties": {
"Type": ["Primary", "Secondary", "Ghost"],
"Size": ["Small", "Medium", "Large"]
},
"componentPropertyDefinitions": {
"Label": { "type": "TEXT", "defaultValue": "Button" },
"Show Icon": { "type": "BOOLEAN", "defaultValue": false }
}
}
```
**选项 B:已提供 URL/Node ID(MCP 备用方案)**
如果只提供了 Figma URL 或 node ID:
1. 在 `.temp/figma-explore/` 中**搜索与组件名称匹配的现有证据文件**
2. **如果未找到,使用 MCP 工具**:
- 使用 `nodeId` 和 `fileKey` 调用 `mcp_figma_get_metadata`
- 使用 `nodeId` 和 `fileKey` 调用 `mcp_figma_get_design_context`
### 2. 查找 Figma URL(如有需要)
如果未提供 URL 或证据文件,请搜索:
1. 检查 `{ComponentFolder}/README.md` 中的 "Figma Source" 部分
2. 检查 `specs/**/tasks.md` 中的组件到 Figma 映射表
3. 检查 `.temp/figma-explore/figma-components-index.json` 中是否有匹配的组件名称
4. 检查先前的对话上下文,查找文件 key
### 3. 读取代码组件并将映射约定内联到上下文中
1. 读取指定的组件文件,识别导出项、props 接口和组件名称
2. **如果 `.temp/design-components/{component-name}/proposed-api.md` 存在,读取该文件并将 prop 到 Figma 的映射表内联到工作上下文中。** 生成时不要通过路径引用此文件——完整映射必须位于当前上下文中,以免猜测或遗漏任何属性。
3. 交叉检查:React 接口中的每个 prop 都应在表中有对应的 Figma 来源。没有 Figma 来源的 props(例如 `className`、`id`)应从 Code Connect 中省略。
### 4. 生成映射
- 使用 `figma.*` 辅助函数将 Figma 属性映射到代码 props
- 构建 JSX 示例模板
- 添加适当的导入
### 5. 编写 Code Connect 文件
- 输出至:`{ComponentFolder}/{ComponentName}.figma.tsx`
- 只输出原始文件内容,不要使用 Markdown 代码围栏
### 6. 在 README 中更新映射图
如果 `{ComponentFolder}/README.md` 存在,确保它包含一个 **Design-to-Code Mapping** 部分,并在该部分顶部放置一个 mermaid 流程图,展示 Figma 到 React 的属性关系。
**图表格式:**
```mermaid
flowchart LR
subgraph Figma["Figma Variants"]
FProp1["PropertyName1"]
FProp2["PropertyName2"]
end
subgraph React["React Props"]
RProp1["propName1"]
RProp2["propName2"]
end
FProp1 -->|"Value1 → 'code1'
Value2 → 'code2'"| RProp1
FProp2 -->|"mapping description"| RProp2
style Figma fill:#f3e8ff,stroke:#9333ea
style React fill:#dbeafe,stroke:#3b82f6
```
**放置位置:** mermaid 图应紧跟在 `## Design-to-Code Mapping` 标题之后,位于所有表格之前。
**README 结构示例:**
```markdown
## Design-to-Code Mapping
```mermaid
flowchart LR
subgraph Figma["Figma Variants"]
FSize["Size"]
FType["Type"]
end
subgraph React["React Props"]
RSize["size"]
RVariant["variant"]
end
FSize -->|"Small → 'sm'
Medium → 'md'
Large → 'lg'"| RSize
FType -->|"Primary → 'primary'
Secondary → 'secondary'"| RVariant
style Figma fill:#f3e8ff,stroke:#9333ea
style React fill:#dbeafe,stroke:#3b82f6
` ` `
### Variant Mappings
| Figma Variant | Figma Value | React Prop | React Value |
...
```
**图表规则:**
- 包含所有已映射的变体属性(来自 `figma.enum()` calls)
- Include boolean properties that map to React props
- Show value transformations on the arrows (e.g., `"Small → 'sm'"`)
- Use `
` for multiple value mappings on one arrow
- Exclude pseudo-states (hover, focus, pressed) from the diagram
- Use purple styling for Figma subgraph, blue for React subgraph
## Rules
### Use Exact Figma Property Names
**Critical:** Code Connect requires the EXACT property names as they appear in Figma.
- Get exact names from evidence files (`.figma-components/*.json`) or `get_metadata` output
- Property names like `ButtonType`, `Type`, `Size` must match EXACTLY (case-sensitive)
- The `get_design_context` MCP tool normalizes to camelCase - **do NOT use those names**
- Property names are case-sensitive: `Size` ≠ `size`
元数据示例:
```
name="ButtonType=Responsive, Type=Primary, Size=Small"
```
在 Code Connect 中使用:
```tsx
variant: { ButtonType: 'Responsive' }, // ✅ Exact match
props: {
size: figma.enum('Size', { ... }), // ✅ Exact match
variant: figma.enum('Type', { ... }), // ✅ Exact match
}
```
### 只使用真实存在的 Figma 属性
根据 Figma 中实际存在的内容进行映射:
- **组件属性** → `figma.boolean()`, `figma.string()`, `figma.instance()`
- **Variant properties** → `figma.enum()`
- **Text layers** → `figma.textContent('LayerName')`
- **Nested instances** → `figma.children('LayerName')` or `figma.children('*')`
- **Child component props** → `figma.nestedProps('LayerName', { ... })`
**Never invent properties that don't exist in Figma.**
### Value Conventions
- Drop pseudo-state variants: `hover`, `pressed`, `focused`, `state`, `interaction`
- Map Figma Title Case to code: `Primary` → `'primary'`, `Small` → `'sm'`
- Normalize boolean variants: "Yes"/"No", "True"/"False", "On"/"Off" → `true`/`false`
### 关键限制:禁止使用 JavaScript 表达式
Code Connect 代码片段是 **字符串,不是可执行代码**。
**绝不要使用:**
```tsx
{hasIcon && <Icon />}
{disabled ? 'disabled' : ''}
{icon || <Fallback />}
```
**改用映射对象:**
```tsx
figma.boolean('Has Icon', {
true: <Icon />,
false: undefined
})
```
## API 参考
### 基础辅助函数
```tsx
// String property
figma.string('Label')
// Boolean property (simple)
figma.boolean('Disabled')
// Boolean with mapping
figma.boolean('Has Icon', {
true: <Icon />,
false: undefined
})
// Conditional string based on boolean
figma.boolean('Has label', {
true: figma.string('Label'),
false: undefined
})
// Enum/Variant property
figma.enum('Size', {
'Small': 'sm',
'Medium': 'md',
'Large': 'lg'
})
// Text content from a layer
figma.textContent('Button Label')
// Instance swap property (nested component)
figma.instance('Icon')
// Child instances by layer name
figma.children('Tab')
figma.children(['Tab 1', 'Tab 2'])
figma.children('Icon*') // wildcard
figma.children('*') // all children
```
### 高级辅助函数
```tsx
// Nested props - access child component's properties on parent
figma.nestedProps('Button Shape', {
size: figma.enum('Size', { ... })
})
// className builder
figma.className([
'btn-base',
figma.enum('Size', { 'Large': 'btn-large' }),
figma.boolean('Disabled', { true: 'btn-disabled', false: '' })
])
// Instance with type inference
figma.instance<React.FunctionComponent>('Icon') // Returns component type
figma.instance<string>('Icon') // Returns string ID
// Access nested instance props in parent
figma.instance('Icon').getProps<{ iconId: string, size: 'sm' | 'lg' }>()
// Custom render for nested instance
figma.instance('Icon').render<{ id: string }>(props => <CustomIcon id={props.id} />)
```
### 变体限制
仅当不同的 Figma 变体映射到完全不同的 React 组件时,才使用此模式。如果所有变体都通过不同的 props 映射到同一个 React 组件,请使用单个 `figma.connect()`:
```tsx
figma.connect(PrimaryButton, 'https://...', {
variant: { Type: 'Primary' },
example: () => <PrimaryButton />
})
figma.connect(SecondaryButton, 'https://...', {
variant: { Type: 'Secondary' },
example: () => <SecondaryButton />
})
// Boolean variant restriction
figma.connect(IconButton, 'https://...', {
variant: { 'Has Icon': true },
example: () => <IconButton />
})
// Multiple variant combination
figma.connect(DangerButton, 'https://...', {
variant: { Type: 'Danger', Disabled: true },
example: () => <DangerButton />
})
```
## 完整示例
```tsx
import figma from '@figma/code-connect'
import { Button } from './Button'
figma.connect(Button, 'https://figma.com/design/abc123/File?node-id=1:2', {
props: {
variant: figma.enum('Variant', {
Primary: 'primary',
Secondary: 'secondary'
}),
size: figma.enum('Size', {
Small: 'sm',
Medium: 'md',
Large: 'lg'
}),
disabled: figma.boolean('Disabled'),
label: figma.textContent('Label'),
icon: figma.boolean('Has Icon', {
true: figma.instance('Icon'),
false: undefined
})
},
example: ({ variant, size, disabled, label, icon }) => (
<Button variant={variant} size={size} disabled={disabled} icon={icon}>
{label}
</Button>
)
})
```
## 图标连接模式
### 将图标作为 JSX 元素
```tsx
// Icon component
figma.connect('https://...icon-url...', {
example: () => <IconHeart />
})
// Parent using the icon
figma.connect(Button, 'https://...button-url...', {
props: {
icon: figma.instance('Icon')
},
example: ({ icon }) => <Button>{icon}</Button>
})
// Renders: <Button><IconHeart/></Button>
```
### 将图标作为 React 组件
```tsx
// Icon returns component reference (not JSX)
figma.connect('https://...icon-url...', {
example: () => IconHeart // No angle brackets
})
// Parent receives component type
figma.connect(Button, 'https://...', {
props: {
Icon: figma.instance<React.FunctionComponent>('Icon')
},
example: ({ Icon }) => <Button Icon={Icon} />
})
// Renders: <Button Icon={IconHeart} />
```
### 将图标作为字符串 ID
```tsx
// Icon returns string ID
figma.connect('https://...icon-url...', {
example: () => 'icon-heart'
})
// Parent uses string
figma.connect(Button, 'https://...', {
props: {
iconId: figma.instance<string>('Icon')
},
example: ({ iconId }) => <Button iconId={iconId} />
})
// Renders: <Button iconId="icon-heart" />
```
## 禁止事项
以下错误会导致 Code Connect 文件静默失败或发布错误的映射:
- **不要使用 `get_design_context` property names.** MCP normalizes them to camelCase. The actual Figma property names are Title Case with spaces (e.g., `Has Icon`, `ButtonType`, `Size`). Use `get_metadata` output or the raw variant names from evidence files.
- **Don't invent properties that don't exist in Figma.** If `proposed-api.md` lists a prop like `className` that has no Figma source, omit it from Code Connect entirely.
- **Don't use JavaScript expressions in example templates.** `{hasIcon && <Icon />}` is invalid — Code Connect snippets are static strings. Use `figma.boolean('Has Icon', { true: <Icon />, false: undefined })` instead.
- **Don't skip the `tsc --noEmit` check.** Run it after writing the `.figma.tsx` file. A type error in the Code Connect file will break the publish step.
- **Don't map pseudo-states.** `hover`, `focus`, `pressed`, `active` Figma variants have no corresponding props — exclude them from all `figma.enum()` and `figma.boolean()` calls.
- **Don't reference `proposed-api.md` by path during generation.** The mapping contract must be inlined into your working context in Step 3. Reaching back to re-read it mid-generation means the context wasn't loaded correctly.
## Output
Write raw file content only—no markdown fences, no explanations.
**File location:** `{ComponentFolder}/{ComponentName}.figma.tsx`
Example: `src/components/inline-edit/EditableText/EditableText.figma.tsx`
File must be immediately usable with `npx @figma/code-connect connect publish`。同类提示词
办公效率· n8n 工作流的对话模型
商品照片转棚拍广告生图指令
上传商品照片并提供说明文字,分析材质、配色和原图问题,写出保留商品外观的棚拍广告生图指令。
=你是一位专业产品摄影师和广告创意总监。分析上传的产品图片及其配文:{{ $('Telegram Trigger Received').item.json.message.caption }} 你的任务是创建一段详细的图像生成提示词,将这张产品照片转化为高端、商业级的广告视觉作品。 分析要求: 1. **产品识别**:识别产品类型、尺寸、类别、材质、配色和关键特征 2. **当前状态评估**:指出当前的光线、背景、构图和质量问题 3. **目标美学**:根据产品类别确定理想的广告风格(奢侈品、科技、食品、时尚等) 输出(严格使用 JSON 格式):办公效率· n8n 工作流的对话模型
Veo 3营销视频分镜指令
填写视频需求、营销目标、图像描述和画幅,生成包含场景、运镜、动作、灯光与结尾的结构化制片指令。
=# Veo3 视频生成系统提示词 你是一名专业的视频提示词工程师,擅长为 Veo3 视频生成撰写细致、富有电影感的提示词。你的角色是分析用户输入,将其转化为全面的视频生成指令,以产出高质量、引人入胜的内容。 ## 输入分析 你将收到以下用户输入: - **AI Videos instructions**:视频生成的核心用户请求 - **Campaign objectives**:营销活动目标和说明 - **Images Description**:用户提供的视觉背景信息 - **Aspect Ratio**:要求的视频尺寸比例 ## 输出格式 你
可填 21 项
办公效率· n8n 工作流的对话模型
保留原品的社媒广告视觉方案
提供商品图和配文,生成保留原品外观的广告生图说明,广告文字仅从配文提取,缺项留空。
={ "system_prompt": "你是一位顶尖创意总监,专攻爆款产品广告,拥有15年以上奢侈品牌广告活动经验。将产品图片转化为商业级广告,让浏览者停下滑动并促进转化。", "instructions": { "core_rules": [ "保持原始产品100%不变——不得修改、替换或扭曲", "只提取和使用用户配文中提供的文字", "如果配文中没有相关文字,文字字段留空——绝不生成AI广告语", "专注于高端视觉强化和商业摄影技巧", "制作适合在Instagram展办公效率· Claude Fable 5.2
用代码制作长纪录片流程
从题材调研、脚本和样帧审核开始,按章节生成三维分镜、旁白、环境声与可复现渲染。
<inputs> 向我询问: 1. 我的主题 2. 目标视频时长 3. 我是否已有脚本 如果我只给你一个主题,先研究该主题并撰写脚本。 开始制作任何内容之前,先向我展示: - 完整脚本 - 章节拆分 - 前 60 seconds 的分镜计划 - 6 张展示预期视觉方向的静帧 在我认可视觉效果之前,不要渲染完整视频。 </inputs> <story> 按照高品质 YouTube 纪录片的方式来写,不要写成 AI 科普解说。 故事必须始终向前推进。 每个部分都需要包含以下内容之一: - 一个新问题 - 一个揭示 - 一个矛盾 - 一个后果 - 一条证据
办公效率
同场景表情变化九宫格自拍
上传主角照片,可选搭档参考图或设定,并填写服装、背景或姿势偏好,生成同一布光和构图的九张变化。
# photo-booth ## 何时使用此 skill - 当用户希望根据参考图制作大头贴宫格、表情宫格、情侣自拍宫格、同步姿势组图或多种人像变体时使用。 - 当请求制作 3x3 宫格,且主体、房间、服装、构图和布光保持一致,仅表情或细微姿势发生变化时触发。 ## 必需输入 - 主要人物的主参考图。 - 可选的伴侣或角色参考图。 - 如果未提供伴侣参考图,需提供期望的伴侣设定。 - 用户指定的服装、背景、摄影时代、姿势清单或氛围。 如果缺少主参考图,请用户附上。如果伴侣设定或预期风格不明确,提出一个有针对性的问题。 ## 连续性规则 -
需参考图
办公效率· Claude Code / 动效编程
单镜头立体落地页飞越动画
提供落地页链接、品牌名、标志和两段收尾文案,可选配乐,制作卡片随镜头掠过而浮起的连续飞越短片。
<inputs> 向我索取:我的落地页链接、品牌名称和标志、由两部分组成的结尾文案(一句陈述,后接一小段斜体文字),以及一条 15 second 音轨(可选)。 </inputs> <direction> 以 60fps 对我的落地页进行 14.5 second 3D 飞越拍摄,1440x1152。页面平放在明亮的摄影棚地面上(中央为 #f9fbfb,角落为 #f2f3f6),周围有柔和宽阔的阴影,圆角为 24px。全程使用一个连续镜头,绝不切镜:镜头从首屏上方低处开始,以恒定速度沿页面向后滑行,同时朝页面上方看去;然后垂直升至正上方,将整个页面呈现为