new-component

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Instructions

说明

When creating new GPUI components:
  1. Follow existing patterns: Base implementation on components in
    crates/ui/src
    (examples:
    Button
    ,
    Select
    )
  2. Style consistency: Follow existing component styles and Shadcn UI patterns
  3. Component type decision:
    • Use stateless elements for simple components (like
      Button
      )
    • Use stateful elements for complex components with data (like
      Select
      and
      SelectState
      )
  4. API consistency: Maintain the same API style as other elements
  5. Documentation: Create component documentation
  6. Stories: Write component stories in the story folder
创建新的GPUI组件时:
  1. 遵循现有模式:基于
    crates/ui/src
    中的组件进行实现(示例:
    Button
    Select
  2. 样式一致性:遵循现有组件样式及Shadcn UI模式
  3. 组件类型选择
    • 简单组件(如
      Button
      )使用无状态元素
    • 带有数据的复杂组件(如
      Select
      SelectState
      )使用有状态元素
  4. API一致性:保持与其他元素相同的API风格
  5. 文档编写:创建组件文档
  6. Story编写:在story文件夹中编写组件stories

Component Types

组件类型

  • Stateless: Pure presentation components without internal state
  • Stateful: Components that manage their own state and data
  • 无状态(Stateless):无内部状态的纯展示型组件
  • 有状态(Stateful):管理自身状态和数据的组件