figma-driven-nextjs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFigma-Driven Next.js 开发技能
Figma-Driven Next.js Development Skill
基于 Figma 设计驱动的 Next.js 开发技能,结合 和 技能,以 Figma 设计文件为核心设计来源。
vercel-react-best-practicesweb-design-guidelinesThis is a Figma-driven Next.js development skill, combining the and skills, with Figma design files as the core design source.
vercel-react-best-practicesweb-design-guidelines技术栈
Tech Stack
| 类别 | 技术选型 |
|---|---|
| 前端框架 | Next.js (App Router) |
| 后端服务 | Supabase |
| 样式方案 | Tailwind CSS |
| 图标库 | Lucide (https://lucide.dev/) |
| 动画库 | Motion (https://motion.dev/) |
| 工作流 | Figma MCP → Trae IDE |
| Category | Technology Selection |
|---|---|
| Frontend Framework | Next.js (App Router) |
| Backend Service | Supabase |
| Styling Solution | Tailwind CSS |
| Icon Library | Lucide (https://lucide.dev/) |
| Animation Library | Motion (https://motion.dev/) |
| Workflow | Figma MCP → Trae IDE |
核心原则
Core Principles
Figma 优先
Figma First
所有设计决策以 Figma 文件为准, 和 作为代码质量和最佳实践的补充指导。
vercel-react-best-practicesweb-design-guidelinesAll design decisions are based on Figma files, with and serving as supplementary guidance for code quality and best practices.
vercel-react-best-practicesweb-design-guidelines设计令牌系统
Design Token System
1. 颜色规范
1. Color Specifications
来源: 严格遵循 Figma 文件中的颜色定义
实现: 创建统一的颜色令牌文件
/styles/tokens/colors.tsDark 模式:
- 自动推导 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.tsDark 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.tsIncludes: 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.tsOptimization: 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.tstypescript
// /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.tstypescript
// /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 无明确断点时)
| 断点名称 | 最小宽度 | 用途 |
|---|---|---|
| 640px | 手机横屏 |
| 768px | 平板竖屏 |
| 1024px | 平板横屏/小笔记本 |
| 1280px | 桌面显示器 |
| 1536px | 大屏显示器 |
- Priority: Intelligently recommend breakpoints based on Figma designs
- Alternative: Use industry-standard breakpoints when Figma has no clear breakpoints
| Breakpoint Name | Minimum Width | Usage |
|---|---|---|
| 640px | Landscape mobile |
| 768px | Portrait tablet |
| 1024px | Landscape tablet/small laptop |
| 1280px | Desktop monitor |
| 1536px | Large screen monitor |
自适应方法
Adaptive Methods
- 使用 CSS Grid 和 Flexbox 实现自适应布局
- 使用 函数实现流体字体和间距
clamp() - 使用容器查询(Container Queries)实现组件级响应式
- 使用相对单位(rem、em、vw、vh、%)替代固定像素值
- Use CSS Grid and Flexbox for adaptive layouts
- Use function for fluid typography and spacing
clamp() - 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)
问题: 在 中使用 选择器重置 margin/padding 会覆盖 Tailwind 工具类
globals.css*错误示例:
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 工具类(如 )优先级也为 0(单个类)
.p-3 - 当优先级相同时,后定义的样式生效
- 如果 在 Tailwind 之后加载,会覆盖工具类
* { padding: 0 }
Problem: Using selector to reset margin/padding in will override Tailwind utility classes
*globals.cssBad 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., ) also have priority 0 (single class)
.p-3 - When priorities are the same, later-defined styles take effect
- If loads after Tailwind, it will override utility classes
* { padding: 0 }
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
当遇到间距问题时,按以下顺序检查:
- 检查 globals.css: 确认没有
* { margin: 0; padding: 0; } - 检查 Tailwind 类: 确认 、
p-*、m-*、gap-*类是否生效space-* - 检查 Grid 布局: 确认组件宽度与 Grid 列宽匹配
- 检查父容器: 确认父容器的 、
display、gap设置padding - 使用 DevTools: 检查计算后的样式值
When encountering spacing issues, check in the following order:
- Check globals.css: Confirm there's no
* { margin: 0; padding: 0; } - Check Tailwind classes: Confirm ,
p-*,m-*,gap-*classes are workingspace-* - Check Grid layout: Confirm component width matches Grid column width
- Check parent container: Confirm parent container's ,
display,gapsettingspadding - Use DevTools: Check computed style values
Tailwind 间距类速查
Tailwind Spacing Class Quick Reference
| 类名 | 值 | 说明 |
|---|---|---|
| 12px | padding: 12px |
| 12px | padding-left/right: 12px |
| 12px | padding-top/bottom: 12px |
| 12px | margin: 12px |
| 12px | margin-bottom: 12px |
| 12px | gap: 12px (Grid/Flex) |
| 12px | 子元素间 margin-top |
| Class Name | Value | Description |
|---|---|---|
| 12px | padding: 12px |
| 12px | padding-left/right: 12px |
| 12px | padding-top/bottom: 12px |
| 12px | margin: 12px |
| 12px | margin-bottom: 12px |
| 12px | gap: 12px (Grid/Flex) |
| 12px | margin-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 file
/docs/component-mapping.mdFormat:
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
- Figma 图标: 从 Figma 导出的自定义图标
- Lucide 图标库: https://lucide.dev/ 作为补充图标库
- Figma Icons: Custom icons exported from Figma
- 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 to hint browser for optimization
willChange - Prioritize using property
transform - Avoid animating layout properties (width, height, top, left)
无障碍
Accessibility
支持 媒体查询
prefers-reduced-motionSupport media query
prefers-reduced-motion动画类型
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: configuration
darkMode: 'class' - 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 skill:
web-design-guidelines| Category | Requirements |
|---|---|
| Semantic HTML | Use correct HTML elements |
| ARIA Attributes | Add aria-label, aria-describedby, etc. when necessary |
| Keyboard Navigation | All interactive elements are accessible via keyboard |
| Focus Management | Visible focus state, use focus-visible |
| Color Contrast | Meet WCAG AA standard (4.5:1) |
图片处理
Image Handling
- 来源: Figma 中的图片资源
- 实现:
- 使用 Next.js 组件
<Image> - 自动优化和懒加载
- 响应式图片
- 提供 alt 文本
- 使用 Next.js
- Source: Image resources from Figma
- Implementation:
- Use Next.js component
<Image> - Automatic optimization and lazy loading
- Responsive images
- Provide alt text
- Use Next.js
代码风格
Code Style
| 类别 | 规范 |
|---|---|
| 语言 | TypeScript(强类型定义) |
| 组件文件 | PascalCase(如 |
| 工具函数 | camelCase(如 |
| 常量 | UPPER_SNAKE_CASE(如 |
| Category | Specifications |
|---|---|
| Language | TypeScript (strongly typed definitions) |
| Component Files | PascalCase (e.g., |
| Utility Functions | camelCase (e.g., |
| Constants | UPPER_SNAKE_CASE (e.g., |
工作流程
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 创建项目时,应输出以下文件:
- - 颜色令牌(含 Light/Dark)
/styles/tokens/colors.ts - - 字体令牌
/styles/tokens/typography.ts - - 间距令牌
/styles/tokens/spacing.ts - - 阴影令牌
/styles/tokens/shadows.ts - - 统一导出
/styles/tokens/index.ts - - 全局样式
/styles/globals.css - - 组件命名映射规则
/docs/component-mapping.md - - 主题提供者
/components/ThemeProvider.tsx - - Tailwind 配置(含设计令牌)
/tailwind.config.ts
When creating a project from Figma each time, the following files should be output:
- - Color tokens (including Light/Dark)
/styles/tokens/colors.ts - - Typography tokens
/styles/tokens/typography.ts - - Spacing tokens
/styles/tokens/spacing.ts - - Shadow tokens
/styles/tokens/shadows.ts - - Unified export
/styles/tokens/index.ts - - Global styles
/styles/globals.css - - Component naming mapping rules
/docs/component-mapping.md - - Theme provider
/components/ThemeProvider.tsx - - Tailwind configuration (including design tokens)
/tailwind.config.ts
触发条件
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
- 颜色来源: 所有颜色必须从 Figma 提取,不使用技能内置颜色
- 间距优化: 如需优化间距,必须告知用户优化内容和原因
- Dark 模式: 即使 Figma 没有 Dark 模式设计,也必须自动生成
- 组件映射: 必须创建组件命名映射文件,保持 Figma 与代码的一致性
- 无障碍: 所有组件必须符合 WCAG AA 标准
- ⚠️ 全局样式: 绝对不要在 globals.css 中使用 ,这会覆盖所有 Tailwind 间距类
* { margin: 0; padding: 0; } - 组件宽度: Grid 布局中的组件应使用 而非固定宽度,避免溢出问题
w-full
- Color Source: All colors must be extracted from Figma, do not use built-in colors from the skill
- Spacing Optimization: If spacing optimization is needed, users must be informed of what was optimized and why
- Dark Mode: Even if Figma has no Dark mode design, it must be automatically generated
- Component Mapping: Component naming mapping file must be created to maintain consistency between Figma and code
- Accessibility: All components must meet WCAG AA standards
- ⚠️ Global Styles: Never use in globals.css, this will override all Tailwind spacing classes
* { margin: 0; padding: 0; } - Component Width: Components in Grid layouts should use instead of fixed widths to avoid overflow issues
w-full