refactor: adjust structures and items to add composites, support getTypes API#4
Conversation
Summary of ChangesHello @Aarebecca, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant refactoring to the infographic component system by adding explicit Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a significant refactoring that introduces a composites property to structures and items, enabling a new getTypes API for dynamically generating TypeScript type definitions. This is a valuable addition for developers. The changes are extensive but well-executed, particularly the refactoring of arrow components to improve separation of concerns. I've found a minor inconsistency in the documentation that should be addressed.
| ### 6. values 字段规则 | ||
|
|
||
| 在 `registerItem` 时,需要传入 `values` 字段,表示当前组件使用了哪些封装组件。`values` 的值基于代码实现中使用的组件来确定: | ||
|
|
||
| - **ItemLabel** → `"label"` | ||
| - **ItemDesc** → `"desc"` | ||
| - **ItemValue** → `"value"` | ||
| - **ItemIcon** 或 **ItemIconCircle** → `"icon"` | ||
| - **Illus** → `"illus"` | ||
|
|
||
| **示例**: | ||
|
|
||
| ```typescript | ||
| // 如果组件使用了 ItemLabel 和 ItemDesc | ||
| registerItem('simple-text', { | ||
| component: SimpleText, | ||
| values: ['label', 'desc'] | ||
| }); | ||
|
|
||
| // 如果组件使用了 ItemIcon, ItemLabel, ItemValue 和 ItemDesc | ||
| registerItem('full-card', { | ||
| component: FullCard, | ||
| values: ['icon', 'label', 'value', 'desc'] | ||
| }); | ||
|
|
||
| // 如果组件使用了 Illus, ItemLabel 和 ItemDesc | ||
| registerItem('illus-item', { | ||
| component: IllusItem, | ||
| values: ['illus', 'label', 'desc'] | ||
| }); | ||
| ``` |
There was a problem hiding this comment.
The documentation uses the field name values, but the implementation across all components and the type definition in packages/infographic/src/designs/items/types.ts use composites. To ensure consistency, please update the documentation to use composites. This also applies to other occurrences of values in this file (e.g., lines 518, 740).
### 6. composites 字段规则
在 `registerItem` 时,需要传入 `composites` 字段,表示当前组件使用了哪些封装组件。`composites` 的值基于代码实现中使用的组件来确定:
- **ItemLabel** → `"label"`
- **ItemDesc** → `"desc"`
- **ItemValue** → `"value"`
- **ItemIcon** 或 **ItemIconCircle** → `"icon"`
- **Illus** → `"illus"`
**示例**:
```typescript
// 如果组件使用了 ItemLabel 和 ItemDesc
registerItem('simple-text', {
component: SimpleText,
composites: ['label', 'desc']
});
// 如果组件使用了 ItemIcon, ItemLabel, ItemValue 和 ItemDesc
registerItem('full-card', {
component: FullCard,
composites: ['icon', 'label', 'value', 'desc']
});
// 如果组件使用了 Illus, ItemLabel 和 ItemDesc
registerItem('illus-item', {
component: IllusItem,
composites: ['illus', 'label', 'desc']
});
Invoke:
Output: