implementing-figma-designs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Figma Designs
实现Figma设计稿
This skill helps you implement Figma designs 1:1 using the OneKey component library.
本技能可帮助你使用OneKey组件库1:1还原Figma设计稿。
Core Principles
核心原则
Focus on UI First, Data Later
先UI,后数据
When implementing Figma designs, prioritize pixel-perfect UI over data integration:
- Use mock data - Hardcode data that matches the design exactly
- Skip i18n - Use plain strings directly from the design, no
intl.formatMessage - Skip API calls - No need to fetch real data at this stage
- Match the design - Focus on visual accuracy, spacing, colors, and layout
实现Figma设计稿时,优先保证像素级精准的UI,再考虑数据集成:
- 使用模拟数据 - 硬编码与设计稿完全匹配的数据
- 跳过i18n - 直接使用设计稿中的纯文本,不使用
intl.formatMessage - 跳过API调用 - 此阶段无需获取真实数据
- 匹配设计稿 - 专注于视觉准确性、间距、颜色和布局
What NOT to do
请勿执行以下操作
- Don't worry about where data comes from
- Don't add translation keys (ETranslations)
- Don't create API integration or hooks for fetching
- Don't add complex state management
- 无需关心数据来源
- 不要添加翻译键(ETranslations)
- 不要创建API集成或数据获取hooks
- 不要添加复杂的状态管理
What TO do
需要执行以下操作
- Hardcode text exactly as shown in Figma
- Create mock data arrays/objects that match the design
- Focus on component structure and styling
- Match spacing, colors, and typography from design
- 完全按照Figma中的显示硬编码文本
- 创建与设计稿匹配的模拟数据数组/对象
- 专注于组件结构和样式
- 匹配设计稿中的间距、颜色和排版
Component Lookup (On-Demand)
按需查询组件
When you need to use a component, look up its source and demo:
当你需要使用某个组件时,可查询其源代码和示例:
Source Code Location Pattern
源代码位置规则
text
packages/components/src/{category}/{ComponentName}/Categories:
- - Button, Icon, Image, Skeleton, Spinner, Stack, Heading, SizeableText
primitives/ - - Input, TextArea, Select, Checkbox, Radio, Switch, Slider, Form, OTPInput
forms/ - - IconButton, ActionList, Alert, Toast, Popover, SegmentControl, Pagination, Tooltip
actions/ - - Dialog, Tabs, Banner, Carousel, Table, Stepper
composite/ - - Badge, Progress, Empty, Divider, QRCode, Markdown, LottieView, LinearGradient, BlurView
content/ - - Page, ScrollView, ListView, SectionList, Accordion, Swiper, SearchBar
layouts/
text
packages/components/src/{category}/{ComponentName}/分类:
- - Button, Icon, Image, Skeleton, Spinner, Stack, Heading, SizeableText
primitives/ - - Input, TextArea, Select, Checkbox, Radio, Switch, Slider, Form, OTPInput
forms/ - - IconButton, ActionList, Alert, Toast, Popover, SegmentControl, Pagination, Tooltip
actions/ - - Dialog, Tabs, Banner, Carousel, Table, Stepper
composite/ - - Badge, Progress, Empty, Divider, QRCode, Markdown, LottieView, LinearGradient, BlurView
content/ - - Page, ScrollView, ListView, SectionList, Accordion, Swiper, SearchBar
layouts/
Demo Location Pattern
示例代码位置规则
text
packages/kit/src/views/Developer/pages/Gallery/Components/stories/{ComponentName}.tsxNote: Some demos have different names (e.g., , )
AccordionGallery.tsxNewTabsGallery.tsxtext
packages/kit/src/views/Developer/pages/Gallery/Components/stories/{ComponentName}.tsx注意:部分示例的名称有所不同(例如、)
AccordionGallery.tsxNewTabsGallery.tsxHow to Look Up a Component
如何查询组件
-
Read the source to understand props and structure:text
Read: packages/components/src/{category}/{ComponentName}/index.tsx -
Read the demo for usage examples:text
Glob: packages/kit/src/views/Developer/pages/Gallery/Components/stories/*{ComponentName}*.tsx
-
阅读源代码以了解props和结构:text
Read: packages/components/src/{category}/{ComponentName}/index.tsx -
阅读示例代码获取使用示例:text
Glob: packages/kit/src/views/Developer/pages/Gallery/Components/stories/*{ComponentName}*.tsx
Quick Reference
快速参考
All imports from @onekeyhq/components
@onekeyhq/components从@onekeyhq/components
导入组件
@onekeyhq/componentstsx
import { Button, Stack, XStack, YStack, Icon, ... } from '@onekeyhq/components';tsx
import { Button, Stack, XStack, YStack, Icon, ... } from '@onekeyhq/components';Spacing Tokens
间距令牌
- = 4px,
$1= 8px,$2= 12px,$3= 16px$4 - = 20px,
$5= 24px,$6= 32px,$8= 40px$10
- = 4像素,
$1= 8像素,$2= 12像素,$3= 16像素$4 - = 20像素,
$5= 24像素,$6= 32像素,$8= 40像素$10
Color Tokens
颜色令牌
- Text: ,
$text,$textSubdued$textDisabled - Background: ,
$bg,$bgSubdued,$bgHover$bgActive - Border: ,
$border,$borderSubdued$borderActive - Icon: ,
$icon,$iconSubdued$iconDisabled
- 文本:,
$text,$textSubdued$textDisabled - 背景:,
$bg,$bgSubdued,$bgHover$bgActive - 边框:,
$border,$borderSubdued$borderActive - 图标:,
$icon,$iconSubdued$iconDisabled
Font Size Tokens
字体大小令牌
Headings (large to small):
- ,
$headingXxl,$headingXl,$headingLg,$headingMd,$headingSm$headingXs
Body text (large to small):
- ,
$bodyLg,$bodyMd,$bodySm$bodyXs
With medium weight (append ):
Medium- ,
$bodyLgMedium,$bodyMdMedium,$bodySmMedium$bodyXsMedium
Usage with SizableText:
tsx
<SizableText size="$bodyMd">Regular text</SizableText>
<SizableText size="$bodyMdMedium">Medium weight text</SizableText>
<SizableText size="$headingSm">Small heading</SizableText>标题(从大到小):
- ,
$headingXxl,$headingXl,$headingLg,$headingMd,$headingSm$headingXs
正文字体(从大到小):
- ,
$bodyLg,$bodyMd,$bodySm$bodyXs
中等字重(添加后缀):
Medium- ,
$bodyLgMedium,$bodyMdMedium,$bodySmMedium$bodyXsMedium
SizableText组件使用示例:
tsx
<SizableText size="$bodyMd">Regular text</SizableText>
<SizableText size="$bodyMdMedium">Medium weight text</SizableText>
<SizableText size="$headingSm">Small heading</SizableText>Common Patterns
常见模式
Layout with Stack:
tsx
<YStack gap="$4"> {/* Vertical */}
<XStack gap="$4"> {/* Horizontal */}
<Stack gap="$4"> {/* Default vertical */}Mock Data:
tsx
const mockItems = [
{ name: 'Bitcoin', symbol: 'BTC', value: '$21,432.50' },
{ name: 'Ethereum', symbol: 'ETH', value: '$5,892.30' },
];Button Actions:
tsx
<Button onPress={() => console.log('clicked')}>Action</Button>使用Stack布局:
tsx
<YStack gap="$4"> {/* 垂直布局 */}
<XStack gap="$4"> {/* 水平布局 */}
<Stack gap="$4"> {/* 默认垂直布局 */}模拟数据:
tsx
const mockItems = [
{ name: 'Bitcoin', symbol: 'BTC', value: '$21,432.50' },
{ name: 'Ethereum', symbol: 'ETH', value: '$5,892.30' },
];按钮操作:
tsx
<Button onPress={() => console.log('clicked')}>Action</Button>Workflow
工作流程
- Analyze the Figma design using Figma MCP
- Identify which components are needed
- Look up each component - read source and demo on-demand
- Create mock data matching the design
- Implement the UI with hardcoded values
- 使用Figma MCP分析Figma设计稿
- 确定所需组件
- 查询每个组件 - 按需阅读源代码和示例
- 创建与设计稿匹配的模拟数据
- 使用硬编码值实现UI