registry-component-patterns
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRegistry Component Patterns
注册表组件配置模式
Register 8-bit components in for discovery via .
registry.jsonshadcn add @8bitcn/[component-name]在中注册8-bit组件,以便通过命令发现这些组件。
registry.jsonshadcn add @8bitcn/[component-name]Component Entry Pattern
组件条目配置模式
json
{
"name": "button",
"type": "registry:component",
"title": "8-bit Button",
"description": "A simple 8-bit button component",
"registryDependencies": ["button"],
"files": [
{
"path": "components/ui/8bit/button.tsx",
"type": "registry:component",
"target": "components/ui/8bit/button.tsx"
},
{
"path": "components/ui/8bit/styles/retro.css",
"type": "registry:component",
"target": "components/ui/8bit/styles/retro.css"
}
]
}json
{
"name": "button",
"type": "registry:component",
"title": "8-bit Button",
"description": "A simple 8-bit button component",
"registryDependencies": ["button"],
"files": [
{
"path": "components/ui/8bit/button.tsx",
"type": "registry:component",
"target": "components/ui/8bit/button.tsx"
},
{
"path": "components/ui/8bit/styles/retro.css",
"type": "registry:component",
"target": "components/ui/8bit/styles/retro.css"
}
]
}Block Entry Pattern
布局块条目配置模式
For pre-built layouts like game UIs:
json
{
"name": "chapter-intro",
"type": "registry:block",
"title": "8-bit Chapter Intro",
"description": "A cinematic chapter/level intro with pixel art background.",
"registryDependencies": ["card"],
"categories": ["gaming"],
"files": [
{
"path": "components/ui/8bit/blocks/chapter-intro.tsx",
"type": "registry:block",
"target": "components/ui/8bit/blocks/chapter-intro.tsx"
},
{
"path": "components/ui/8bit/styles/retro.css",
"type": "registry:component",
"target": "components/ui/8bit/styles/retro.css"
},
{
"path": "components/ui/8bit/card.tsx",
"type": "registry:component",
"target": "components/ui/8bit/card.tsx"
}
]
}对于游戏UI这类预构建布局:
json
{
"name": "chapter-intro",
"type": "registry:block",
"title": "8-bit Chapter Intro",
"description": "A cinematic chapter/level intro with pixel art background.",
"registryDependencies": ["card"],
"categories": ["gaming"],
"files": [
{
"path": "components/ui/8bit/blocks/chapter-intro.tsx",
"type": "registry:block",
"target": "components/ui/8bit/blocks/chapter-intro.tsx"
},
{
"path": "components/ui/8bit/styles/retro.css",
"type": "registry:component",
"target": "components/ui/8bit/styles/retro.css"
},
{
"path": "components/ui/8bit/card.tsx",
"type": "registry:component",
"target": "components/ui/8bit/card.tsx"
}
]
}Required retro.css
必须包含retro.css
Always include in registry entries:
retro.cssjson
"files": [
{
"path": "components/ui/8bit/new-component.tsx",
"type": "registry:component",
"target": "components/ui/8bit/new-component.tsx"
},
{
"path": "components/ui/8bit/styles/retro.css",
"type": "registry:component",
"target": "components/ui/8bit/styles/retro.css"
}
]所有注册表条目都必须包含:
retro.cssjson
"files": [
{
"path": "components/ui/8bit/new-component.tsx",
"type": "registry:component",
"target": "components/ui/8bit/new-component.tsx"
},
{
"path": "components/ui/8bit/styles/retro.css",
"type": "registry:component",
"target": "components/ui/8bit/styles/retro.css"
}
]Categories
分类
Use gaming-specific categories:
json
"categories": ["gaming"]Available categories: , , , , , , .
gaminglayoutformdata-displayfeedbacknavigationoverlay使用游戏专属分类:
json
"categories": ["gaming"]可用分类:, , , , , , .
gaminglayoutformdata-displayfeedbacknavigationoverlayRegistry Dependencies
注册表依赖
List base shadcn dependencies:
json
"registryDependencies": ["button", "dialog"]For blocks with multiple components:
json
"registryDependencies": ["card", "button", "progress"]列出基础shadcn依赖:
json
"registryDependencies": ["button", "dialog"]对于包含多个组件的布局块:
json
"registryDependencies": ["card", "button", "progress"]Key Principles
核心原则
- Type - Use for single components,
registry:componentfor layoutsregistry:block - retro.css required - Always include in files array
- Target path - Use same path for source and target
- Categories - Use for retro-themed components
gaming - Dependencies - List base shadcn/ui components (not 8-bit versions)
- Description - Clear, concise description for CLI output
- 类型 - 单个组件使用,布局块使用
registry:componentregistry:block - 必须包含retro.css - 始终在文件数组中包含该文件
- 目标路径 - 源路径与目标路径保持一致
- 分类 - 复古主题组件使用分类
gaming - 依赖 - 列出基础shadcn/ui组件(而非8-bit版本)
- 描述 - 为CLI输出提供清晰简洁的描述
Adding a New Component
添加新组件的步骤
- Create component in
components/ui/8bit/component.tsx - Update with entry (copy existing component as template)
registry.json - Include dependency
retro.css - Test with:
pnpm dlx shadcn@latest add @8bitcn/component
- 在中创建组件
components/ui/8bit/component.tsx - 参考现有组件模板,在中添加对应条目
registry.json - 包含依赖
retro.css - 使用以下命令测试:
pnpm dlx shadcn@latest add @8bitcn/component