figma-driven-nextjs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Figma-Driven Next.js 开发技能

Figma-Driven Next.js Development Skill

基于 Figma 设计驱动的 Next.js 开发技能,结合
vercel-react-best-practices
web-design-guidelines
技能,以 Figma 设计文件为核心设计来源。

This is a Figma-driven Next.js development skill, combining the
vercel-react-best-practices
and
web-design-guidelines
skills, with Figma design files as the core design source.

技术栈

Tech Stack

类别技术选型
前端框架Next.js (App Router)
后端服务Supabase
样式方案Tailwind CSS
图标库Lucide (https://lucide.dev/)
动画库Motion (https://motion.dev/)
工作流Figma MCP → Trae IDE

CategoryTechnology Selection
Frontend FrameworkNext.js (App Router)
Backend ServiceSupabase
Styling SolutionTailwind CSS
Icon LibraryLucide (https://lucide.dev/)
Animation LibraryMotion (https://motion.dev/)
WorkflowFigma MCP → Trae IDE

核心原则

Core Principles

Figma 优先

Figma First

所有设计决策以 Figma 文件为准,
vercel-react-best-practices
web-design-guidelines
作为代码质量和最佳实践的补充指导。

All design decisions are based on Figma files, with
vercel-react-best-practices
and
web-design-guidelines
serving as supplementary guidance for code quality and best practices.

设计令牌系统

Design Token System

1. 颜色规范

1. Color Specifications

来源: 严格遵循 Figma 文件中的颜色定义
实现: 创建统一的颜色令牌文件
/styles/tokens/colors.ts
Dark 模式:
  • 自动推导 Dark 模式颜色(基于 Figma 原始颜色智能生成)
  • 遵循 WCAG 对比度标准
  • 仅支持 Light/Dark 双主题,不支持多主题
颜色令牌结构:
typescript
// /styles/tokens/colors.ts
export const colors = {
  light: {
    primary: '#从Figma提取',
    secondary: '#从Figma提取',
    background: '#从Figma提取',
    foreground: '#从Figma提取',
    // ... 其他颜色
  },
  dark: {
    primary: '#自动推导',
    secondary: '#自动推导',
    background: '#自动推导',
    foreground: '#自动推导',
    // ... 自动生成
  }
}
Dark 模式推导规则:
  • 背景色:降低亮度,保持色相
  • 前景色:提高亮度,确保对比度 ≥ 4.5:1
  • 强调色:微调亮度,保持品牌识别度
  • 边框色:降低饱和度和亮度
Source: Strictly follow color definitions in Figma files
Implementation: Create a unified color token file
/styles/tokens/colors.ts
Dark Mode:
  • Automatically derive Dark mode colors (intelligently generated based on original Figma colors)
  • Comply with WCAG contrast standards
  • Only support Light/Dark dual themes, not multi-themes
Color Token Structure:
typescript
// /styles/tokens/colors.ts
export const colors = {
  light: {
    primary: '#Extracted from Figma',
    secondary: '#Extracted from Figma',
    background: '#Extracted from Figma',
    foreground: '#Extracted from Figma',
    // ... Other colors
  },
  dark: {
    primary: '#Automatically derived',
    secondary: '#Automatically derived',
    background: '#Automatically derived',
    foreground: '#Automatically derived',
    // ... Automatically generated
  }
}
Dark Mode Derivation Rules:
  • Background color: Reduce brightness, maintain hue
  • Foreground color: Increase brightness, ensure contrast ≥ 4.5:1
  • Accent color: Fine-tune brightness, maintain brand recognition
  • Border color: Reduce saturation and brightness

2. 字体规范

2. Typography Specifications

来源: 使用 Figma 文件中的字体规范
实现: 创建字体令牌文件
/styles/tokens/typography.ts
包含: 字体族、字号、字重、行高、字间距
typescript
// /styles/tokens/typography.ts
export const typography = {
  fontFamily: {
    sans: '从Figma提取',
    serif: '从Figma提取',
    mono: '从Figma提取',
  },
  fontSize: {
    xs: '从Figma提取',
    sm: '从Figma提取',
    base: '从Figma提取',
    lg: '从Figma提取',
    xl: '从Figma提取',
    '2xl': '从Figma提取',
    // ... 其他尺寸
  },
  fontWeight: {
    normal: 400,
    medium: 500,
    semibold: 600,
    bold: 700,
  },
  lineHeight: {
    tight: '从Figma提取',
    normal: '从Figma提取',
    relaxed: '从Figma提取',
  },
  letterSpacing: {
    tight: '从Figma提取',
    normal: '从Figma提取',
    wide: '从Figma提取',
  },
}
Source: Use typography specifications from Figma files
Implementation: Create a typography token file
/styles/tokens/typography.ts
Includes: Font family, font size, font weight, line height, letter spacing
typescript
// /styles/tokens/typography.ts
export const typography = {
  fontFamily: {
    sans: 'Extracted from Figma',
    serif: 'Extracted from Figma',
    mono: 'Extracted from Figma',
  },
  fontSize: {
    xs: 'Extracted from Figma',
    sm: 'Extracted from Figma',
    base: 'Extracted from Figma',
    lg: 'Extracted from Figma',
    xl: 'Extracted from Figma',
    '2xl': 'Extracted from Figma',
    // ... Other sizes
  },
  fontWeight: {
    normal: 400,
    medium: 500,
    semibold: 600,
    bold: 700,
  },
  lineHeight: {
    tight: 'Extracted from Figma',
    normal: 'Extracted from Figma',
    relaxed: 'Extracted from Figma',
  },
  letterSpacing: {
    tight: 'Extracted from Figma',
    normal: 'Extracted from Figma',
    wide: 'Extracted from Figma',
  },
}

3. 间距规范

3. Spacing Specifications

来源: 遵循 Figma 文件中的间距定义
实现: 创建间距令牌文件
/styles/tokens/spacing.ts
优化: 可进行合理优化,但需明确告知用户优化了什么及原因
typescript
// /styles/tokens/spacing.ts
export const spacing = {
  0: '0',
  1: '从Figma提取', // 如 4px
  2: '从Figma提取', // 如 8px
  3: '从Figma提取', // 如 12px
  4: '从Figma提取', // 如 16px
  // ... 其他间距
}
Source: Follow spacing definitions in Figma files
Implementation: Create a spacing token file
/styles/tokens/spacing.ts
Optimization: Reasonable optimization is allowed, but users must be informed of what was optimized and why
typescript
// /styles/tokens/spacing.ts
export const spacing = {
  0: '0',
  1: 'Extracted from Figma', // e.g. 4px
  2: 'Extracted from Figma', // e.g. 8px
  3: 'Extracted from Figma', // e.g. 12px
  4: 'Extracted from Figma', // e.g. 16px
  // ... Other spacing values
}

4. 阴影规范

4. Shadow Specifications

来源: 从 Figma 提取阴影效果
实现: 创建阴影令牌文件
/styles/tokens/shadows.ts
typescript
// /styles/tokens/shadows.ts
export const shadows = {
  sm: '从Figma提取',
  md: '从Figma提取',
  lg: '从Figma提取',
  xl: '从Figma提取',
}

Source: Extract shadow effects from Figma
Implementation: Create a shadow token file
/styles/tokens/shadows.ts
typescript
// /styles/tokens/shadows.ts
export const shadows = {
  sm: 'Extracted from Figma',
  md: 'Extracted from Figma',
  lg: 'Extracted from Figma',
  xl: 'Extracted from Figma',
}

布局规范

Layout Specifications

原则

Principles

响应式布局优先,自适应方法
Responsive layout first, adaptive approach

断点策略

Breakpoint Strategy

  • 优先: 根据 Figma 设计智能推荐断点
  • 备选: 使用行业标准断点(当 Figma 无明确断点时)
断点名称最小宽度用途
sm
640px手机横屏
md
768px平板竖屏
lg
1024px平板横屏/小笔记本
xl
1280px桌面显示器
2xl
1536px大屏显示器
  • Priority: Intelligently recommend breakpoints based on Figma designs
  • Alternative: Use industry-standard breakpoints when Figma has no clear breakpoints
Breakpoint NameMinimum WidthUsage
sm
640pxLandscape mobile
md
768pxPortrait tablet
lg
1024pxLandscape tablet/small laptop
xl
1280pxDesktop monitor
2xl
1536pxLarge screen monitor

自适应方法

Adaptive Methods

  • 使用 CSS Grid 和 Flexbox 实现自适应布局
  • 使用
    clamp()
    函数实现流体字体和间距
  • 使用容器查询(Container Queries)实现组件级响应式
  • 使用相对单位(rem、em、vw、vh、%)替代固定像素值
  • Use CSS Grid and Flexbox for adaptive layouts
  • Use
    clamp()
    function for fluid typography and spacing
  • Use Container Queries for component-level responsiveness
  • Use relative units (rem, em, vw, vh, %) instead of fixed pixel values

Figma 智能推荐规则

Figma Intelligent Recommendation Rules

  • 分析 Figma 中的 Auto Layout 设置
  • 根据 Figma 组件的约束(Constraints)推断响应式行为
  • 根据 Figma 变体(Variants)识别不同断点的设计

  • Analyze Auto Layout settings in Figma
  • Infer responsive behavior based on Figma component Constraints
  • Identify designs for different breakpoints based on Figma Variants

CSS 样式最佳实践

CSS Styling Best Practices

⚠️ 全局样式陷阱(重要)

⚠️ Global Style Pitfall (Important)

问题: 在
globals.css
中使用
*
选择器重置 margin/padding 会覆盖 Tailwind 工具类
错误示例:
css
/* ❌ 错误:会覆盖所有 Tailwind 的 p-*、m-*、gap-* 类 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
正确做法:
css
/* ✅ 正确:只设置 box-sizing,让 Tailwind 工具类正常工作 */
*,
*::before,
*::after {
  box-sizing: border-box;
}
原因: CSS 选择器优先级规则
  • *
    选择器优先级为 0
  • Tailwind 工具类(如
    .p-3
    )优先级也为 0(单个类)
  • 当优先级相同时,后定义的样式生效
  • 如果
    * { padding: 0 }
    在 Tailwind 之后加载,会覆盖工具类
Problem: Using
*
selector to reset margin/padding in
globals.css
will override Tailwind utility classes
Bad Example:
css
/* ❌ Wrong: Will override all Tailwind p-*, m-*, gap-* classes */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
Correct Approach:
css
/* ✅ Correct: Only set box-sizing, let Tailwind utility classes work normally */
*,
*::before,
*::after {
  box-sizing: border-box;
}
Reason: CSS selector priority rules
  • *
    selector has priority 0
  • Tailwind utility classes (e.g.,
    .p-3
    ) also have priority 0 (single class)
  • When priorities are the same, later-defined styles take effect
  • If
    * { padding: 0 }
    loads after Tailwind, it will override utility classes

globals.css 推荐结构

Recommended globals.css Structure

css
@import "tailwindcss";

:root {
  --background: #F5F5F5;
  --foreground: #1D2129;
  --surface: #FFFFFF;
  --border: #E5E6EB;
  
  --text-primary: #1D2129;
  --text-secondary: #4E5969;
  --text-tertiary: #86909C;
  
  --primary: #6242FD;
  --primary-hover: #5230E0;
}

.dark {
  --background: #0F172A;
  --foreground: #F9FAFB;
  /* ... dark mode variables */
}

/* ✅ 只设置 box-sizing,不重置 margin/padding */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  min-height: 100vh;
}
css
@import "tailwindcss";

:root {
  --background: #F5F5F5;
  --foreground: #1D2129;
  --surface: #FFFFFF;
  --border: #E5E6EB;
  
  --text-primary: #1D2129;
  --text-secondary: #4E5969;
  --text-tertiary: #86909C;
  
  --primary: #6242FD;
  --primary-hover: #5230E0;
}

.dark {
  --background: #0F172A;
  --foreground: #F9FAFB;
  /* ... dark mode variables */
}

/* ✅ Only set box-sizing, don't reset margin/padding */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  min-height: 100vh;
}

组件宽度与 Grid 布局

Component Width & Grid Layout

问题: 组件固定宽度与 Grid 容器列宽不匹配会导致溢出
错误示例:
tsx
// ❌ 错误:固定宽度可能超出 Grid 列宽
<div className="w-[218px] rounded-xl">

// Grid 容器
<div className="grid grid-cols-4 gap-4">
  {/* 每列实际宽度可能只有 200px */}
</div>
正确做法:
tsx
// ✅ 正确:使用 w-full 让组件自适应 Grid 列宽
<div className="w-full rounded-xl">

// Grid 容器
<div className="grid grid-cols-4 gap-4">
  {/* 组件会自动填满列宽 */}
</div>
Problem: Mismatch between fixed component width and Grid container column width causes overflow
Bad Example:
tsx
// ❌ Wrong: Fixed width may exceed Grid column width
<div className="w-[218px] rounded-xl">

// Grid container
<div className="grid grid-cols-4 gap-4">
  {/* Actual column width may only be 200px */}
</div>
Correct Approach:
tsx
// ✅ Correct: Use w-full to make component adapt to Grid column width
<div className="w-full rounded-xl">

// Grid container
<div className="grid grid-cols-4 gap-4">
  {/* Component will automatically fill the column width */}
</div>

间距调试清单

Spacing Debug Checklist

当遇到间距问题时,按以下顺序检查:
  1. 检查 globals.css: 确认没有
    * { margin: 0; padding: 0; }
  2. 检查 Tailwind 类: 确认
    p-*
    m-*
    gap-*
    space-*
    类是否生效
  3. 检查 Grid 布局: 确认组件宽度与 Grid 列宽匹配
  4. 检查父容器: 确认父容器的
    display
    gap
    padding
    设置
  5. 使用 DevTools: 检查计算后的样式值
When encountering spacing issues, check in the following order:
  1. Check globals.css: Confirm there's no
    * { margin: 0; padding: 0; }
  2. Check Tailwind classes: Confirm
    p-*
    ,
    m-*
    ,
    gap-*
    ,
    space-*
    classes are working
  3. Check Grid layout: Confirm component width matches Grid column width
  4. Check parent container: Confirm parent container's
    display
    ,
    gap
    ,
    padding
    settings
  5. Use DevTools: Check computed style values

Tailwind 间距类速查

Tailwind Spacing Class Quick Reference

类名说明
p-3
12pxpadding: 12px
px-3
12pxpadding-left/right: 12px
py-3
12pxpadding-top/bottom: 12px
m-3
12pxmargin: 12px
mb-3
12pxmargin-bottom: 12px
gap-3
12pxgap: 12px (Grid/Flex)
space-y-3
12px子元素间 margin-top

Class NameValueDescription
p-3
12pxpadding: 12px
px-3
12pxpadding-left/right: 12px
py-3
12pxpadding-top/bottom: 12px
m-3
12pxmargin: 12px
mb-3
12pxmargin-bottom: 12px
gap-3
12pxgap: 12px (Grid/Flex)
space-y-3
12pxmargin-top between child elements

组件库架构

Component Library Architecture

原子设计方法论

Atomic Design Methodology

/components
  /atoms          # 原子组件(Button, Input, Icon...)
  /molecules      # 分子组件(SearchBar, Card...)
  /organisms      # 有机体组件(Header, Footer...)
  /templates      # 模板组件
  /pages          # 页面组件
/components
  /atoms          # Atomic components (Button, Input, Icon...)
  /molecules      # Molecule components (SearchBar, Card...)
  /organisms      # Organism components (Header, Footer...)
  /templates      # Template components
  /pages          # Page components

组件文件结构

Component File Structure

/components
  /atoms
    /Button
      Button.tsx        # 组件实现
      Button.types.ts   # 类型定义
      index.ts          # 导出
/components
  /atoms
    /Button
      Button.tsx        # Component implementation
      Button.types.ts   # Type definitions
      index.ts          # Export

组件命名映射规则

Component Naming Mapping Rules

要求: 创建
/docs/component-mapping.md
文件
格式:
markdown
| Figma 组件名 | 代码组件名 | 文件路径 |
|-------------|-----------|---------|
| Button/Primary | Button | /components/atoms/Button |
| Button/Secondary | Button | /components/atoms/Button |
| Input/Text | Input | /components/atoms/Input |

Requirement: Create
/docs/component-mapping.md
file
Format:
markdown
| Figma Component Name | Code Component Name | File Path |
|-------------|-----------|---------|
| Button/Primary | Button | /components/atoms/Button |
| Button/Secondary | Button | /components/atoms/Button |
| Input/Text | Input | /components/atoms/Input |

图标处理

Icon Handling

图标来源

Icon Sources

  1. Figma 图标: 从 Figma 导出的自定义图标
  2. Lucide 图标库: https://lucide.dev/ 作为补充图标库
  1. Figma Icons: Custom icons exported from Figma
  2. Lucide Icon Library: https://lucide.dev/ as supplementary icon library

实现规范

Implementation Specifications

  • Figma 图标: SVG 组件化,存放于
    /components/icons/
  • Lucide 图标: 按需导入,Tree-shakable
  • 自定义能力: 支持尺寸、颜色、描边宽度自定义
  • Figma Icons: SVG componentization, stored in
    /components/icons/
  • Lucide Icons: Import on demand, Tree-shakable
  • Customization: Support custom size, color, stroke width

命名规范

Naming Specifications

  • Figma 导出:
    Icon[Name].tsx
  • Lucide 使用: 直接导入
    import { IconName } from 'lucide-react'
  • Figma exports:
    Icon[Name].tsx
  • Lucide usage: Direct import
    import { IconName } from 'lucide-react'

图标组件接口

Icon Component Interface

tsx
interface IconProps {
  size?: number
  color?: string
  strokeWidth?: number
  className?: string
}

tsx
interface IconProps {
  size?: number
  color?: string
  strokeWidth?: number
  className?: string
}

动画规范

Animation Specifications

动画库

Animation Library

Motion: https://motion.dev/ - 生产级动画库
Motion: https://motion.dev/ - Production-grade animation library

性能优化

Performance Optimization

  • 使用
    willChange
    提示浏览器优化
  • 优先使用
    transform
    属性
  • 避免动画布局属性(width, height, top, left)
  • Use
    willChange
    to hint browser for optimization
  • Prioritize using
    transform
    property
  • Avoid animating layout properties (width, height, top, left)

无障碍

Accessibility

支持
prefers-reduced-motion
媒体查询
Support
prefers-reduced-motion
media query

动画类型

Animation Types

  • 入场动画(Enter)
  • 退出动画(Exit)
  • 滚动动画(Scroll)
  • 手势动画(Gesture)
  • 布局动画(Layout)
  • Enter animations
  • Exit animations
  • Scroll animations
  • Gesture animations
  • Layout animations

Motion 使用示例

Motion Usage Example

tsx
import { motion, AnimatePresence } from 'motion/react'

<AnimatePresence>
  {isVisible && (
    <motion.div
      initial={{ opacity: 0, y: 20 }}
      animate={{ opacity: 1, y: 0 }}
      exit={{ opacity: 0, y: -20 }}
      transition={{ duration: 0.3 }}
      style={{ willChange: 'transform, opacity' }}
    />
  )}
</AnimatePresence>

tsx
import { motion, AnimatePresence } from 'motion/react'

<AnimatePresence>
  {isVisible && (
    <motion.div
      initial={{ opacity: 0, y: 20 }}
      animate={{ opacity: 1, y: 0 }}
      exit={{ opacity: 0, y: -20 }}
      transition={{ duration: 0.3 }}
      style={{ willChange: 'transform, opacity' }}
    />
  )}
</AnimatePresence>

主题切换机制

Theme Switching Mechanism

实现方式

Implementation

  • CSS 变量: 使用 CSS 自定义属性定义颜色
  • Tailwind Dark 模式:
    darkMode: 'class'
    配置
  • 切换方式: 系统偏好检测 + 手动切换
  • 持久化: localStorage 存储用户偏好
  • CSS Variables: Use CSS custom properties to define colors
  • Tailwind Dark Mode:
    darkMode: 'class'
    configuration
  • Switching Method: System preference detection + manual switch
  • Persistence: Store user preferences in localStorage

主题提供者

Theme Provider

tsx
// /components/ThemeProvider.tsx
'use client'
import { createContext, useContext, useEffect, useState } from 'react'

type Theme = 'light' | 'dark'
type ThemeContextType = {
  theme: Theme
  setTheme: (theme: Theme) => void
}

const ThemeContext = createContext<ThemeContextType | undefined>(undefined)

export function ThemeProvider({ children }: { children: React.ReactNode }) {
  const [theme, setTheme] = useState<Theme>('light')
  const [mounted, setMounted] = useState(false)

  useEffect(() => {
    setMounted(true)
    const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
    const savedTheme = localStorage.getItem('theme') as Theme | null
    setTheme(savedTheme || (prefersDark ? 'dark' : 'light'))
  }, [])

  useEffect(() => {
    if (mounted) {
      document.documentElement.classList.toggle('dark', theme === 'dark')
      localStorage.setItem('theme', theme)
    }
  }, [theme, mounted])

  if (!mounted) return null

  return (
    <ThemeContext.Provider value={{ theme, setTheme }}>
      {children}
    </ThemeContext.Provider>
  )
}

export const useTheme = () => {
  const context = useContext(ThemeContext)
  if (!context) throw new Error('useTheme must be used within ThemeProvider')
  return context
}

tsx
// /components/ThemeProvider.tsx
'use client'
import { createContext, useContext, useEffect, useState } from 'react'

type Theme = 'light' | 'dark'
type ThemeContextType = {
  theme: Theme
  setTheme: (theme: Theme) => void
}

const ThemeContext = createContext<ThemeContextType | undefined>(undefined)

export function ThemeProvider({ children }: { children: React.ReactNode }) {
  const [theme, setTheme] = useState<Theme>('light')
  const [mounted, setMounted] = useState(false)

  useEffect(() => {
    setMounted(true)
    const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
    const savedTheme = localStorage.getItem('theme') as Theme | null
    setTheme(savedTheme || (prefersDark ? 'dark' : 'light'))
  }, [])

  useEffect(() => {
    if (mounted) {
      document.documentElement.classList.toggle('dark', theme === 'dark')
      localStorage.setItem('theme', theme)
    }
  }, [theme, mounted])

  if (!mounted) return null

  return (
    <ThemeContext.Provider value={{ theme, setTheme }}>
      {children}
    </ThemeContext.Provider>
  )
}

export const useTheme = () => {
  const context = useContext(ThemeContext)
  if (!context) throw new Error('useTheme must be used within ThemeProvider')
  return context
}

无障碍规范

Accessibility Specifications

遵循
web-design-guidelines
技能中的无障碍规则:
类别要求
语义化 HTML使用正确的 HTML 元素
ARIA 属性必要时添加 aria-label、aria-describedby 等
键盘导航所有交互元素可通过键盘访问
焦点管理可见的焦点状态,使用 focus-visible
颜色对比度符合 WCAG AA 标准(4.5:1)

Follow accessibility rules in
web-design-guidelines
skill:
CategoryRequirements
Semantic HTMLUse correct HTML elements
ARIA AttributesAdd aria-label, aria-describedby, etc. when necessary
Keyboard NavigationAll interactive elements are accessible via keyboard
Focus ManagementVisible focus state, use focus-visible
Color ContrastMeet WCAG AA standard (4.5:1)

图片处理

Image Handling

  • 来源: Figma 中的图片资源
  • 实现:
    • 使用 Next.js
      <Image>
      组件
    • 自动优化和懒加载
    • 响应式图片
    • 提供 alt 文本

  • Source: Image resources from Figma
  • Implementation:
    • Use Next.js
      <Image>
      component
    • Automatic optimization and lazy loading
    • Responsive images
    • Provide alt text

代码风格

Code Style

类别规范
语言TypeScript(强类型定义)
组件文件PascalCase(如
Button.tsx
工具函数camelCase(如
formatDate.ts
常量UPPER_SNAKE_CASE(如
API_BASE_URL

CategorySpecifications
LanguageTypeScript (strongly typed definitions)
Component FilesPascalCase (e.g.,
Button.tsx
)
Utility FunctionscamelCase (e.g.,
formatDate.ts
)
ConstantsUPPER_SNAKE_CASE (e.g.,
API_BASE_URL
)

工作流程

Workflow

Figma 文件 (MCP)
  提取设计令牌
  (颜色、字体、间距、组件)
  生成设计系统文件
  (tokens/*.ts)
  创建组件映射文件
  (component-mapping.md)
  创建基础组件
  (基于 Figma 组件)
  应用最佳实践
  (vercel-react-best-practices)
  无障碍与 UX 审查
  (web-design-guidelines)
  完整页面实现

Figma File (MCP)
  Extract Design Tokens
  (Colors, Typography, Spacing, Components)
  Generate Design System Files
  (tokens/*.ts)
  Create Component Mapping File
  (component-mapping.md)
  Create Base Components
  (Based on Figma Components)
  Apply Best Practices
  (vercel-react-best-practices)
  Accessibility & UX Review
  (web-design-guidelines)
  Complete Page Implementation

输出文件清单

Output File Checklist

每次从 Figma 创建项目时,应输出以下文件:
  1. /styles/tokens/colors.ts
    - 颜色令牌(含 Light/Dark)
  2. /styles/tokens/typography.ts
    - 字体令牌
  3. /styles/tokens/spacing.ts
    - 间距令牌
  4. /styles/tokens/shadows.ts
    - 阴影令牌
  5. /styles/tokens/index.ts
    - 统一导出
  6. /styles/globals.css
    - 全局样式
  7. /docs/component-mapping.md
    - 组件命名映射规则
  8. /components/ThemeProvider.tsx
    - 主题提供者
  9. /tailwind.config.ts
    - Tailwind 配置(含设计令牌)

When creating a project from Figma each time, the following files should be output:
  1. /styles/tokens/colors.ts
    - Color tokens (including Light/Dark)
  2. /styles/tokens/typography.ts
    - Typography tokens
  3. /styles/tokens/spacing.ts
    - Spacing tokens
  4. /styles/tokens/shadows.ts
    - Shadow tokens
  5. /styles/tokens/index.ts
    - Unified export
  6. /styles/globals.css
    - Global styles
  7. /docs/component-mapping.md
    - Component naming mapping rules
  8. /components/ThemeProvider.tsx
    - Theme provider
  9. /tailwind.config.ts
    - Tailwind configuration (including design tokens)

触发条件

Trigger Conditions

当以下情况发生时,自动应用此技能:
  • 用户请求从 Figma 设计创建页面/组件
  • 用户提到 "根据 Figma..." 或 "按照设计稿..."
  • 用户提供 Figma 文件链接或 MCP 数据
  • 用户请求创建设计令牌

This skill is automatically applied when:
  • Users request to create pages/components from Figma designs
  • Users mention "based on Figma..." or "follow the design draft..."
  • Users provide Figma file links or MCP data
  • Users request to create design tokens

注意事项

Notes

  1. 颜色来源: 所有颜色必须从 Figma 提取,不使用技能内置颜色
  2. 间距优化: 如需优化间距,必须告知用户优化内容和原因
  3. Dark 模式: 即使 Figma 没有 Dark 模式设计,也必须自动生成
  4. 组件映射: 必须创建组件命名映射文件,保持 Figma 与代码的一致性
  5. 无障碍: 所有组件必须符合 WCAG AA 标准
  6. ⚠️ 全局样式: 绝对不要在 globals.css 中使用
    * { margin: 0; padding: 0; }
    ,这会覆盖所有 Tailwind 间距类
  7. 组件宽度: Grid 布局中的组件应使用
    w-full
    而非固定宽度,避免溢出问题
  1. Color Source: All colors must be extracted from Figma, do not use built-in colors from the skill
  2. Spacing Optimization: If spacing optimization is needed, users must be informed of what was optimized and why
  3. Dark Mode: Even if Figma has no Dark mode design, it must be automatically generated
  4. Component Mapping: Component naming mapping file must be created to maintain consistency between Figma and code
  5. Accessibility: All components must meet WCAG AA standards
  6. ⚠️ Global Styles: Never use
    * { margin: 0; padding: 0; }
    in globals.css, this will override all Tailwind spacing classes
  7. Component Width: Components in Grid layouts should use
    w-full
    instead of fixed widths to avoid overflow issues